| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 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 |
|
|
|
|
|
| 0% |
Uncovered Elements: 67 (67) |
Complexity: 7 |
Complexity Density: 0.13 |
|
| 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 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 42 |
0
|
protected void loadTestData() throws Exception {... |
| 43 |
0
|
loadXmlFile("EngineConfig.xml"); |
| 44 |
|
} |
| 45 |
|
|
|
|
|
| 0% |
Uncovered Elements: 64 (64) |
Complexity: 6 |
Complexity Density: 0.11 |
4
-
|
|
| 46 |
0
|
@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 |
|
|
| 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 |
|
} |