1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.krad.library.validation;
17
18 import org.junit.Test;
19
20 import edu.samplu.common.SmokeTestBase;
21
22
23
24
25 public class DemoLibraryValidationRegexBasedConstraintsSmokeTest extends SmokeTestBase {
26
27
28
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
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
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
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
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
84 waitAndTypeByName("inputField5","22:00");
85 waitAndClickByLinkText("Usage");
86
87
88
89 }
90
91 protected void testValidationRegexBasedConstraints24hTime() throws Exception {
92 waitAndClickByLinkText("24h Time");
93
94
95 waitAndTypeByName("inputField6","01:00AM");
96 waitAndClickByLinkText("Usage");
97
98
99
100 }
101
102 protected void testValidationRegexBasedConstraintsTimestamp() throws Exception {
103 waitAndClickByLinkText("Timestamp");
104
105
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
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
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
133 waitAndTypeByName("inputField10","94101");
134 waitAndClickByLinkText("Usage");
135
136
137
138 }
139
140 protected void testValidationRegexBasedConstraintsJavaclassname() throws Exception {
141 waitAndClickByLinkText("Java classname");
142
143
144 waitAndTypeByName("inputField11","asdf");
145 waitAndClickByLinkText("Usage");
146
147
148
149 }
150
151 protected void testValidationRegexBasedConstraintsCustom() throws Exception {
152 waitAndClickByLinkText("Custom");
153
154
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 }