1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.actions.asyncservices;
17
18 import static org.junit.Assert.assertFalse;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertNull;
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25 import org.junit.Test;
26 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
27 import org.kuali.rice.kew.api.WorkflowDocument;
28 import org.kuali.rice.kew.api.WorkflowDocumentFactory;
29 import org.kuali.rice.kew.rule.TestRuleAttribute;
30 import org.kuali.rice.kew.service.KEWServiceLocator;
31 import org.kuali.rice.kew.test.KEWTestCase;
32
33
34
35
36
37
38 public class ActionInvocationProcessorTest extends KEWTestCase {
39
40
41 @Test public void testActionInvocationProcessorWorksWithNoActionItem() throws Exception {
42
43 TestRuleAttribute.setRecipientPrincipalIds("TestRole", "QualRole", getRecipients());
44
45 String rkirkendPrincipalId = getPrincipalIdForName("rkirkend");
46 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(rkirkendPrincipalId, "TestDocumentType");
47 doc.route("");
48
49 List<ActionRequestValue> requests = KEWServiceLocator.getActionRequestService().findAllActionRequestsByDocumentId(doc.getDocumentId());
50 assertFalse(requests.isEmpty());
51
52 ActionRequestValue request = null;
53 for (ActionRequestValue tempRequest : requests) {
54 if (tempRequest.getPrincipal() != null && tempRequest.getPrincipal().getPrincipalName().equals("user1"))
55 {
56 request = tempRequest;
57 break;
58 }
59 }
60
61 assertNotNull(request);
62
63 String user1PrincipalId = getPrincipalIdForName("user1");
64 String actionItemID = request.getDocumentId().trim();
65
66 new ActionInvocationProcessor().invokeAction(user1PrincipalId, request.getDocumentId(), new ActionInvocation(actionItemID, request.getActionRequested()));
67
68 new ActionInvocationProcessor().invokeAction(user1PrincipalId, request.getDocumentId(), new ActionInvocation(actionItemID, request.getActionRequested()));
69
70
71 requests = KEWServiceLocator.getActionRequestService().findAllActionRequestsByDocumentId(doc.getDocumentId());
72 assertFalse(requests.isEmpty());
73
74 request = null;
75 for (ActionRequestValue tempRequest : requests) {
76 if (tempRequest.getPrincipalId() != null && tempRequest.getPrincipalId().equals(getPrincipalIdForName("user1")) && tempRequest.isActive()) {
77 request = tempRequest;
78 break;
79 }
80 }
81
82 assertNull(request);
83
84 }
85
86 public List<String> getRecipients() {
87 List<String> recipients = new ArrayList<String>();
88 recipients.add(getPrincipalIdForName("user1"));
89 recipients.add(getPrincipalIdForName("user2"));
90 return recipients;
91 }
92
93 }