Clover Coverage Report - kew-test 2.0.0-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
19   74   3   9.5
2   38   0.16   2
2     1.5  
1    
 
  ReleaseWorkgroupAuthorityTest       Line # 38 19 0% 3 23 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2005-2007 The Kuali Foundation
3    *
4    *
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    * http://www.opensource.org/licenses/ecl2.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 org.kuali.rice.kew.actions;
18   
19   
20    import org.junit.Test;
21    import org.kuali.rice.kew.actionitem.ActionItem;
22    import org.kuali.rice.kew.actionlist.service.ActionListService;
23   
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.kim.util.KimConstants;
28   
29    import java.util.Collection;
30    import java.util.Iterator;
31   
32    import static org.junit.Assert.assertEquals;
33    import static org.junit.Assert.assertTrue;
34   
35    /**
36    * @author Kuali Rice Team (rice.collab@kuali.org)
37    */
 
38    public class ReleaseWorkgroupAuthorityTest extends KEWTestCase {
39   
 
40  0 toggle protected void loadTestData() throws Exception {
41  0 loadXmlFile("ActionsConfig.xml");
42    }
43   
 
44  0 toggle @Test public void testReleaseWorkgroupAuthority() throws Exception {
45  0 WorkflowDocument doc = new WorkflowDocument(getPrincipalIdForName("user1"), TakeWorkgroupAuthorityTest.DOC_TYPE);
46  0 doc.routeDocument("");
47   
48  0 String groupId = getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "TestWorkgroup");
49    //have member rkirkend take authority
50  0 doc = new WorkflowDocument(getPrincipalIdForName("rkirkend"), doc.getRouteHeaderId());
51  0 doc.takeGroupAuthority("", groupId);
52   
53    // verify there is only one action item and that it's to rkirkend
54  0 ActionListService aiService = KEWServiceLocator.getActionListService();
55  0 Collection actionItems = aiService.findByRouteHeaderId(doc.getRouteHeaderId());
56  0 assertEquals("There should be only one action item", 1, actionItems.size());
57  0 ActionItem ai = (ActionItem)actionItems.iterator().next();
58  0 assertEquals("action item should be to rkirkend", getPrincipalIdForName("rkirkend"), ai.getPrincipalId());
59  0 assertEquals("action item should be to group", groupId, ai.getGroupId());
60   
61    //have rkirkend release authority
62  0 doc = new WorkflowDocument(getPrincipalIdForName("rkirkend"), doc.getRouteHeaderId());
63   
64  0 doc.releaseGroupAuthority("", groupId);
65   
66    //verify that all members have the action item
67  0 actionItems = aiService.findByRouteHeaderId(doc.getRouteHeaderId());
68  0 assertTrue("There should be more than one action item", actionItems.size() > 1);
69  0 for (Iterator iter = actionItems.iterator(); iter.hasNext();) {
70  0 ActionItem actionItem = (ActionItem) iter.next();
71  0 assertTrue("Action Item not to workgroup member", TakeWorkgroupAuthorityTest.WORKGROUP_MEMBERS.contains(actionItem.getPerson().getPrincipalName()));
72    }
73    }
74    }