View Javadoc

1   /*
2    * Copyright 2006-2012 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  
17  package edu.samplu.krad.compview;
18  
19  import edu.samplu.common.WebDriverLegacyITBase;
20  
21  import junit.framework.Assert;
22  import org.junit.Test;
23  
24  /**
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class ContraintsLegacyIT extends WebDriverLegacyITBase {
28  
29      @Override
30      public String getTestUrl() {
31          return "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page3";
32      }
33  
34      @Test
35      public void testContraintsIT() throws Exception {
36          checkForIncidentReport("field9");
37          fireEvent("field9","focus");
38          waitAndTypeByName("field9", "1");
39          fireEvent("field9", "blur");
40          Assert.assertTrue(getAttributeByName("field9","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
41          fireEvent("field9","focus");
42          clearTextByName("field9");
43          waitAndTypeByName("field9", "12345");
44          fireEvent("field9", "blur");
45          Assert.assertTrue(getAttributeByName("field9","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
46          fireEvent("field10","focus");
47          waitAndTypeByName("field10", "2");
48          fireEvent("field10", "blur");
49          Assert.assertTrue(getAttributeByName("field10","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
50          fireEvent("field10","focus");
51          clearTextByName("field10");
52          waitAndTypeByName("field10", "51");
53          fireEvent("field10", "blur");
54          Assert.assertTrue(getAttributeByName("field10","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
55          fireEvent("field10","focus");
56          clearTextByName("field10");
57          waitAndTypeByName("field10", "25");
58          fireEvent("field10", "blur");
59          Assert.assertTrue(getAttributeByName("field10","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
60          fireEvent("field6","focus");
61          waitAndTypeByName("field6", "A");
62          fireEvent("field6", "blur");
63          waitAndTypeByName("field7", "");
64          fireEvent("field7", "blur");
65          Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
66          waitAndTypeByName("field7", "B");
67          fireEvent("field7", "blur");
68          Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
69          waitAndTypeByName("field8", "");
70          fireEvent("field8", "blur");
71          Assert.assertTrue(getAttributeByName("field8","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
72          clearTextByName("field8");
73          waitAndTypeByName("field8", "C");
74          fireEvent("field8", "blur");
75          Assert.assertTrue(getAttributeByName("field8","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
76          clearTextByName("field6");
77          waitAndTypeByName("field6", "");
78          fireEvent("field6", "blur");
79          Assert.assertTrue(getAttributeByName("field6","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
80          clearTextByName("field7");
81          waitAndTypeByName("field7", "");
82          fireEvent("field7", "blur");
83          Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
84          clearTextByName("field8");
85          waitAndTypeByName("field8", "");
86          fireEvent("field8", "blur");
87          Assert.assertTrue(getAttributeByName("field6","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
88          Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
89          Assert.assertTrue(getAttributeByName("field8","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
90          clearTextByName("field8");
91          waitAndTypeByName("field8", "C");
92          fireEvent("field8", "blur");
93          Assert.assertTrue(getAttributeByName("field6","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
94          Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
95          Assert.assertTrue(getAttributeByName("field8","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
96          clearTextByName("field6");
97          waitAndTypeByName("field6", "A");
98          fireEvent("field6", "blur");
99          Assert.assertTrue(getAttributeByName("field6","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
100         Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
101         Assert.assertTrue(getAttributeByName("field8","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
102         waitAndTypeByName("field14", "A");
103         fireEvent("field14", "blur");
104         Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
105         clearTextByName("field11");
106         waitAndTypeByName("field11", "A");
107         fireEvent("field11", "blur");
108         Assert.assertTrue(getAttributeByName("field11","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
109         Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
110         clearTextByName("field11");
111         waitAndTypeByName("field11", "");
112         fireEvent("field11", "blur");
113         Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
114         clearTextByName("field12");
115         waitAndTypeByName("field12", "A");
116         fireEvent("field12", "blur");
117         Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
118         clearTextByName("field13");
119         waitAndTypeByName("field13", "A");
120         fireEvent("field13", "blur");
121         Assert.assertTrue(getAttributeByName("field13","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
122         Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
123         clearTextByName("field11");
124         waitAndTypeByName("field11", "A");
125         fireEvent("field11", "blur");
126         Assert.assertTrue(getAttributeByName("field11","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
127         Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
128         waitAndTypeByName("field18", "A");
129         fireEvent("field18", "blur");
130         Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
131         waitAndTypeByName("field15", "A");
132         fireEvent("field15", "blur");
133         Assert.assertTrue(getAttributeByName("field15","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
134         Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
135         clearTextByName("field15");
136         waitAndTypeByName("field15", "");
137         fireEvent("field15", "blur");
138         Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
139         clearTextByName("field6");
140         waitAndTypeByName("field16", "A");
141         fireEvent("field16", "blur");
142         Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
143         clearTextByName("field17");
144         waitAndTypeByName("field17", "A");
145         fireEvent("field17", "blur");
146         Assert.assertTrue(getAttributeByName("field17","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
147         Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
148         clearTextByName("field15");
149         waitAndTypeByName("field15", "A");
150         fireEvent("field15", "blur");
151         Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
152         waitAndTypeByName("field23", "A");
153         fireEvent("field23", "blur");
154         Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
155         clearTextByName("field19");
156         waitAndTypeByName("field19", "A");
157         fireEvent("field19", "blur");
158         Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
159         clearTextByName("field19");
160         waitAndTypeByName("field19", "");
161         fireEvent("field19", "blur");
162         waitAndTypeByName("field20", "B");
163         fireEvent("field20", "blur");
164         Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
165         clearTextByName("field20");
166         waitAndTypeByName("field20", "");
167         fireEvent("field20", "blur");
168         Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
169         clearTextByName("field21");
170         waitAndTypeByName("field21", "C");
171         fireEvent("field21", "blur");
172         Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
173         clearTextByName("field22");
174         waitAndTypeByName("field22", "D");
175         fireEvent("field22", "blur");
176         Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
177         clearTextByName("field19");
178         waitAndTypeByName("field19", "D");
179         fireEvent("field19", "blur");
180         Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
181         clearTextByName("field20");
182         waitAndTypeByName("field20", "D");
183         fireEvent("field20", "blur");
184         Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
185         checkByXpath("//*[@name='field24' and @value='case1']");
186         clearTextByName("field25");
187         waitAndTypeByName("field25", "");
188         fireEvent("field25", "blur");
189         Assert.assertTrue(getAttributeByName("field25","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
190         checkByXpath("//*[@name='field24' and @value='case4']");
191         fireEvent("field24", "blur");
192         for (int second = 0; ; second++) {
193             if (second >= 60) {
194                 Assert.fail("timeout");
195             }
196             try {
197                 if (getAttributeByName("field25","class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
198                     break;
199                 }
200             } catch (Exception e) {
201             }
202             Thread.sleep(1000);
203         }
204 
205         Assert.assertTrue(getAttributeByName("field25","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
206         checkByXpath("//*[@name='field24' and @value='case1']");
207         fireEvent("field24", "blur");
208         clearTextByName("field25");
209         waitAndTypeByName("field25", "$100");
210         fireEvent("field25", "blur");
211         for (int second = 0; ; second++) {
212             if (second >= 60) {
213                 Assert.fail("timeout");
214             }
215             try {
216                 if (getAttributeByName("field25","class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
217                     break;
218                 }
219             } catch (Exception e) {
220             }
221             Thread.sleep(1000);
222         }
223 
224         Assert.assertTrue(getAttributeByName("field25","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
225         checkByXpath("//*[@name='field24' and @value='case2']");
226         fireEvent("field24", "blur");
227         for (int second = 0; ; second++) {
228             if (second >= 60) {
229                 Assert.fail("timeout");
230             }
231             try {
232                 if (getAttributeByName("field25","class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
233                     break;
234                 }
235             } catch (Exception e) {
236             }
237             Thread.sleep(1000);
238         }
239 
240         Assert.assertTrue(getAttributeByName("field25","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
241         clearTextByName("field25");
242         waitAndTypeByName("field25", "A100");
243         fireEvent("field25", "blur");
244         Assert.assertTrue(getAttributeByName("field25","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
245         checkByXpath("//*[@name='field24' and @value='case3']");
246         fireEvent("field24", "blur");
247         clearTextByName("field26");
248         waitAndTypeByName("field26", "6000");
249         fireEvent("field26", "blur");
250         for (int second = 0; ; second++) {
251             if (second >= 60) {
252                 Assert.fail("timeout");
253             }
254             try {
255                 if (getAttributeByName("field26","class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
256                     break;
257                 }
258             } catch (Exception e) {
259             }
260             Thread.sleep(1000);
261         }
262 
263         Assert.assertTrue(getAttributeByName("field26","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
264         clearTextByName("field26");
265         waitAndTypeByName("field26", "501");
266         fireEvent("field26", "blur");
267         Assert.assertTrue(getAttributeByName("field26","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
268         clearTextByName("field26");
269         waitAndTypeByName("field26", "499");
270         fireEvent("field26", "blur");
271         Assert.assertTrue(getAttributeByName("field26","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
272         clearTextByName("field26");
273         waitAndTypeByName("field26", "6000");
274         fireEvent("field26", "blur");
275         checkByXpath("//*[@name='field24' and @value='case3']");
276         fireEvent("field24", "blur");
277         for (int second = 0; ; second++) {
278             if (second >= 60) {
279                 Assert.fail("timeout");
280             }
281             try {
282                 if (getAttributeByName("field26","class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
283                     break;
284                 }
285             } catch (Exception e) {
286             }
287             Thread.sleep(1000);
288         }
289 
290         Assert.assertTrue(getAttributeByName("field26","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
291         checkByXpath("//*[@name='field24' and @value='case4']");
292         clearTextByName("field27");
293         waitAndTypeByName("field27", "A");
294         fireEvent("field27", "blur");
295         clearTextByName("field28");
296         waitAndTypeByName("field28", "");
297         fireEvent("field28", "blur");
298         for (int second = 0; ; second++) {
299             if (second >= 60) {
300                 Assert.fail("timeout");
301             }
302             try {
303                 if (getAttributeByName("field28","class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
304                     break;
305                 }
306             } catch (Exception e) {
307             }
308             Thread.sleep(1000);
309         }
310 
311         Assert.assertTrue(getAttributeByName("field28","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
312         checkByXpath("//*[@name='field24' and @value='case3']");
313         fireEvent("field24", "blur");
314         for (int second = 0; ; second++) {
315             if (second >= 60) {
316                 Assert.fail("timeout");
317             }
318             try {
319                 if (getAttributeByName("field28","class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
320                     break;
321                 }
322             } catch (Exception e) {
323             }
324             Thread.sleep(1000);
325         }
326 
327         Assert.assertTrue(getAttributeByName("field28","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
328         clearTextByName("field28");
329         waitAndTypeByName("field28", "B");
330         fireEvent("field28", "blur");
331         checkByXpath("//*[@name='field24' and @value='case4']");
332         fireEvent("field24", "blur");
333         for (int second = 0; ; second++) {
334             if (second >= 60) {
335                 Assert.fail("timeout");
336             }
337             try {
338                 if (getAttributeByName("field28","class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
339                     break;
340                 }
341             } catch (Exception e) {
342             }
343             Thread.sleep(1000);
344         }
345 
346         Assert.assertTrue(getAttributeByName("field28","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
347         clearTextByName("field31");
348         waitAndTypeByName("field31", "B");
349         clearTextByName("field32");
350         waitAndTypeByName("field32", "B");
351         waitAndTypeByName("field33", "");
352         fireEvent("field33", "blur");
353         Assert.assertTrue(getAttributeByName("field33","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
354         clearTextByName("field33");
355         waitAndTypeByName("field33", "B");
356         fireEvent("field33", "blur");
357         Assert.assertTrue(getAttributeByName("field33","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
358         clearTextByName("field32");
359         waitAndTypeByName("field32", "A");
360         clearTextByName("field33");
361         waitAndTypeByName("field33", "");
362         fireEvent("field33", "blur");
363         Assert.assertTrue(getAttributeByName("field33","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
364         passed();
365     }
366 }