1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.routing;
17
18 import org.junit.Test;
19 import org.kuali.rice.kew.api.WorkflowDocument;
20 import org.kuali.rice.kew.api.WorkflowDocumentFactory;
21 import org.kuali.rice.kew.api.action.ActionRequest;
22 import org.kuali.rice.kew.test.KEWTestCase;
23 import org.kuali.rice.kew.test.TestUtilities;
24 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
25
26 import java.util.List;
27
28 import static org.junit.Assert.assertTrue;
29
30 public class RoutingWithEmptyWorkGroupTest extends KEWTestCase {
31
32 protected void loadTestData() throws Exception {
33 loadXmlFile("RoutingWithEmptyGroupConfig.xml");
34 }
35
36 @Test public void testRoutingToEmptyWorkgroup() throws Exception {
37
38 String user1PrincipalId = getPrincipalIdForName("user1");
39 String user2PrincipalId = getPrincipalIdForName("user2");
40
41 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(user1PrincipalId, "EmptyWorkgroupDocType");
42
43 doc = WorkflowDocumentFactory.loadDocument("user1", doc.getDocumentId());
44
45 doc.route("");
46
47
48
49
50
51 doc = WorkflowDocumentFactory.loadDocument(user2PrincipalId, doc.getDocumentId());
52
53 assertTrue("Document should be enroute", doc.isEnroute());
54 TestUtilities.assertAtNode(doc, "Node3");
55
56 TestUtilities.assertInActionList(user2PrincipalId, doc.getDocumentId());
57
58
59 List<ActionRequest> actionRequests = doc.getRootActionRequests();
60 for (ActionRequest actionRequest : actionRequests) {
61 if ("Node2".equals(actionRequest.getNodeName())) {
62 assertTrue("action request should be for a group", actionRequest.isGroupRequest());
63 assertTrue("action request should be marked as \"done\"", actionRequest.isDone());
64 assertTrue("Group should have no members.", KimApiServiceLocator.getGroupService().getMemberPrincipalIds(
65 actionRequest.getGroupId()).isEmpty());
66 }
67 }
68 }
69 }