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("Fixed Point Constraint");
42 }
43
44 protected void testValidationRegexBasedConstraintsPhone() throws Exception {
45
46 waitAndTypeByName("inputField1","1234567890");
47 waitAndClickByLinkText("Usage");
48 assertElementPresentByXpath("//input[@name='inputField1' and @class='uif-textControl validChar-inputField10 dirty error']");
49 }
50
51 protected void testValidationRegexBasedConstraintsEmail() throws Exception {
52 waitAndClickByLinkText("Email");
53
54
55 waitAndTypeByName("inputField2","s1!@f.xoh");
56 waitAndClickByLinkText("Usage");
57 assertElementPresentByXpath("//input[@name='inputField2' and @class='uif-textControl validChar-inputField20 dirty error']");
58 }
59
60 protected void testValidationRegexBasedConstraintsUrl() throws Exception {
61 waitAndClickByLinkText("Url");
62
63
64 waitAndTypeByName("inputField3","www.google.com");
65 waitAndClickByLinkText("Usage");
66 assertElementPresentByXpath("//input[@name='inputField3' and @class='uif-textControl validChar-inputField30 dirty error']");
67 }
68
69 protected void testValidationRegexBasedConstraintsNowhitespace() throws Exception {
70 waitAndClickByLinkText("No whitespace");
71
72
73 waitAndTypeByName("inputField4","aw e");
74 waitAndClickByLinkText("Usage");
75 assertElementPresentByXpath("//input[@name='inputField4' and @class='uif-textControl validChar-inputField40 dirty error']");
76 }
77
78 protected void testValidationRegexBasedConstraints12hTime() throws Exception {
79 waitAndClickByLinkText("12h Time");
80
81
82 waitAndTypeByName("inputField5","22:00");
83 waitAndClickByLinkText("Usage");
84
85
86
87 }
88
89 protected void testValidationRegexBasedConstraints24hTime() throws Exception {
90 waitAndClickByLinkText("24h Time");
91
92
93 waitAndTypeByName("inputField6","01:00AM");
94 waitAndClickByLinkText("Usage");
95
96
97
98 }
99
100 protected void testValidationRegexBasedConstraintsTimestamp() throws Exception {
101 waitAndClickByLinkText("Timestamp");
102
103
104 waitAndTypeByName("inputField7","1234-12-30 23:23:23.23");
105 waitAndClickByLinkText("Usage");
106 assertElementPresentByXpath("//input[@name='inputField7' and @class='uif-textControl validChar-inputField70 dirty error']");
107 }
108
109 protected void testValidationRegexBasedConstraintsYear() throws Exception {
110 waitAndClickByLinkText("Year");
111
112
113 waitAndTypeByName("inputField8","1599");
114 waitAndClickByLinkText("Usage");
115 assertElementPresentByXpath("//input[@name='inputField8' and @class='uif-textControl validChar-inputField80 dirty error']");
116 }
117
118 protected void testValidationRegexBasedConstraintsMonth() throws Exception {
119 waitAndClickByLinkText("Month");
120
121
122 waitAndTypeByName("inputField9","13");
123 waitAndClickByLinkText("Usage");
124 assertElementPresentByXpath("//input[@name='inputField9' and @class='uif-textControl validChar-inputField90 dirty error']");
125 }
126
127 protected void testValidationRegexBasedConstraintsZipcode() throws Exception {
128 waitAndClickByLinkText("Zipcode");
129
130
131 waitAndTypeByName("inputField10","94101");
132 waitAndClickByLinkText("Usage");
133
134
135
136 }
137
138 protected void testValidationRegexBasedConstraintsJavaclassname() throws Exception {
139 waitAndClickByLinkText("Java classname");
140
141
142 waitAndTypeByName("inputField11","asdf");
143 waitAndClickByLinkText("Usage");
144
145
146
147 }
148
149 protected void testValidationRegexBasedConstraintsCustom() throws Exception {
150 waitAndClickByLinkText("Custom");
151
152
153 waitAndTypeByName("inputField12","ab.9");
154 waitAndTypeByName("inputField13","Demo-hi hello");
155 waitAndClickByLinkText("Usage");
156 assertElementPresentByXpath("//input[@name='inputField12' and @class='uif-textControl validChar-inputField120 dirty error']");
157 assertElementPresentByXpath("//input[@name='inputField13' and @class='uif-textControl validChar-inputField130 dirty error']");
158 }
159
160 @Test
161 public void testValidationRegexBasedConstraintsBookmark() throws Exception {
162 testValidationRegexBasedConstraintsPhone();
163 testValidationRegexBasedConstraintsEmail();
164 testValidationRegexBasedConstraintsUrl();
165 testValidationRegexBasedConstraintsNowhitespace();
166 testValidationRegexBasedConstraints12hTime();
167 testValidationRegexBasedConstraints24hTime();
168 testValidationRegexBasedConstraintsTimestamp();
169 testValidationRegexBasedConstraintsYear();
170 testValidationRegexBasedConstraintsMonth();
171 testValidationRegexBasedConstraintsZipcode();
172 testValidationRegexBasedConstraintsJavaclassname();
173 testValidationRegexBasedConstraintsCustom();
174 passed();
175 }
176
177 @Test
178 public void testValidationRegexBasedConstraintsNav() throws Exception {
179 testValidationRegexBasedConstraintsPhone();
180 testValidationRegexBasedConstraintsEmail();
181 testValidationRegexBasedConstraintsUrl();
182 testValidationRegexBasedConstraintsNowhitespace();
183 testValidationRegexBasedConstraints12hTime();
184 testValidationRegexBasedConstraints24hTime();
185 testValidationRegexBasedConstraintsTimestamp();
186 testValidationRegexBasedConstraintsYear();
187 testValidationRegexBasedConstraintsMonth();
188 testValidationRegexBasedConstraintsZipcode();
189 testValidationRegexBasedConstraintsJavaclassname();
190 testValidationRegexBasedConstraintsCustom();
191 passed();
192 }
193 }