1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 import org.openqa.selenium.By;
22
23
24
25
26 public class LibraryValidationMustOccurConstraintsAft extends WebDriverLegacyITBase {
27
28
29
30
31 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-MustOccurConstraintView&methodToCall=start";
32
33
34
35
36 private static final String EXAMPLE1_VALIDATION_MESSAGE=" 1-2 of the following must occur: (Field 1A) OR (Field 2A and Field 2B)";
37
38
39
40
41 private static final String EXAMPLE2_VALIDATION_MESSAGE=" The following must occur: (Field 1A) OR (Field 2A and Field 2B)";
42
43
44
45
46 private static final String EXAMPLE3_VALIDATION_MESSAGE=" 1-2 of the following must occur: (Field 1A or Field 1B) OR (Field 2A and Field 2B)";
47
48
49
50
51 private static final String EXAMPLE1_ERROR_XPATH="//input[@name='inputField4' and @class='error']";
52
53
54
55
56 private static final String EXAMPLE2_ERROR_XPATH="//input[@name='inputField8' and @class='error']";
57
58
59
60
61 private static final String EXAMPLE3_ERROR_XPATH="//input[@name='inputField13' and @class='error']";
62
63 @Override
64 protected String getBookmarkUrl() {
65 return BOOKMARK_URL;
66 }
67
68 @Override
69 protected void navigate() throws Exception {
70 waitAndClickLibraryLink();
71 waitAndClickByLinkText("Validation");
72 waitAndClickByLinkText("Must Occur Constraint");
73 }
74
75 protected void testValidationMustOccurConstraintsExample1() throws Exception {
76 waitAndClickByLinkText("Example 1");
77
78
79 assertFocusTypeBlurError("inputField4", "a");
80 fireMouseOverEventByName("inputField4");
81 assertTextPresent(EXAMPLE1_VALIDATION_MESSAGE);
82
83
84 waitAndTypeByName("inputField1","a");
85 waitAndTypeByName("inputField2","");
86 if(isElementPresentByXpath(EXAMPLE1_ERROR_XPATH)) {
87 jiraAwareFail("Criteria Not Satisfied " + this.getClass().toString());
88 }
89
90
91 clearTextByName("inputField1");
92 waitAndTypeByName("inputField4","a");
93 waitAndTypeByName("inputField2", "a");
94 waitAndTypeByName("inputField1","");
95 String id = findElement(By.name("inputField4")).getAttribute("id");
96 assertTrue(findElement(By.id(id)).getAttribute("class").contains("error"));
97 fireEvent("inputField1", "blur");
98 fireMouseOverEventByName("inputField4");
99 assertTextPresent(EXAMPLE1_VALIDATION_MESSAGE);
100
101
102 waitAndTypeByName("inputField3","a");
103 waitAndTypeByName("inputField1","");
104 if(isElementPresentByXpath(EXAMPLE1_ERROR_XPATH)) {
105 jiraAwareFail("Criteria Not Satisfied " + this.getClass().toString());
106 }
107 }
108
109 protected void testValidationMustOccurConstraintsExample2() throws Exception {
110 waitAndClickByLinkText("Example 2");
111
112
113 assertFocusTypeBlurError("inputField8","a");
114 fireMouseOverEventByName("inputField8");
115 assertTextPresent(EXAMPLE2_VALIDATION_MESSAGE);
116
117
118 waitAndTypeByName("inputField5","a");
119 waitAndTypeByName("inputField6","");
120 if(isElementPresentByXpath(EXAMPLE2_ERROR_XPATH)) {
121 jiraAwareFail("Criteria Not Satisfied " + this.getClass().toString());
122 }
123
124
125 clearTextByName("inputField5");
126 waitAndTypeByName("inputField6","a");
127 waitAndTypeByName("inputField8","a");
128 waitAndTypeByName("inputField5","");
129 String id = findElement(By.name("inputField8")).getAttribute("id");
130 assertTrue(findElement(By.id(id)).getAttribute("class").contains("error"));
131 fireEvent("inputField5", "blur");
132 fireMouseOverEventByName("inputField8");
133 assertTextPresent(EXAMPLE2_VALIDATION_MESSAGE);
134
135
136 waitAndTypeByName("inputField7","a");
137 waitAndTypeByName("inputField5","");
138 if (isElementPresentByXpath(EXAMPLE2_ERROR_XPATH)){
139 jiraAwareFail("Criteria Not Satisfied " + this.getClass().toString());
140 }
141
142
143 waitAndTypeByName("inputField5","a");
144 waitAndTypeByName("inputField8","a");
145 assertTrue(findElement(By.id(id)).getAttribute("class").contains("error"));
146 fireEvent("inputField8", "blur");
147 fireMouseOverEventByName("inputField8");
148 assertTextPresent(EXAMPLE2_VALIDATION_MESSAGE);
149 }
150
151 protected void testValidationMustOccurConstraintsExample3() throws Exception {
152 waitAndClickByLinkText("Example 3");
153
154
155 assertFocusTypeBlurError("inputField13","a");
156 fireMouseOverEventByName("inputField13");
157 assertTextPresent(EXAMPLE3_VALIDATION_MESSAGE);
158
159
160 waitAndTypeByName("inputField9","a");
161 waitAndTypeByName("inputField13","");
162 if (isElementPresentByXpath(EXAMPLE3_ERROR_XPATH)) {
163 jiraAwareFail("Criteria Not Satisfied " + this.getClass().toString());
164 }
165 clearTextByName("inputField9");
166
167
168 waitAndTypeByName("inputField10","a");
169 waitAndTypeByName("inputField13","");
170 if (isElementPresentByXpath(EXAMPLE3_ERROR_XPATH)) {
171 jiraAwareFail("Criteria Not Satisfied " + this.getClass().toString());
172 }
173 clearTextByName("inputField10");
174
175
176 waitAndTypeByName("inputField11","a");
177 waitAndTypeByName("inputField12","a");
178 waitAndTypeByName("inputField13","");
179 if (isElementPresentByXpath(EXAMPLE3_ERROR_XPATH)) {
180 jiraAwareFail("Criteria Not Satisfied " + this.getClass().toString());
181 }
182 }
183
184
185 @Test
186 public void testValidationMustOccurConstraintsBookmark() throws Exception {
187 testValidationMustOccurConstraintsExample1();
188 testValidationMustOccurConstraintsExample2();
189 testValidationMustOccurConstraintsExample3();
190 passed();
191 }
192
193 @Test
194 public void testValidationMustOccurConstraintsNav() throws Exception {
195 testValidationMustOccurConstraintsExample1();
196 testValidationMustOccurConstraintsExample2();
197 testValidationMustOccurConstraintsExample3();
198 passed();
199 }
200 }