Clover Coverage Report - kew-test 2.0.0-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
55   113   7   27.5
10   81   0.13   2
2     3.5  
1    
 
  SubProcessRoutingTest       Line # 35 55 0% 7 67 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.engine;
18   
19   
20    import org.junit.Test;
21    import org.kuali.rice.kew.actionrequest.ActionRequestValue;
22   
23    import org.kuali.rice.kew.dto.RouteNodeInstanceDTO;
24    import org.kuali.rice.kew.engine.node.RouteNodeInstance;
25    import org.kuali.rice.kew.service.KEWServiceLocator;
26    import org.kuali.rice.kew.service.WorkflowDocument;
27    import org.kuali.rice.kew.test.KEWTestCase;
28    import org.kuali.rice.kew.util.KEWConstants;
29   
30    import java.util.Iterator;
31    import java.util.List;
32   
33    import static org.junit.Assert.*;
34   
 
35    public class SubProcessRoutingTest extends KEWTestCase {
36   
37    private static final String DOCUMENT_TYPE_NAME = "SubProcessDocType";
38    private static final String SUB_PROCESS_NODE = "MySubProcess";
39    private static final String ACKNOWLEDGE_NODE = "Acknowledge";
40    private static final String APPROVE_NODE = "Approve";
41   
 
42  0 toggle protected void loadTestData() throws Exception {
43  0 loadXmlFile("EngineConfig.xml");
44    }
45   
 
46  0 toggle @Test public void testSubProcessRoute() throws Exception {
47  0 WorkflowDocument document = new WorkflowDocument(getPrincipalIdForName("ewestfal"), DOCUMENT_TYPE_NAME);
48  0 document.saveRoutingData();
49  0 assertTrue("Document should be initiated", document.stateIsInitiated());
50  0 assertEquals("Should be no action requests.", 0, document.getActionRequests().length);
51  0 assertEquals("Invalid route level.", new Integer(0), document.getRouteHeader().getDocRouteLevel());
52  0 document.routeDocument("");
53  0 assertTrue("Document shoule be ENROUTE.", document.stateIsEnroute());
54   
55  0 List actionRequests = KEWServiceLocator.getActionRequestService().findPendingByDoc(document.getRouteHeaderId());
56  0 assertEquals("Incorrect pending action requests.", 2, actionRequests.size());
57  0 boolean isAck = false;
58  0 boolean isApprove = false;
59  0 for (Iterator iterator = actionRequests.iterator(); iterator.hasNext();) {
60  0 ActionRequestValue request = (ActionRequestValue) iterator.next();
61  0 RouteNodeInstance nodeInstance = request.getNodeInstance();
62  0 assertNotNull("Node instance should be non null.", nodeInstance);
63  0 if (request.getPrincipalId().equals(getPrincipalIdForName("bmcgough"))) {
64  0 isAck = true;
65  0 assertEquals("Wrong request type.", KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, request.getActionRequested());
66  0 assertEquals("Wrong node.", ACKNOWLEDGE_NODE, nodeInstance.getRouteNode().getRouteNodeName());
67  0 assertNotNull("Should be in a sub process.", nodeInstance.getProcess());
68  0 assertEquals("Wrong sub process.", SUB_PROCESS_NODE, nodeInstance.getProcess().getRouteNode().getRouteNodeName());
69  0 assertFalse("Sub process should be non-initial.", nodeInstance.getProcess().isInitial());
70  0 assertFalse("Sub process should be non-active.", nodeInstance.getProcess().isActive());
71  0 assertFalse("Sub process should be non-complete.", nodeInstance.getProcess().isComplete());
72  0 } else if (request.getPrincipalId().equals(getPrincipalIdForName("temay"))) {
73  0 isApprove = true;
74  0 assertEquals("Wrong request type.", KEWConstants.ACTION_REQUEST_APPROVE_REQ, request.getActionRequested());
75  0 assertEquals("Wrong node.", APPROVE_NODE, request.getNodeInstance().getRouteNode().getRouteNodeName());
76  0 assertNotNull("Should be in a sub process.", request.getNodeInstance().getProcess());
77  0 assertEquals("Wrong sub process.", SUB_PROCESS_NODE, request.getNodeInstance().getProcess().getRouteNode().getRouteNodeName());
78  0 assertFalse("Sub process should be non-initial.", nodeInstance.getProcess().isInitial());
79  0 assertFalse("Sub process should be non-active.", nodeInstance.getProcess().isActive());
80  0 assertFalse("Sub process should be non-complete.", nodeInstance.getProcess().isComplete());
81    }
82    }
83  0 assertTrue(isAck);
84  0 assertTrue(isApprove);
85  0 document = new WorkflowDocument(getPrincipalIdForName("bmcgough"), document.getRouteHeaderId());
86  0 assertTrue("Should have acknowledge.", document.isAcknowledgeRequested());
87  0 document.acknowledge("");
88   
89  0 document = new WorkflowDocument(getPrincipalIdForName("temay"), document.getRouteHeaderId());
90  0 document.approve("");
91   
92    // find the subprocess and assert it is complete, not active, and not initial
93  0 boolean foundSubProcess = false;
94  0 RouteNodeInstanceDTO[] nodeInstances = document.getRouteNodeInstances();
95  0 for (int index = 0; index < nodeInstances.length; index++) {
96  0 RouteNodeInstanceDTO instanceVO = nodeInstances[index];
97  0 if (instanceVO.getName().equals(SUB_PROCESS_NODE)) {
98  0 foundSubProcess = true;
99  0 assertFalse("Sub process should be non-initial.", instanceVO.isInitial());
100  0 assertFalse("Sub process should be non-active.", instanceVO.isActive());
101  0 assertTrue("Sub process should be complete.", instanceVO.isComplete());
102    }
103    }
104  0 assertTrue("Could not locate sub process node.", foundSubProcess);
105   
106  0 document = new WorkflowDocument(getPrincipalIdForName("rkirkend"), document.getRouteHeaderId());
107  0 document.approve("");
108   
109  0 document = new WorkflowDocument(getPrincipalIdForName("ewestfal"), document.getRouteHeaderId());
110  0 assertTrue("Document should be final.", document.stateIsFinal());
111    }
112   
113    }