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 java.util.ArrayList;
19 import java.util.List;
20
21 import org.junit.Test;
22 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
23 import org.kuali.rice.kew.rule.TestRuleAttribute;
24 import org.kuali.rice.kew.service.KEWServiceLocator;
25 import org.kuali.rice.kew.service.WorkflowDocument;
26 import org.kuali.rice.kew.test.KEWTestCase;
27 import org.kuali.rice.kew.user.AuthenticationUserId;
28
29
30
31
32
33
34
35
36 public class ActionInvocationProcessorTest extends KEWTestCase {
37
38
39 @Test public void testActionInvocationProcessorWorksWithNoActionItem() throws Exception {
40
41 TestRuleAttribute.setRecipientPrincipalIds("TestRole", "QualRole", getRecipients());
42
43 String rkirkendPrincipalId = getPrincipalIdForName("rkirkend");
44 WorkflowDocument doc = new WorkflowDocument(rkirkendPrincipalId, "TestDocumentType");
45 doc.routeDocument("");
46
47 List<ActionRequestValue> requests = KEWServiceLocator.getActionRequestService().findAllActionRequestsByRouteHeaderId(doc.getRouteHeaderId());
48 assertFalse(requests.isEmpty());
49
50 ActionRequestValue request = null;
51 for (ActionRequestValue tempRequest : requests) {
52 if (tempRequest.getPrincipal() != null && tempRequest.getPrincipal().getPrincipalName().equals("user1"))
53 {
54 request = tempRequest;
55 break;
56 }
57 }
58
59 assertNotNull(request);
60
61 String user1PrincipalId = getPrincipalIdForName("user1");
62 new ActionInvocationProcessor().invokeAction(user1PrincipalId, request.getRouteHeaderId(), new ActionInvocation(request.getRouteHeaderId(), request.getActionRequested()));
63
64 new ActionInvocationProcessor().invokeAction(user1PrincipalId, request.getRouteHeaderId(), new ActionInvocation(request.getRouteHeaderId(), request.getActionRequested()));
65
66
67 requests = KEWServiceLocator.getActionRequestService().findAllActionRequestsByRouteHeaderId(doc.getRouteHeaderId());
68 assertFalse(requests.isEmpty());
69
70 request = null;
71 for (ActionRequestValue tempRequest : requests) {
72 if (tempRequest.getPrincipalId() != null && tempRequest.getPrincipalId().equals(getPrincipalIdForName("user1")) && tempRequest.isActive()) {
73 request = tempRequest;
74 break;
75 }
76 }
77
78 assertNull(request);
79
80 }
81
82 public List<String> getRecipients() {
83 List<String> recipients = new ArrayList<String>();
84 recipients.add(getPrincipalIdForName("user1"));
85 recipients.add(getPrincipalIdForName("user2"));
86 return recipients;
87 }
88
89 }