View Javadoc
1   /**
2    * Copyright 2005-2016 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 org.kuali.rice.krad.demo.uif.library.validation;
17  
18  import org.junit.Test;
19  
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class LibraryValidationRegexBasedConstraintsAft extends WebDriverLegacyITBase {
26  
27      /**
28       * /kr-krad/kradsampleapp?viewId=Demo-ConfigurationBasedRegexPatternConstraintView&methodToCall=start
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-ConfigurationBasedRegexPatternConstraintView&methodToCall=start";
31  
32      @Override
33      protected String getBookmarkUrl() {
34          return BOOKMARK_URL;
35      }
36  
37      @Override
38      protected void navigate() throws Exception {
39          waitAndClickLibraryLink();
40          waitAndClickByLinkText("Validation");
41          waitAndClickByLinkText("Regex Based Constraints");
42      }
43  
44      protected void testValidationRegexBasedConstraintsPhone() throws Exception {
45          waitAndClickByLinkText("Phone");
46  
47          //Scenario-1
48          assertFocusTypeBlurError("inputField1","1234567890");
49      }
50      
51      protected void testValidationRegexBasedConstraintsEmail() throws Exception {
52          waitAndClickByLinkText("Email");
53  
54          assertFocusTypeBlurValid("inputField2", "a@kuali.org");
55          assertFocusTypeBlurValid("inputField2", "aa@kuali.org");
56          assertFocusTypeBlurValid("inputField2", "a.a@kuali.org");
57          assertFocusTypeBlurValid("inputField2", "a.aa@kuali.org");
58          assertFocusTypeBlurValid("inputField2", "aa.a@kuali.org");
59          assertFocusTypeBlurValid("inputField2", "aa.aa@kuali.org");
60  
61          assertFocusTypeBlurError("inputField2", "s1!@f.xoh");
62      }
63      
64      protected void testValidationRegexBasedConstraintsUrl() throws Exception {
65          waitAndClickByLinkText("Url");
66          
67          //Scenario-1
68          assertFocusTypeBlurError("inputField3","www.google.com");
69      }
70      
71      protected void testValidationRegexBasedConstraintsNowhitespace() throws Exception {
72          waitAndClickByLinkText("No whitespace");
73          
74          //Scenario-1
75          assertFocusTypeBlurError("inputField4","aw e");
76      }
77      
78      protected void testValidationRegexBasedConstraints12hTime() throws Exception {
79          waitAndClickByLinkText("12h Time");
80          
81          //Scenario-1
82          assertFocusTypeBlurError("inputField5","22:00");
83      }
84      
85      protected void testValidationRegexBasedConstraints24hTime() throws Exception {
86          waitAndClickByLinkText("24h Time");
87          
88          //Scenario-1
89          assertFocusTypeBlurError("inputField6","01:00AM");
90      }
91      
92      protected void testValidationRegexBasedConstraintsTimestamp() throws Exception {
93          waitAndClickByLinkText("Timestamp");
94          
95          //Scenario-1
96          assertFocusTypeBlurError("inputField7","1234-12-30 23:23:23.23");
97      }
98      
99       protected void testValidationRegexBasedConstraintsYear() throws Exception {
100          waitAndClickByLinkText("Year");
101         
102          //Scenario-1
103          assertFocusTypeBlurError("inputField8","1599");
104     }
105     
106      protected void testValidationRegexBasedConstraintsMonth() throws Exception {
107          waitAndClickByLinkText("Month");
108         
109          //Scenario-1
110          assertFocusTypeBlurError("inputField9","13");
111     }
112     
113      protected void testValidationRegexBasedConstraintsZipcode() throws Exception {
114          waitAndClickByLinkText("Zipcode");
115         
116          //Scenario-1
117          assertFocusTypeBlurError("inputField10","941012");
118     }
119     
120     protected void testValidationRegexBasedConstraintsJavaclassname() throws Exception {
121         waitAndClickByLinkText("Java classname");
122         
123         //Scenario-1
124         assertFocusTypeBlurError("inputField11","123");
125     }
126     
127      protected void testValidationRegexBasedConstraintsCustom() throws Exception {
128          waitAndClickByLinkText("Custom");
129         
130          //Scenario-1
131          assertFocusTypeBlurError("inputField12","ab.9");
132          assertFocusTypeBlurError("inputField13","Demo-hi hello");
133     }
134     
135     @Test
136     public void testValidationRegexBasedConstraintsBookmark() throws Exception {
137         testValidationRegexBasedConstraintsPhone();
138         testValidationRegexBasedConstraintsEmail();
139         testValidationRegexBasedConstraintsUrl();
140         testValidationRegexBasedConstraintsNowhitespace();
141         testValidationRegexBasedConstraints12hTime();
142         testValidationRegexBasedConstraints24hTime();
143         testValidationRegexBasedConstraintsTimestamp();
144         testValidationRegexBasedConstraintsYear();
145         testValidationRegexBasedConstraintsMonth();
146         testValidationRegexBasedConstraintsZipcode();
147         testValidationRegexBasedConstraintsJavaclassname();
148         testValidationRegexBasedConstraintsCustom();
149         passed();
150     }
151 
152     @Test
153     public void testValidationRegexBasedConstraintsNav() throws Exception {
154         testValidationRegexBasedConstraintsPhone();
155         testValidationRegexBasedConstraintsEmail();
156         testValidationRegexBasedConstraintsUrl();
157         testValidationRegexBasedConstraintsNowhitespace();
158         testValidationRegexBasedConstraints12hTime();
159         testValidationRegexBasedConstraints24hTime();
160         testValidationRegexBasedConstraintsTimestamp();
161         testValidationRegexBasedConstraintsYear();
162         testValidationRegexBasedConstraintsMonth();
163         testValidationRegexBasedConstraintsZipcode();
164         testValidationRegexBasedConstraintsJavaclassname();
165         testValidationRegexBasedConstraintsCustom();
166         passed();
167     }
168 }