1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.admin;
17
18 import org.apache.commons.lang.RandomStringUtils;
19 import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
20 import org.kuali.rice.testtools.selenium.WebDriverUtils;
21
22
23
24
25 public abstract class CampusActionListAftBase extends CampusAftBase {
26
27
28
29
30
31
32 public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL+"?channelTitle=Campus&channelUrl="+ WebDriverUtils
33 .getBaseUrlString()+"/kr/lookup.do?methodToCall=start&businessObjectClassName=org.kuali.rice.location.impl.campus.CampusBo&docFormKey=88888888&returnLocation="+
34 AutomatedFunctionalTestUtils.PORTAL_URL+ AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
35
36 @Override
37 protected String getBookmarkUrl() {
38 return BOOKMARK_URL;
39 }
40
41 private void assertActionListRequestGroup(String userInGroup, String group, String namespace, String actionCode, String beforeState, String afterState) throws InterruptedException {
42 namespaceCode = namespace;
43 String docId = testCreateActionRequestGroup(group, namespace, actionCode);
44 impersonateUser(userInGroup);
45 assertActionList(docId, actionCode, beforeState);
46 assertOutbox(docId, afterState);
47 selectTopFrame();
48 }
49
50 private void assertActionListRequestPerson(String user, String actionType, String beforeState, String afterState) throws Exception {
51 String[][] adhocRequests = new String [][]{{user, actionType}};
52 assertActionListRequestPerson(adhocRequests, beforeState, afterState);
53 }
54
55 private void assertActionListRequestPerson(String[][] adhocRequests, String beforeState, String afterState) throws Exception {
56 String docId = testCreateActionRequestPerson(adhocRequests);
57 impersonateUser(adhocRequests[0][0]);
58 assertActionList(docId, adhocRequests[0][1], beforeState);
59 assertOutbox(docId, afterState);
60 selectTopFrame();
61 }
62
63 protected String testCreateActionRequestGroup(String user, String namespace, String actionType) throws InterruptedException{
64 String docId = testCreateNew();
65 addAdHocRecipientsGroup(new String[]{user, actionType, namespace});
66 checkForDocError();
67 waitAndClickByName("methodToCall.route");
68 waitForProgress("Submitting...");
69
70 reattemptPrimaryKey();
71
72 waitForTextPresent("Document was successfully submitted");
73 waitAndClickByName("methodToCall.close");
74
75 return docId;
76 }
77
78
79
80
81
82
83
84
85
86
87 protected String testCreateActionRequestPerson(String[][] userActions) throws InterruptedException {
88 String docId = testCreateNew();
89 if (!userActions[0][0].isEmpty()){
90 addAdHocRecipientsPerson(userActions);
91 }
92
93 checkForDocError();
94 waitAndClickByName("methodToCall.route");
95 waitForProgress("Submitting...");
96
97 reattemptPrimaryKey();
98
99 waitForTextPresent("Document was successfully submitted");
100 waitAndClickByName("methodToCall.close");
101
102 return docId;
103 }
104
105 private void reattemptPrimaryKey() throws InterruptedException {
106 int attempts = 0;
107 while (hasDocError() && extractErrorText().contains("a record with the same primary key already exists.") &&
108 ++attempts <= 3) {
109 jGrowl("record with the same primary key already exists trying another, attempt: " + attempts);
110 clearTextByName("document.newMaintainableObject.code");
111 jiraAwareTypeByName("document.newMaintainableObject.code", RandomStringUtils.randomAlphanumeric(2));
112 waitAndClickByName("methodToCall.route");
113 waitForProgress("Submitting...");
114 }
115 }
116
117 public void testActionListAcknowledgeGroup() throws Exception {
118 assertActionListRequestGroup("fran", "RecipeMasters", "KR-WKFLW", "K", "PROCESSED", "FINAL");
119 passed();
120 }
121
122
123
124
125
126
127 public void testActionListAcknowledgePerson() throws Exception {
128 assertActionListRequestPerson("erin", "K", "PROCESSED", "FINAL");
129 passed();
130 }
131
132
133
134
135
136
137
138 public void testActionListAcknowledgePerson_WithPendingApprove() throws Exception {
139 String[][] adhocRequests = new String [][]{{"fred","A"},{"fran","K"}};
140 String docId = testCreateActionRequestPerson(adhocRequests);
141 impersonateUser("fran");
142 assertActionList(docId, "K", "ENROUTE");
143 assertOutbox(docId, "ENROUTE");
144 selectTopFrame();
145 passed();
146 }
147
148
149
150
151
152
153
154 public void testActionListAcknowledgePerson_WithPendingAcknowledge() throws Exception {
155 String[][] adhocRequests = new String [][]{{"fred","K"},{"fran","K"}};
156 String docId = testCreateActionRequestPerson(adhocRequests);
157 impersonateUser("fran");
158 assertActionList(docId, "K", "PROCESSED");
159 assertOutbox(docId, "PROCESSED");
160 selectTopFrame();
161 passed();
162 }
163
164
165
166
167
168
169 public void testActionListApprovePerson() throws Exception {
170 assertActionListRequestPerson("fred", "A", "ENROUTE", "FINAL");
171 passed();
172 }
173
174
175
176
177
178
179
180 public void testActionListApprovePerson_WithPendingApprove() throws Exception {
181 String[][] adhocRequests = new String [][]{{"fred","A"},{"fran","A"}};
182 assertActionListRequestPerson(adhocRequests, "ENROUTE", "ENROUTE");
183 passed();
184 }
185
186
187
188
189
190
191
192 public void testActionListApprovePerson_WithPendingAcknowledge() throws Exception {
193 String[][] adhocRequests = new String [][]{{"fran","A"},{"fred","K"}};
194 assertActionListRequestPerson(adhocRequests, "ENROUTE", "PROCESSED");
195 passed();
196 }
197
198 public void testActionListApproveGroup() throws Exception {
199 assertActionListRequestGroup("fred", "RecipeMasters", "KR-WKFLW", "A", "ENROUTE", "FINAL");
200 passed();
201 }
202
203 public void testActionListCompleteGroup() throws Exception {
204 assertActionListRequestGroup("dev1", "Kuali Developers", "KUALI", "C", "ENROUTE", "FINAL");
205 passed();
206 }
207
208
209
210
211
212
213 public void testActionListCompletePerson() throws Exception {
214 assertActionListRequestPerson("fran", "C", "ENROUTE", "FINAL");
215 passed();
216 }
217
218 public void testActionListCompletePerson_WithPendingAcknowledge() throws Exception {
219 String[][] adhocRequests = new String [][]{{"fran","C"},{"fred","K"}};
220 assertActionListRequestPerson(adhocRequests, "ENROUTE", "PROCESSED");
221 passed();
222 }
223
224 public void testActionListDisapproveGroup() throws Exception {
225 assertActionListRequestGroup("director", "ChickenRecipeMasters", "KR-WKFLW", "D", "ENROUTE", "DISAPPROVED");
226 passed();
227 }
228
229
230
231
232
233
234 public void testActionListDisapprovePerson() throws Exception {
235 assertActionListRequestPerson("fred", "D", "ENROUTE", "DISAPPROVED");
236 passed();
237 }
238
239 public void testActionListFyiGroup() throws Exception {
240 assertActionListRequestGroup("dev2", "Kuali Developers", "KUALI", "F", "FINAL", "FINAL");
241 passed();
242 }
243
244
245
246
247
248
249 public void testActionListFyiPerson() throws Exception {
250 assertActionListRequestPerson("eric", "F", "FINAL", "FINAL");
251 passed();
252 }
253
254
255
256 public void testActionListCancelPerson() throws Exception {
257 assertActionListRequestGroup("dev2", "Kuali Developers", "KUALI", "F", "FINAL", "FINAL");
258 passed();
259 }
260
261 public void testCampusActionListRecallAndCancel_WithPendingPersonApprove() throws Exception {
262 String user = "erin";
263 String docId = testCreateNew();
264 addAdHocRecipientsPerson(new String[]{user, "A"});
265 submit();
266 recall(true);
267 impersonateUser(user);
268 assertNotInActionList(docId);
269 passed();
270 }
271
272 public void testCampusActionListRecallToActionList_WithPendingPersonApprove() throws Exception {
273 String user = "erin";
274
275 String docId = testCreateNew();
276 addAdHocRecipientsPerson(new String[]{user, "A"});
277 submit();
278 waitForTextPresent("ENROUTE");
279 recall(false);
280
281 assertActionList(docId, "CR", "SAVED");
282
283 driver.navigate().to(WebDriverUtils.getBaseUrlString() + BOOKMARK_URL);
284 waitAndClickDocSearch();
285 selectFrameIframePortlet();
286 waitAndTypeByName("documentId",docId);
287 waitAndClickByXpath(SEARCH_XPATH);
288 waitForTextPresent("FINAL");
289 passed();
290 }
291
292 public void testCampusActionListCancel_WithPendingPersonApprove()throws Exception {
293 String docId = testCreateNew();
294 addAdHocRecipientsPerson(new String[]{"fred", "A"});
295 waitAndClickByName("methodToCall.cancel");
296 assertDocSearchNoResults(docId);
297 passed();
298 }
299
300 public void testCampusActionListSave_WithPendingPersonApprove() throws Exception {
301 String user = "erin";
302 String docId = testCreateNew();
303 addAdHocRecipientsPerson(new String[]{user, "A"});
304 saveAndReload();
305 waitForTextPresent("SAVED");
306 passed();
307 }
308
309 public void assertCampusActionListSubmit_WithPersonRequest(String user, String action, String state) throws Exception {
310 String[][] userActions = new String [][]{{user, action}};
311 String docId = testCreateNew();
312 if (!userActions[0][0].isEmpty()){
313 addAdHocRecipientsPerson(userActions);
314 }
315
316 checkForDocError();
317 waitAndClickByName("methodToCall.route");
318 waitForProgress("Submitting...");
319
320 reattemptPrimaryKey();
321
322 waitForTextPresent("Document was successfully submitted");
323
324 waitForTextPresent("ENROUTE");
325 waitAndClickByName("methodToCall.reload");
326 waitForTextPresent(state);
327 close();
328 }
329
330 public void testCampusActionListSubmit() throws Exception {
331 assertCampusActionListSubmit_WithPersonRequest("", "", "FINAL");
332 passed();
333 }
334
335 public void testCampusActionListSubmit_WithPendingPersonApprove() throws Exception {
336 assertCampusActionListSubmit_WithPersonRequest("erin", "A", "ENROUTE");
337 passed();
338 }
339
340 public void testCampusActionListSubmit_WithPendingPersonAcknowledge() throws Exception {
341 assertCampusActionListSubmit_WithPersonRequest("erin", "K", "PROCESSED");
342 passed();
343 }
344
345 public void testCampusActionListSubmit_WithPendingPersonFyi() throws Exception {
346 assertCampusActionListSubmit_WithPersonRequest("erin", "F", "FINAL");
347 passed();
348 }
349
350
351 }