001    /*
002     * Copyright 2006-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package edu.samplu.krad.compview;
018    
019    import edu.samplu.common.UpgradedSeleniumITBase;
020    import junit.framework.Assert;
021    import org.junit.Test;
022    
023    /**
024     * @author Kuali Rice Team (rice.collab@kuali.org)
025     */
026    public class ContraintsIT extends UpgradedSeleniumITBase {
027    
028        @Override
029        public String getTestUrl() {
030            return "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page3";
031        }
032    
033        @Test
034        public void testContraintsIT() throws Exception {
035            selenium.focus("name=field9");
036            selenium.type("name=field9", "1");
037            selenium.fireEvent("name=field9", "blur");
038            Assert.assertTrue(selenium.getAttribute("name=field9@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
039            selenium.focus("name=field9");
040            selenium.type("name=field9", "12345");
041            selenium.fireEvent("name=field9", "blur");
042            Assert.assertTrue(selenium.getAttribute("name=field9@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
043            selenium.focus("name=field10");
044            selenium.type("name=field10", "2");
045            selenium.fireEvent("name=field10", "blur");
046            Assert.assertTrue(selenium.getAttribute("name=field10@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
047            selenium.focus("name=field10");
048            selenium.type("name=field10", "51");
049            selenium.fireEvent("name=field10", "blur");
050            Assert.assertTrue(selenium.getAttribute("name=field10@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
051            selenium.focus("name=field10");
052            selenium.type("name=field10", "25");
053            selenium.fireEvent("name=field10", "blur");
054            Assert.assertTrue(selenium.getAttribute("name=field10@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
055            selenium.focus("name=field6");
056            selenium.type("name=field6", "A");
057            selenium.fireEvent("name=field6", "blur");
058            selenium.fireEvent("name=field7", "blur");
059            Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
060            selenium.type("name=field7", "B");
061            selenium.fireEvent("name=field7", "blur");
062            Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
063            selenium.fireEvent("name=field8", "blur");
064            Assert.assertTrue(selenium.getAttribute("name=field8@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
065            selenium.type("name=field8", "C");
066            selenium.fireEvent("name=field8", "blur");
067            Assert.assertTrue(selenium.getAttribute("name=field8@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
068            selenium.type("name=field6", "");
069            selenium.fireEvent("name=field6", "blur");
070            Assert.assertTrue(selenium.getAttribute("name=field6@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
071            selenium.type("name=field7", "");
072            selenium.fireEvent("name=field7", "blur");
073            Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
074            selenium.type("name=field8", "");
075            selenium.fireEvent("name=field8", "blur");
076            Assert.assertTrue(selenium.getAttribute("name=field6@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
077            Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
078            Assert.assertTrue(selenium.getAttribute("name=field8@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
079            selenium.type("name=field8", "C");
080            selenium.fireEvent("name=field8", "blur");
081            Assert.assertTrue(selenium.getAttribute("name=field6@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
082            Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
083            Assert.assertTrue(selenium.getAttribute("name=field8@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
084            selenium.type("name=field6", "A");
085            selenium.fireEvent("name=field6", "blur");
086            Assert.assertTrue(selenium.getAttribute("name=field6@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
087            Assert.assertTrue(selenium.getAttribute("name=field7@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
088            Assert.assertTrue(selenium.getAttribute("name=field8@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
089            selenium.type("name=field14", "A");
090            selenium.fireEvent("name=field14", "blur");
091            Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
092            selenium.type("name=field11", "A");
093            selenium.fireEvent("name=field11", "blur");
094            Assert.assertTrue(selenium.getAttribute("name=field11@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
095            Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
096            selenium.type("name=field11", "");
097            selenium.fireEvent("name=field11", "blur");
098            Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
099            selenium.type("name=field12", "A");
100            selenium.fireEvent("name=field12", "blur");
101            Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
102            selenium.type("name=field13", "A");
103            selenium.fireEvent("name=field13", "blur");
104            Assert.assertTrue(selenium.getAttribute("name=field13@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
105            Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
106            selenium.type("name=field11", "A");
107            selenium.fireEvent("name=field11", "blur");
108            Assert.assertTrue(selenium.getAttribute("name=field11@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
109            Assert.assertTrue(selenium.getAttribute("name=field14@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
110            selenium.type("name=field18", "A");
111            selenium.fireEvent("name=field18", "blur");
112            Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
113            selenium.type("name=field15", "A");
114            selenium.fireEvent("name=field15", "blur");
115            Assert.assertTrue(selenium.getAttribute("name=field15@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
116            Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
117            selenium.type("name=field15", "");
118            selenium.fireEvent("name=field15", "blur");
119            Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
120            selenium.type("name=field16", "A");
121            selenium.fireEvent("name=field16", "blur");
122            Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
123            selenium.type("name=field17", "A");
124            selenium.fireEvent("name=field17", "blur");
125            Assert.assertTrue(selenium.getAttribute("name=field17@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
126            Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
127            selenium.type("name=field15", "A");
128            selenium.fireEvent("name=field15", "blur");
129            Assert.assertTrue(selenium.getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
130            selenium.type("name=field23", "A");
131            selenium.fireEvent("name=field23", "blur");
132            Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
133            selenium.type("name=field19", "A");
134            selenium.fireEvent("name=field19", "blur");
135            Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
136            selenium.type("name=field19", "");
137            selenium.fireEvent("name=field19", "blur");
138            selenium.type("name=field20", "B");
139            selenium.fireEvent("name=field20", "blur");
140            Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
141            selenium.type("name=field20", "");
142            selenium.fireEvent("name=field20", "blur");
143            Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
144            selenium.type("name=field21", "C");
145            selenium.fireEvent("name=field21", "blur");
146            Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
147            selenium.type("name=field22", "D");
148            selenium.fireEvent("name=field22", "blur");
149            Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
150            selenium.type("name=field19", "D");
151            selenium.fireEvent("name=field19", "blur");
152            Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
153            selenium.type("name=field20", "D");
154            selenium.fireEvent("name=field20", "blur");
155            Assert.assertTrue(selenium.getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
156            selenium.check("name=field24 value=case1");
157            selenium.type("name=field25", "");
158            selenium.fireEvent("name=field25", "blur");
159            Assert.assertTrue(selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
160            selenium.check("name=field24 value=case4");
161            selenium.fireEvent("name=field24", "blur");
162            for (int second = 0; ; second++) {
163                if (second >= 60) {
164                    Assert.fail("timeout");
165                }
166                try {
167                    if (selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
168                        break;
169                    }
170                } catch (Exception e) {
171                }
172                Thread.sleep(1000);
173            }
174    
175            Assert.assertTrue(selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
176            selenium.check("name=field24 value=case1");
177            selenium.fireEvent("name=field24", "blur");
178            selenium.type("name=field25", "$100");
179            selenium.fireEvent("name=field25", "blur");
180            for (int second = 0; ; second++) {
181                if (second >= 60) {
182                    Assert.fail("timeout");
183                }
184                try {
185                    if (selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
186                        break;
187                    }
188                } catch (Exception e) {
189                }
190                Thread.sleep(1000);
191            }
192    
193            Assert.assertTrue(selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
194            selenium.check("name=field24 value=case2");
195            selenium.fireEvent("name=field24", "blur");
196            for (int second = 0; ; second++) {
197                if (second >= 60) {
198                    Assert.fail("timeout");
199                }
200                try {
201                    if (selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
202                        break;
203                    }
204                } catch (Exception e) {
205                }
206                Thread.sleep(1000);
207            }
208    
209            Assert.assertTrue(selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
210            selenium.type("name=field25", "A100");
211            selenium.fireEvent("name=field25", "blur");
212            Assert.assertTrue(selenium.getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
213            selenium.check("name=field24 value=case3");
214            selenium.fireEvent("name=field24", "blur");
215            selenium.type("name=field26", "6000");
216            selenium.fireEvent("name=field26", "blur");
217            for (int second = 0; ; second++) {
218                if (second >= 60) {
219                    Assert.fail("timeout");
220                }
221                try {
222                    if (selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
223                        break;
224                    }
225                } catch (Exception e) {
226                }
227                Thread.sleep(1000);
228            }
229    
230            Assert.assertTrue(selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
231            selenium.type("name=field26", "501");
232            selenium.fireEvent("name=field26", "blur");
233            Assert.assertTrue(selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
234            selenium.type("name=field26", "499");
235            selenium.fireEvent("name=field26", "blur");
236            Assert.assertTrue(selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
237            selenium.type("name=field26", "6000");
238            selenium.fireEvent("name=field26", "blur");
239            selenium.check("name=field24 value=case3");
240            selenium.fireEvent("name=field24", "blur");
241            for (int second = 0; ; second++) {
242                if (second >= 60) {
243                    Assert.fail("timeout");
244                }
245                try {
246                    if (selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
247                        break;
248                    }
249                } catch (Exception e) {
250                }
251                Thread.sleep(1000);
252            }
253    
254            Assert.assertTrue(selenium.getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
255            selenium.check("name=field24 value=case4");
256            selenium.type("name=field27", "A");
257            selenium.fireEvent("name=field27", "blur");
258            selenium.type("name=field28", "");
259            selenium.fireEvent("name=field28", "blur");
260            for (int second = 0; ; second++) {
261                if (second >= 60) {
262                    Assert.fail("timeout");
263                }
264                try {
265                    if (selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
266                        break;
267                    }
268                } catch (Exception e) {
269                }
270                Thread.sleep(1000);
271            }
272    
273            Assert.assertTrue(selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
274            selenium.check("name=field24 value=case3");
275            selenium.fireEvent("name=field24", "blur");
276            for (int second = 0; ; second++) {
277                if (second >= 60) {
278                    Assert.fail("timeout");
279                }
280                try {
281                    if (selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
282                        break;
283                    }
284                } catch (Exception e) {
285                }
286                Thread.sleep(1000);
287            }
288    
289            Assert.assertTrue(selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
290            selenium.type("name=field28", "B");
291            selenium.fireEvent("name=field28", "blur");
292            selenium.check("name=field24 value=case4");
293            selenium.fireEvent("name=field24", "blur");
294            for (int second = 0; ; second++) {
295                if (second >= 60) {
296                    Assert.fail("timeout");
297                }
298                try {
299                    if (selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
300                        break;
301                    }
302                } catch (Exception e) {
303                }
304                Thread.sleep(1000);
305            }
306    
307            Assert.assertTrue(selenium.getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
308            selenium.type("name=field31", "B");
309            selenium.type("name=field32", "B");
310            selenium.fireEvent("name=field33", "blur");
311            Assert.assertTrue(selenium.getAttribute("name=field33@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
312            selenium.type("name=field33", "B");
313            selenium.fireEvent("name=field33", "blur");
314            Assert.assertTrue(selenium.getAttribute("name=field33@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
315            selenium.type("name=field32", "A");
316            selenium.type("name=field33", "");
317            selenium.fireEvent("name=field33", "blur");
318            Assert.assertTrue(selenium.getAttribute("name=field33@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
319        }
320    }