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
20 import java.util.Collection;
21 import java.util.Iterator;
22
23 import org.junit.Test;
24 import org.kuali.rice.kew.actionitem.ActionItem;
25 import org.kuali.rice.kew.actionlist.service.ActionListService;
26 import org.kuali.rice.kew.dto.NetworkIdDTO;
27 import org.kuali.rice.kew.service.KEWServiceLocator;
28 import org.kuali.rice.kew.service.WorkflowDocument;
29 import org.kuali.rice.kew.test.KEWTestCase;
30 import org.kuali.rice.kim.util.KimConstants;
31
32
33
34
35 public class ReleaseWorkgroupAuthorityTest extends KEWTestCase {
36
37 protected void loadTestData() throws Exception {
38 loadXmlFile("ActionsConfig.xml");
39 }
40
41 @Test public void testReleaseWorkgroupAuthority() throws Exception {
42 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("user1"), TakeWorkgroupAuthorityTest.DOC_TYPE);
43 doc.routeDocument("");
44
45 String groupId = getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "TestWorkgroup");
46
47 doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), doc.getRouteHeaderId());
48 doc.takeGroupAuthority("", groupId);
49
50
51 ActionListService aiService = KEWServiceLocator.getActionListService();
52 Collection actionItems = aiService.findByRouteHeaderId(doc.getRouteHeaderId());
53 assertEquals("There should be only one action item", 1, actionItems.size());
54 ActionItem ai = (ActionItem)actionItems.iterator().next();
55 assertEquals("action item should be to rkirkend", getPrincipalIdForName("rkirkend"), ai.getPrincipalId());
56 assertEquals("action item should be to group", groupId, ai.getGroupId());
57
58
59 doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), doc.getRouteHeaderId());
60
61 doc.releaseGroupAuthority("", groupId);
62
63
64 actionItems = aiService.findByRouteHeaderId(doc.getRouteHeaderId());
65 assertTrue("There should be more than one action item", actionItems.size() > 1);
66 for (Iterator iter = actionItems.iterator(); iter.hasNext();) {
67 ActionItem actionItem = (ActionItem) iter.next();
68 assertTrue("Action Item not to workgroup member", TakeWorkgroupAuthorityTest.WORKGROUP_MEMBERS.contains(actionItem.getPerson().getPrincipalName()));
69 }
70 }
71 }