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("Regex Based Constraints");
42      }
43  
44      protected void testValidationRegexBasedConstraintsPhone() throws Exception {
45         //Scenario-1
46         waitAndTypeByName("inputField1","1234567890");
47         waitAndClickByLinkText("Usage");
48         fireEvent("inputField1", "focus");
49         Thread.sleep(200);
50         assertElementPresentByXpath("//input[@name='inputField1' and @class='uif-textControl validChar-inputField10 dirty error']");
51      }
52      
53      protected void testValidationRegexBasedConstraintsEmail() throws Exception {
54          waitAndClickByLinkText("Email");
55          
56          //Scenario-1
57          waitAndTypeByName("inputField2","s1!@f.xoh");
58          waitAndClickByLinkText("Usage");
59          assertElementPresentByXpath("//input[@name='inputField2' and @class='uif-textControl validChar-inputField20 dirty error']");
60      }
61      
62      protected void testValidationRegexBasedConstraintsUrl() throws Exception {
63          waitAndClickByLinkText("Url");
64          
65          //Scenario-1
66          waitAndTypeByName("inputField3","www.google.com");
67          waitAndClickByLinkText("Usage");
68          assertElementPresentByXpath("//input[@name='inputField3' and @class='uif-textControl validChar-inputField30 dirty error']");
69      }
70      
71      protected void testValidationRegexBasedConstraintsNowhitespace() throws Exception {
72          waitAndClickByLinkText("No whitespace");
73          
74          //Scenario-1
75          waitAndTypeByName("inputField4","aw e");
76          waitAndClickByLinkText("Usage");
77          assertElementPresentByXpath("//input[@name='inputField4' and @class='uif-textControl validChar-inputField40 dirty error']");
78      }
79      
80      protected void testValidationRegexBasedConstraints12hTime() throws Exception {
81          waitAndClickByLinkText("12h Time");
82          
83          //Scenario-1
84          waitAndTypeByName("inputField5","22:00");
85          waitAndClickByLinkText("Usage");
86          
87          //Currently this field is not working
88  		//assertElementPresentByXpath("//input[@name='inputField5' and @class='uif-textControl validChar-inputField50 dirty error']");
89      }
90      
91      protected void testValidationRegexBasedConstraints24hTime() throws Exception {
92          waitAndClickByLinkText("24h Time");
93          
94          //Scenario-1
95          waitAndTypeByName("inputField6","01:00AM");
96          waitAndClickByLinkText("Usage");
97          
98          //Currently this field is not working
99  		//assertElementPresentByXpath("//input[@name='inputField6' and @class='uif-textControl validChar-inputField60 dirty error']");
100     }
101     
102     protected void testValidationRegexBasedConstraintsTimestamp() throws Exception {
103         waitAndClickByLinkText("Timestamp");
104         
105         //Scenario-1
106         waitAndTypeByName("inputField7","1234-12-30 23:23:23.23");
107         waitAndClickByLinkText("Usage");
108         assertElementPresentByXpath("//input[@name='inputField7' and @class='uif-textControl validChar-inputField70 dirty error']");
109     }
110     
111      protected void testValidationRegexBasedConstraintsYear() throws Exception {
112         waitAndClickByLinkText("Year");
113         
114         //Scenario-1
115         waitAndTypeByName("inputField8","1599");
116         waitAndClickByLinkText("Usage");
117         assertElementPresentByXpath("//input[@name='inputField8' and @class='uif-textControl validChar-inputField80 dirty error']");
118     }
119     
120      protected void testValidationRegexBasedConstraintsMonth() throws Exception {
121         waitAndClickByLinkText("Month");
122         
123         //Scenario-1
124         waitAndTypeByName("inputField9","13");
125         waitAndClickByLinkText("Usage");
126         assertElementPresentByXpath("//input[@name='inputField9' and @class='uif-textControl validChar-inputField90 dirty error']");
127     }
128     
129      protected void testValidationRegexBasedConstraintsZipcode() throws Exception {
130         waitAndClickByLinkText("Zipcode");
131         
132         //Scenario-1
133         waitAndTypeByName("inputField10","94101");
134         waitAndClickByLinkText("Usage");
135         
136         //Currently not working
137         //assertElementPresentByXpath("//input[@name='inputField10' and @class='uif-textControl validChar-inputField100 dirty error']");
138     }
139     
140     protected void testValidationRegexBasedConstraintsJavaclassname() throws Exception {
141         waitAndClickByLinkText("Java classname");
142         
143         //Scenario-1
144         waitAndTypeByName("inputField11","asdf");
145         waitAndClickByLinkText("Usage");
146         
147         //Currently not working
148         //assertElementPresentByXpath("//input[@name='inputField11' and @class='uif-textControl validChar-inputField110 dirty error']");
149     }
150     
151      protected void testValidationRegexBasedConstraintsCustom() throws Exception {
152         waitAndClickByLinkText("Custom");
153         
154         //Scenario-1
155         waitAndTypeByName("inputField12","ab.9");
156         waitAndTypeByName("inputField13","Demo-hi hello");
157         waitAndClickByLinkText("Usage");
158         assertElementPresentByXpath("//input[@name='inputField12' and @class='uif-textControl validChar-inputField120 dirty error']");
159         assertElementPresentByXpath("//input[@name='inputField13' and @class='uif-textControl validChar-inputField130 dirty error']");
160     }
161     
162     @Test
163     public void testValidationRegexBasedConstraintsBookmark() throws Exception {
164         testValidationRegexBasedConstraintsPhone();
165         testValidationRegexBasedConstraintsEmail();
166         testValidationRegexBasedConstraintsUrl();
167         testValidationRegexBasedConstraintsNowhitespace();
168         testValidationRegexBasedConstraints12hTime();
169         testValidationRegexBasedConstraints24hTime();
170         testValidationRegexBasedConstraintsTimestamp();
171         testValidationRegexBasedConstraintsYear();
172         testValidationRegexBasedConstraintsMonth();
173         testValidationRegexBasedConstraintsZipcode();
174         testValidationRegexBasedConstraintsJavaclassname();
175         testValidationRegexBasedConstraintsCustom();
176         passed();
177     }
178 
179     @Test
180     public void testValidationRegexBasedConstraintsNav() throws Exception {
181         testValidationRegexBasedConstraintsPhone();
182         testValidationRegexBasedConstraintsEmail();
183         testValidationRegexBasedConstraintsUrl();
184         testValidationRegexBasedConstraintsNowhitespace();
185         testValidationRegexBasedConstraints12hTime();
186         testValidationRegexBasedConstraints24hTime();
187         testValidationRegexBasedConstraintsTimestamp();
188         testValidationRegexBasedConstraintsYear();
189         testValidationRegexBasedConstraintsMonth();
190         testValidationRegexBasedConstraintsZipcode();
191         testValidationRegexBasedConstraintsJavaclassname();
192         testValidationRegexBasedConstraintsCustom();
193         passed();
194     }
195 
196     @Test
197     public void testValidationRegexBasedConstraintsEmailNav() throws Exception {
198         testValidationRegexBasedConstraintsEmail();
199         passed();
200     }
201 }