01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.actions;
18:
19: import java.util.Collection;
20: import java.util.Iterator;
21:
22: import org.junit.Test;
23: import org.kuali.workflow.test.WorkflowTestCase;
24:
25: import edu.iu.uis.eden.KEWServiceLocator;
26: import edu.iu.uis.eden.actionitem.ActionItem;
27: import edu.iu.uis.eden.actionlist.ActionListService;
28: import edu.iu.uis.eden.clientapp.WorkflowDocument;
29: import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
30: import edu.iu.uis.eden.clientapp.vo.WorkflowGroupIdVO;
31: import edu.iu.uis.eden.workgroup.GroupNameId;
32: import edu.iu.uis.eden.workgroup.Workgroup;
33:
34: /**
35: * @author rkirkend
36: */
37: public class ReleaseWorkgroupAuthorityTest extends WorkflowTestCase {
38:
39: protected void loadTestData() throws Exception {
40: loadXmlFile("ActionsConfig.xml");
41: }
42:
43: @Test
44: public void testReleaseWorkgroupAuthority() throws Exception {
45: WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
46: "user1"), TakeWorkgroupAuthorityTest.DOC_TYPE);
47: doc.routeDocument("");
48:
49: Workgroup workgroup = KEWServiceLocator.getWorkgroupService()
50: .getWorkgroup(new GroupNameId("TestWorkgroup"));
51:
52: //have member rkirkend take authority
53: doc = new WorkflowDocument(new NetworkIdVO("rkirkend"), doc
54: .getRouteHeaderId());
55: doc.takeWorkgroupAuthority("", new WorkflowGroupIdVO(workgroup
56: .getWorkflowGroupId().getGroupId()));
57:
58: //have rkirkend release authority
59: doc = new WorkflowDocument(new NetworkIdVO("rkirkend"), doc
60: .getRouteHeaderId());
61: doc.releaseWorkgroupAuthority("", new WorkflowGroupIdVO(
62: workgroup.getWorkflowGroupId().getGroupId()));
63:
64: //verify that all members have the action item
65: ActionListService aiService = KEWServiceLocator
66: .getActionListService();
67: Collection actionItems = aiService.findByRouteHeaderId(doc
68: .getRouteHeaderId());
69: assertTrue("There should be more than one action item",
70: actionItems.size() > 1);
71: for (Iterator iter = actionItems.iterator(); iter.hasNext();) {
72: ActionItem actionItem = (ActionItem) iter.next();
73: assertTrue("Action Item not to workgroup member",
74: TakeWorkgroupAuthorityTest.WORKGROUP_MEMBERS
75: .contains(actionItem.getUser()
76: .getAuthenticationUserId()
77: .getAuthenticationId()));
78: }
79: }
80: }
|