View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.samplu.krad.library.validation;
17  
18  import org.junit.Test;
19  
20  import edu.samplu.common.SmokeTestBase;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class DemoLibraryValidationRegexBasedConstraintsSmokeTest extends SmokeTestBase {
26  
27      /**
28       * /kr-krad/kradsampleapp?viewId=Demo-ConfigurationBasedRegexPatternConstraint-View&methodToCall=start
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-ConfigurationBasedRegexPatternConstraint-View&methodToCall=start";
31  
32      @Override
33      protected String getBookmarkUrl() {
34          return BOOKMARK_URL;
35      }
36  
37      @Override
38      protected void navigate() throws Exception {
39          waitAndClickById("Demo-LibraryLink", "");
40          waitAndClickByLinkText("Validation");
41          waitAndClickByLinkText("Fixed Point Constraint");
42      }
43  
44      protected void testValidationRegexBasedConstraintsPhone() throws Exception {
45         //Scenario-1
46         waitAndTypeByName("inputField1","1234567890");
47         waitAndClickByLinkText("Usage");
48         assertElementPresentByXpath("//input[@name='inputField1' and @class='uif-textControl validChar-inputField10 dirty error']");
49      }
50      
51      protected void testValidationRegexBasedConstraintsEmail() throws Exception {
52          waitAndClickByLinkText("Email");
53          
54          //Scenario-1
55          waitAndTypeByName("inputField2","s1!@f.xoh");
56          waitAndClickByLinkText("Usage");
57          assertElementPresentByXpath("//input[@name='inputField2' and @class='uif-textControl validChar-inputField20 dirty error']");
58      }
59      
60      protected void testValidationRegexBasedConstraintsUrl() throws Exception {
61          waitAndClickByLinkText("Url");
62          
63          //Scenario-1
64          waitAndTypeByName("inputField3","www.google.com");
65          waitAndClickByLinkText("Usage");
66          assertElementPresentByXpath("//input[@name='inputField3' and @class='uif-textControl validChar-inputField30 dirty error']");
67      }
68      
69      protected void testValidationRegexBasedConstraintsNowhitespace() throws Exception {
70          waitAndClickByLinkText("No whitespace");
71          
72          //Scenario-1
73          waitAndTypeByName("inputField4","aw e");
74          waitAndClickByLinkText("Usage");
75          assertElementPresentByXpath("//input[@name='inputField4' and @class='uif-textControl validChar-inputField40 dirty error']");
76      }
77      
78      protected void testValidationRegexBasedConstraints12hTime() throws Exception {
79          waitAndClickByLinkText("12h Time");
80          
81          //Scenario-1
82          waitAndTypeByName("inputField5","22:00");
83          waitAndClickByLinkText("Usage");
84          
85          //Currently this field is not working
86  		//assertElementPresentByXpath("//input[@name='inputField5' and @class='uif-textControl validChar-inputField50 dirty error']");
87      }
88      
89      protected void testValidationRegexBasedConstraints24hTime() throws Exception {
90          waitAndClickByLinkText("24h Time");
91          
92          //Scenario-1
93          waitAndTypeByName("inputField6","01:00AM");
94          waitAndClickByLinkText("Usage");
95          
96          //Currently this field is not working
97  		//assertElementPresentByXpath("//input[@name='inputField6' and @class='uif-textControl validChar-inputField60 dirty error']");
98      }
99      
100     protected void testValidationRegexBasedConstraintsTimestamp() throws Exception {
101         waitAndClickByLinkText("Timestamp");
102         
103         //Scenario-1
104         waitAndTypeByName("inputField7","1234-12-30 23:23:23.23");
105         waitAndClickByLinkText("Usage");
106         assertElementPresentByXpath("//input[@name='inputField7' and @class='uif-textControl validChar-inputField70 dirty error']");
107     }
108     
109      protected void testValidationRegexBasedConstraintsYear() throws Exception {
110         waitAndClickByLinkText("Year");
111         
112         //Scenario-1
113         waitAndTypeByName("inputField8","1599");
114         waitAndClickByLinkText("Usage");
115         assertElementPresentByXpath("//input[@name='inputField8' and @class='uif-textControl validChar-inputField80 dirty error']");
116     }
117     
118      protected void testValidationRegexBasedConstraintsMonth() throws Exception {
119         waitAndClickByLinkText("Month");
120         
121         //Scenario-1
122         waitAndTypeByName("inputField9","13");
123         waitAndClickByLinkText("Usage");
124         assertElementPresentByXpath("//input[@name='inputField9' and @class='uif-textControl validChar-inputField90 dirty error']");
125     }
126     
127      protected void testValidationRegexBasedConstraintsZipcode() throws Exception {
128         waitAndClickByLinkText("Zipcode");
129         
130         //Scenario-1
131         waitAndTypeByName("inputField10","94101");
132         waitAndClickByLinkText("Usage");
133         
134         //Currently not working
135         //assertElementPresentByXpath("//input[@name='inputField10' and @class='uif-textControl validChar-inputField100 dirty error']");
136     }
137     
138     protected void testValidationRegexBasedConstraintsJavaclassname() throws Exception {
139         waitAndClickByLinkText("Java classname");
140         
141         //Scenario-1
142         waitAndTypeByName("inputField11","asdf");
143         waitAndClickByLinkText("Usage");
144         
145         //Currently not working
146         //assertElementPresentByXpath("//input[@name='inputField11' and @class='uif-textControl validChar-inputField110 dirty error']");
147     }
148     
149      protected void testValidationRegexBasedConstraintsCustom() throws Exception {
150         waitAndClickByLinkText("Custom");
151         
152         //Scenario-1
153         waitAndTypeByName("inputField12","ab.9");
154         waitAndTypeByName("inputField13","Demo-hi hello");
155         waitAndClickByLinkText("Usage");
156         assertElementPresentByXpath("//input[@name='inputField12' and @class='uif-textControl validChar-inputField120 dirty error']");
157         assertElementPresentByXpath("//input[@name='inputField13' and @class='uif-textControl validChar-inputField130 dirty error']");
158     }
159     
160     @Test
161     public void testValidationRegexBasedConstraintsBookmark() throws Exception {
162         testValidationRegexBasedConstraintsPhone();
163         testValidationRegexBasedConstraintsEmail();
164         testValidationRegexBasedConstraintsUrl();
165         testValidationRegexBasedConstraintsNowhitespace();
166         testValidationRegexBasedConstraints12hTime();
167         testValidationRegexBasedConstraints24hTime();
168         testValidationRegexBasedConstraintsTimestamp();
169         testValidationRegexBasedConstraintsYear();
170         testValidationRegexBasedConstraintsMonth();
171         testValidationRegexBasedConstraintsZipcode();
172         testValidationRegexBasedConstraintsJavaclassname();
173         testValidationRegexBasedConstraintsCustom();
174         passed();
175     }
176 
177     @Test
178     public void testValidationRegexBasedConstraintsNav() throws Exception {
179         testValidationRegexBasedConstraintsPhone();
180         testValidationRegexBasedConstraintsEmail();
181         testValidationRegexBasedConstraintsUrl();
182         testValidationRegexBasedConstraintsNowhitespace();
183         testValidationRegexBasedConstraints12hTime();
184         testValidationRegexBasedConstraints24hTime();
185         testValidationRegexBasedConstraintsTimestamp();
186         testValidationRegexBasedConstraintsYear();
187         testValidationRegexBasedConstraintsMonth();
188         testValidationRegexBasedConstraintsZipcode();
189         testValidationRegexBasedConstraintsJavaclassname();
190         testValidationRegexBasedConstraintsCustom();
191         passed();
192     }
193 }