1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.actions;
18
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.Iterator;
22 import java.util.List;
23
24 import org.junit.Test;
25 import org.kuali.rice.kew.actionitem.ActionItem;
26 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
27 import org.kuali.rice.kew.dto.ActionRequestDTO;
28 import org.kuali.rice.kew.dto.NetworkIdDTO;
29 import org.kuali.rice.kew.exception.WorkflowException;
30 import org.kuali.rice.kew.service.KEWServiceLocator;
31 import org.kuali.rice.kew.service.WorkflowDocument;
32 import org.kuali.rice.kew.test.KEWTestCase;
33 import org.kuali.rice.kew.test.TestUtilities;
34 import org.kuali.rice.kew.util.KEWConstants;
35 import org.kuali.rice.kim.bo.Group;
36 import org.kuali.rice.kim.bo.Person;
37 import org.kuali.rice.kim.service.KIMServiceLocator;
38 import org.kuali.rice.kim.util.KimConstants;
39 import org.kuali.rice.kns.document.authorization.DocumentAuthorizer;
40 import org.kuali.rice.kns.service.DocumentHelperService;
41 import org.kuali.rice.kns.service.KNSServiceLocator;
42
43 public class AdHocRouteTest extends KEWTestCase {
44
45 private static final String ADHOC_DOC = "AdhocRouteTest";
46 private static final String ADHOC_NO_NODE_DOC = "AdHocNoNodeTest";
47 private Long docId;
48
49 protected void loadTestData() throws Exception {
50 loadXmlFile("ActionsConfig.xml");
51 }
52
53 @Test
54 public void testRequestLabel() throws Exception{
55 String note = "test note";
56 Person per = KIMServiceLocator.getPersonService().getPersonByPrincipalName("rkirkend");
57 WorkflowDocument doc = new WorkflowDocument(per.getPrincipalId(), ADHOC_DOC);
58
59 docId = doc.getRouteHeaderId();
60
61 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_FYI_REQ, "AdHoc", "annotation1", getPrincipalIdForName("dewey"), "respDesc1", false, note);
62
63 doc = getDocument(per.getPrincipalId(), docId);
64 List<ActionRequestValue> actionRequests = KEWServiceLocator.getActionRequestService().findAllActionRequestsByRouteHeaderId(docId);
65 for(ActionRequestValue arv : actionRequests){
66 assertTrue("The note we passed in should equal the one we get out. note=["+ note +"]", note.equals(arv.getRequestLabel()));
67 }
68 }
69
70 @Test
71 public void testParallelAdHocRouting() throws Exception {
72 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), ADHOC_DOC);
73 docId = doc.getRouteHeaderId();
74 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc", "annotation1", getPrincipalIdForName("dewey"), "respDesc1", false);
75
76 doc = getDocument("dewey");
77 assertFalse("User andlee should not have an approve request yet. Document not yet routed.", doc.isApprovalRequested());
78
79 doc.adHocRouteDocumentToGroup(KEWConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc", "annotation2", getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "WorkflowAdmin"), "respDesc2", true);
80
81 doc = getDocument("quickstart");
82 assertFalse("User should not have approve request yet. Document not yet routed.", doc.isApprovalRequested());
83
84 doc = getDocument("rkirkend");
85 doc.routeDocument("");
86
87
88 ActionRequestDTO[] actionRequests = doc.getActionRequests();
89 for (int index = 0; index < actionRequests.length; index++) {
90 assertTrue("Request should be an adhoc request.", actionRequests[index].isAdHocRequest());
91 }
92
93
94 WorkflowDocument deweyDoc = getDocument("dewey");
95 assertTrue("Dewey should have an approve request", deweyDoc.isApprovalRequested());
96
97 doc = getDocument("ewestfal");
98
99 assertTrue("WorkflowAdmin should have an approve request", doc.isApprovalRequested());
100
101 deweyDoc.approve("");
102 doc.approve("");
103 doc = getDocument("user1");
104 doc.approve("");
105 assertTrue("The document should be final", doc.stateIsFinal());
106 }
107
108
109
110
111
112
113
114 @Test
115 public void testAdHocToInitiator() throws Exception {
116 final String ADHOC_NODE = "AdHoc";
117 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), ADHOC_DOC);
118 docId = doc.getRouteHeaderId();
119 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_APPROVE_REQ, ADHOC_NODE, "annotation1", getPrincipalIdForName("rkirkend"), "", true);
120
121 doc.routeDocument("");
122 assertTrue(doc.stateIsEnroute());
123
124 doc = getDocument("rkirkend");
125 assertTrue("rkirkend should have an approval request on the document", doc.isApprovalRequested());
126 TestUtilities.assertAtNode(doc, ADHOC_NODE);
127
128
129 doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), ADHOC_DOC);
130 docId = doc.getRouteHeaderId();
131 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_APPROVE_REQ, ADHOC_NODE, "annotation1", getPrincipalIdForName("rkirkend"), "", false);
132
133 doc.routeDocument("");
134 assertTrue(doc.stateIsEnroute());
135
136 doc = getDocument("rkirkend");
137 assertFalse("rkirkend should NOT have an approval request on the document", doc.isApprovalRequested());
138 TestUtilities.assertAtNode(doc, "One");
139 doc = getDocument("user1");
140 assertTrue("user1 should have an approval request on the document", doc.isApprovalRequested());
141 }
142
143 @Test
144 public void testSerialAdHocRouting() throws Exception {
145 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), ADHOC_DOC);
146 docId = doc.getRouteHeaderId();
147 doc.routeDocument("");
148 doc = getDocument("user1");
149 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_APPROVE_REQ, "One", "annotation1", getPrincipalIdForName("user2"), "", false);
150 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_APPROVE_REQ, "One", "annotation1", getPrincipalIdForName("rkirkend"), "", true);
151 doc.approve("");
152 doc = getDocument("rkirkend");
153 assertFalse("rkirkend should not have the document at this point 'S' activation", doc.isApprovalRequested());
154 doc = getDocument("user2");
155 assertTrue("user2 should have an approve request", doc.isApprovalRequested());
156 doc.approve("");
157 doc = getDocument("rkirkend");
158 doc.approve("");
159 assertTrue("The document should be final", doc.stateIsFinal());
160 }
161
162 @Test
163 public void testRepeatedAdHocRouting() throws Exception {
164 final String ADHOC_NODE = "AdHoc";
165 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), ADHOC_DOC);
166 docId = doc.getRouteHeaderId();
167 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_APPROVE_REQ, ADHOC_NODE, "annotation1", getPrincipalIdForName("user2"), "", false);
168 doc.routeDocument("");
169 doc = getDocument("rkirkend");
170 assertFalse("rkirkend should NOT have an approval request on the document", doc.isApprovalRequested());
171
172 doc = getDocument("user1");
173 assertFalse("user1 should NOT have an approval request on the document", doc.isApprovalRequested());
174
175 doc = getDocument("user2");
176 assertTrue("user2 should have an approval request on document", doc.isApprovalRequested());
177 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_APPROVE_REQ, ADHOC_NODE, "annotation1", getPrincipalIdForName("user3"), "", false);
178 doc.approve("");
179 doc = getDocument("user2");
180 assertFalse("user2 should NOT have an approval request on the document", doc.isApprovalRequested());
181
182 doc = getDocument("user3");
183 assertTrue("user3 should have an approval request on document", doc.isApprovalRequested());
184 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_APPROVE_REQ, ADHOC_NODE, "annotation1", getPrincipalIdForName("rkirkend"), "", true);
185 doc.approve("");
186 doc = getDocument("user3");
187 assertFalse("user3 should NOT have an approval request on the document", doc.isApprovalRequested());
188
189 doc = getDocument("rkirkend");
190 assertTrue("rkirkend should have an approval request on document", doc.isApprovalRequested());
191 doc.approve("");
192 doc = getDocument("rkirkend");
193 assertFalse("rkirkend should NOT have an approval request on the document", doc.isApprovalRequested());
194
195
196 doc = getDocument("user1");
197 assertTrue("user1 should have an approval request on document", doc.isApprovalRequested());
198 doc.approve("");
199 doc = getDocument("user1");
200 assertFalse("user1 should NOT have an approval request on the document", doc.isApprovalRequested());
201
202
203 doc = getDocument("rkirkend");
204 assertFalse("rkirkend should NOT have an approval request on the document", doc.isApprovalRequested());
205 doc = getDocument("user2");
206 assertFalse("user2 should NOT have an approval request on the document", doc.isApprovalRequested());
207 doc = getDocument("user3");
208 assertFalse("user3 should NOT have an approval request on the document", doc.isApprovalRequested());
209
210 assertTrue("The document should be final", doc.stateIsFinal());
211 }
212
213 @Test public void testAdHocWhenDocumentIsInitiated() throws Exception {
214 WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), "TakeWorkgroupAuthorityDoc");
215 document.saveRoutingData();
216 assertTrue(document.stateIsInitiated());
217
218 document.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_APPROVE_REQ, "My Annotation", getPrincipalIdForName("rkirkend"), "", true);
219 document.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_FYI_REQ, "My Annotation", getPrincipalIdForName("user1"), "", true);
220
221
222 document = new WorkflowDocument(new NetworkIdDTO("rkirkend"), document.getRouteHeaderId());
223 assertFalse(document.isApprovalRequested());
224 document = new WorkflowDocument(new NetworkIdDTO("user1"), document.getRouteHeaderId());
225 assertFalse(document.isFYIRequested());
226
227
228 document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), document.getRouteHeaderId());
229 document.routeDocument("");
230 document = new WorkflowDocument(new NetworkIdDTO("rkirkend"), document.getRouteHeaderId());
231 assertTrue(document.isApprovalRequested());
232 document = new WorkflowDocument(new NetworkIdDTO("user1"), document.getRouteHeaderId());
233 assertTrue(document.isFYIRequested());
234 }
235
236 @Test public void testAdHocWhenDocumentIsFinal() throws Exception {
237 WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), "TakeWorkgroupAuthorityDoc");
238 document.routeDocument("");
239 TestUtilities.assertAtNode(document, "WorkgroupByDocument");
240
241 try {
242 document.adHocRouteDocumentToPrincipal("A", "AdHoc", "", getPrincipalIdForName("ewestfal"), "", true);
243 fail("document should not be allowed to route to nodes that are complete");
244 } catch (Exception e) {
245 }
246
247
248 document = new WorkflowDocument(new NetworkIdDTO("rkirkend"), document.getRouteHeaderId());
249 assertTrue("rkirkend should have request", document.isApprovalRequested());
250 document.approve("");
251
252 assertTrue("Document should be final", document.stateIsFinal());
253
254 document = new WorkflowDocument(new NetworkIdDTO("user1"), document.getRouteHeaderId());
255 ActionRequestDTO[] requests = document.getActionRequests();
256 for (int i = 0; i < requests.length; i++) {
257 ActionRequestDTO request = requests[i];
258 if (request.isActivated()) {
259 fail("Active requests should not be present on a final document");
260 }
261 }
262
263
264 try {
265 document.adHocRouteDocumentToPrincipal("A", "WorkgroupByDocument", "", getPrincipalIdForName("ewestfal"), "", true);
266 fail("Should not be allowed to adhoc approve to a final document.");
267 } catch (Exception e) {
268
269 }
270
271
272 document = new WorkflowDocument(new NetworkIdDTO("rkirkend"), document.getRouteHeaderId());
273 assertFalse("rkirkend should not have an FYI request.", document.isFYIRequested());
274 document.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_FYI_REQ, "WorkgroupByDocument", "", getPrincipalIdForName("rkirkend"), "", true);
275 document = new WorkflowDocument(new NetworkIdDTO("rkirkend"), document.getRouteHeaderId());
276 assertTrue("rkirkend should have an FYI request", document.isFYIRequested());
277 }
278
279 @Test public void testAdHocWhenDocumentIsSaved() throws Exception {
280 WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), "TakeWorkgroupAuthorityDoc");
281 document.saveDocument("");
282
283
284
285 assertTrue("Document should be saved.", document.stateIsSaved());
286 document.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_FYI_REQ, "AdHoc", "", getPrincipalIdForName("rkirkend"), "", true);
287 document = new WorkflowDocument(new NetworkIdDTO("rkirkend"), document.getRouteHeaderId());
288 assertTrue("rkirkend should have an FYI request", document.isFYIRequested());
289 }
290
291 @Test public void testAdHocFieldsSavedCorrectly() throws Exception {
292 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), ADHOC_DOC);
293 docId = doc.getRouteHeaderId();
294 doc.routeDocument("");
295
296 List<Long> oldRequestIds = new ArrayList<Long>();
297 for (Iterator iterator = KEWServiceLocator.getActionRequestService().findAllActionRequestsByRouteHeaderId(doc.getRouteHeaderId()).iterator(); iterator.hasNext();) {
298 oldRequestIds.add(((ActionRequestValue) iterator.next()).getActionRequestId());
299 }
300
301
302 doc = getDocument("user1");
303 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_APPROVE_REQ, "One", "annotation1", getPrincipalIdForName("user2"), "respDesc", false);
304
305
306 ActionRequestValue request = null;
307 for (Iterator iter = KEWServiceLocator.getActionRequestService().findAllActionRequestsByRouteHeaderId(doc.getRouteHeaderId()).iterator(); iter.hasNext();) {
308 ActionRequestValue actionRequest = (ActionRequestValue) iter.next();
309 if (!oldRequestIds.contains(actionRequest.getActionRequestId())) {
310 request = actionRequest;
311 break;
312 }
313 }
314 assertNotNull("Could not find adhoc routed action request", request);
315
316
317 assertEquals("wrong person", request.getPrincipalId(), getPrincipalIdForName("user2"));
318 assertEquals("annotation incorrect", "annotation1", request.getAnnotation());
319 assertEquals("action requested code incorrect", request.getActionRequested(), KEWConstants.ACTION_REQUEST_APPROVE_REQ);
320 assertEquals("responsibility desc incorrect", request.getResponsibilityDesc(), "respDesc");
321 assertEquals("wrong force action", request.getForceAction(), Boolean.FALSE);
322
323 }
324
325 @Test
326 public void testAdHocDissaprovedDocument() throws Exception {
327 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("ewestfal"), ADHOC_DOC);
328 docId = doc.getRouteHeaderId();
329 doc.routeDocument("");
330
331 doc = getDocument("user1");
332 TestUtilities.assertAtNode(doc, "One");
333 doc.disapprove("");
334 TestUtilities.assertAtNode(doc, "One");
335
336
337 doc.adHocRouteDocumentToPrincipal("F", "One", "", getPrincipalIdForName("rkirkend"), "", true);
338 doc.adHocRouteDocumentToPrincipal("K", "One", "", getPrincipalIdForName("user2"), "", true);
339
340 doc = getDocument("rkirkend");
341 assertTrue(doc.isFYIRequested());
342 doc.fyi();
343 doc = getDocument("user2");
344 assertTrue(doc.isAcknowledgeRequested());
345 doc.acknowledge("");
346
347
348 doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), ADHOC_DOC);
349 docId = doc.getRouteHeaderId();
350 doc.routeDocument("");
351
352 doc = getDocument("user1");
353 doc.disapprove("");
354
355
356 try {
357 doc.adHocRouteDocumentToPrincipal("A", "One", "", getPrincipalIdForName("rkirkend"), "", true);
358 fail("should have thrown exception cant adhoc approvals on dissaproved documents");
359 } catch (Exception e) {
360
361 }
362
363
364 try {
365 doc.adHocRouteDocumentToPrincipal("C", "One", "", getPrincipalIdForName("rkirkend"), "", true);
366 fail("should have thrown exception cant ad hoc completes on dissaproved documents");
367 } catch (Exception e) {
368
369 }
370
371
372 try {
373 doc.adHocRouteDocumentToPrincipal("K", "", getPrincipalIdForName("user1"), "", true);
374 } catch (Exception e) {
375 e.printStackTrace();
376 fail("should have thrown exception cant ad hoc completes on dissaproved documents");
377 }
378
379
380 try {
381 doc.adHocRouteDocumentToPrincipal("F", "", getPrincipalIdForName("user1"), "", true);
382 } catch (Exception e) {
383 e.printStackTrace();
384 fail("should have thrown exception cant ad hoc completes on dissaproved documents");
385 }
386
387 }
388
389
390
391
392
393 @Test
394 public void testAdHocNoNodeName() throws Exception {
395 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("user1"), ADHOC_DOC);
396 docId = doc.getRouteHeaderId();
397
398
399
400
401 doc.adHocRouteDocumentToPrincipal("A", "", getPrincipalIdForName("jitrue"), "", false);
402 doc.adHocRouteDocumentToGroup("A", "", getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "NonSIT"), "", false);
403 doc.routeDocument("");
404
405
406
407 doc = getDocument("user1");
408 assertFalse(doc.isApprovalRequested());
409 doc = getDocument("jitrue");
410 assertTrue(doc.isApprovalRequested());
411
412
413 TestUtilities.assertAtNode(doc, "AdHoc");
414
415
416 doc = getDocument("jitrue");
417 TestUtilities.assertAtNode(doc, "AdHoc");
418 doc.disapprove("");
419
420 TestUtilities.assertAtNode(doc, "AdHoc");
421 assertTrue(doc.stateIsDisapproved());
422
423
424 doc.adHocRouteDocumentToPrincipal("F", "", getPrincipalIdForName("rkirkend"), "", true);
425 doc.adHocRouteDocumentToPrincipal("K", "", getPrincipalIdForName("user2"), "", true);
426
427 doc.adHocRouteDocumentToGroup("K", "", getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "NonSIT"), "", true);
428
429
430 doc = getDocument("rkirkend");
431 assertTrue(doc.isFYIRequested());
432 doc.fyi();
433
434
435
436 doc = getDocument("user3");
437 assertTrue(doc.isAcknowledgeRequested());
438
439
440
441 doc = getDocument("user2");
442 assertTrue(doc.isAcknowledgeRequested());
443 doc.acknowledge("");
444
445
446
447 doc = getDocument("user3");
448 assertFalse(doc.isAcknowledgeRequested());
449
450
451
452 doc = getDocument("user1");
453 assertTrue(doc.isAcknowledgeRequested());
454 doc.acknowledge("");
455
456
457 TestUtilities.assertNumberOfPendingRequests(doc.getRouteHeaderId(), 0);
458
459
460
461 try {
462 doc.adHocRouteDocumentToPrincipal("A", "", getPrincipalIdForName("rkirkend"), "", true);
463 fail("should have thrown exception cant adhoc approvals on dissaproved documents");
464 } catch (Exception e) {
465 }
466
467 try {
468 doc.adHocRouteDocumentToPrincipal("C", "", getPrincipalIdForName("rkirkend"), "", true);
469 fail("should have thrown exception cant ad hoc completes on dissaproved documents");
470 } catch (Exception e) {
471 }
472
473 }
474
475 @Test
476 public void testAdHocWithRequestLabel_ToPrincipal() throws Exception {
477 WorkflowDocument doc = new WorkflowDocument(getPrincipalIdForName("user1"), ADHOC_DOC);
478 String label = "MY PRINCIPAL LABEL";
479 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_APPROVE_REQ, null, "", getPrincipalIdForName("ewestfal"), "", true, label);
480
481 List<ActionRequestValue> actionRequests = KEWServiceLocator.getActionRequestService().findPendingRootRequestsByDocId(doc.getRouteHeaderId());
482 assertEquals("Shoudl have 1 request.", 1, actionRequests.size());
483 ActionRequestValue actionRequest = actionRequests.get(0);
484 assertEquals("Should be an approve request", KEWConstants.ACTION_REQUEST_APPROVE_REQ, actionRequest.getActionRequested());
485 assertEquals("Invalid request label", label, actionRequest.getRequestLabel());
486 assertEquals("Request should be initialized", KEWConstants.ACTION_REQUEST_INITIALIZED, actionRequest.getStatus());
487
488
489 doc.routeDocument("");
490
491 Collection<ActionItem> actionItems = KEWServiceLocator.getActionListService().getActionListForSingleDocument(doc.getRouteHeaderId());
492 assertEquals("Should have 1 action item.", 1, actionItems.size());
493 ActionItem actionItem = actionItems.iterator().next();
494 assertEquals("ActionItem should be constructed from request.", actionRequest.getActionRequestId(), actionItem.getActionRequestId());
495 assertEquals("ActionItem should have same label", label, actionItem.getRequestLabel());
496 }
497
498 @Test
499 public void testAdHocWithRequestLabel_ToGroup() throws Exception {
500 WorkflowDocument doc = new WorkflowDocument(getPrincipalIdForName("user1"), ADHOC_DOC);
501 String label = "MY GROUP LABEL";
502 Group workflowAdmin = KEWServiceLocator.getIdentityHelperService().getGroupByName("KR-WKFLW", "WorkflowAdmin");
503 doc.adHocRouteDocumentToGroup(KEWConstants.ACTION_REQUEST_APPROVE_REQ, null, "", workflowAdmin.getGroupId(), "", true, label);
504
505 List<ActionRequestValue> actionRequests = KEWServiceLocator.getActionRequestService().findPendingRootRequestsByDocId(doc.getRouteHeaderId());
506 assertEquals("Should have 1 request.", 1, actionRequests.size());
507 ActionRequestValue actionRequest = actionRequests.get(0);
508 assertEquals("Should be an approve request", KEWConstants.ACTION_REQUEST_APPROVE_REQ, actionRequest.getActionRequested());
509 assertEquals("Invalid request label", label, actionRequest.getRequestLabel());
510 assertEquals("Request should be initialized", KEWConstants.ACTION_REQUEST_INITIALIZED, actionRequest.getStatus());
511
512
513 doc.routeDocument("");
514
515 Collection<ActionItem> actionItems = KEWServiceLocator.getActionListService().getActionListForSingleDocument(doc.getRouteHeaderId());
516 assertTrue("Should have more than 1 action item.", actionItems.size() > 1);
517 for (ActionItem actionItem : actionItems) {
518 assertEquals("ActionItem should be constructed from request.", actionRequest.getActionRequestId(), actionItem.getActionRequestId());
519 assertEquals("ActionItem should have same label", label, actionItem.getRequestLabel());
520 }
521 }
522
523 @Test
524 public void testAdHocWithNoNodes() throws Exception {
525 WorkflowDocument doc = new WorkflowDocument(getPrincipalIdForName("user1"), ADHOC_NO_NODE_DOC);
526 String label = "MY PRINCIPAL LABEL";
527
528
529 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_FYI_REQ, null, "", getPrincipalIdForName("ewestfal"), "", true, label);
530
531 List<ActionRequestValue> actionRequests = KEWServiceLocator.getActionRequestService().findPendingRootRequestsByDocId(doc.getRouteHeaderId());
532 assertEquals("Should have 1 request.", 1, actionRequests.size());
533 ActionRequestValue actionRequest = actionRequests.get(0);
534 assertEquals("Should be a FYI request", KEWConstants.ACTION_REQUEST_FYI_REQ, actionRequest.getActionRequested());
535 assertEquals("Invalid request label", label, actionRequest.getRequestLabel());
536 assertEquals("Request should be initialized", KEWConstants.ACTION_REQUEST_INITIALIZED, actionRequest.getStatus());
537
538
539 doc.routeDocument("");
540
541 Collection<ActionItem> actionItems = KEWServiceLocator.getActionListService().getActionListForSingleDocument(doc.getRouteHeaderId());
542 assertEquals("Should have 0 action item.", 0, actionItems.size());
543
544
545
546 }
547
548
549 private WorkflowDocument getDocument(String netid) throws WorkflowException {
550 return new WorkflowDocument(new NetworkIdDTO(netid), docId);
551 }
552 private WorkflowDocument getDocument(String principalId, Long docId) throws WorkflowException {
553 return new WorkflowDocument(principalId, docId);
554 }
555
556 }