| 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 |
|
import org.junit.Test; |
| 20 |
|
|
| 21 |
|
import org.kuali.rice.kew.exception.WorkflowException; |
| 22 |
|
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 23 |
|
import org.kuali.rice.kew.service.WorkflowDocument; |
| 24 |
|
import org.kuali.rice.kew.test.KEWTestCase; |
| 25 |
|
import org.kuali.rice.kew.util.KEWConstants; |
| 26 |
|
|
| 27 |
|
import java.util.Collection; |
| 28 |
|
|
| 29 |
|
import static org.junit.Assert.*; |
| 30 |
|
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 7 |
Complexity Density: 0.21 |
|
| 31 |
|
public class RouteDocumentTest extends KEWTestCase { |
| 32 |
|
|
| 33 |
|
public static final String DOCUMENT_TYPE_NAME = "BlanketApproveSequentialTest"; |
| 34 |
|
public static final String DOCUMENT_TYPE_POLICY_TEST_NAME = "BlanketApprovePolicyTest"; |
| 35 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 36 |
0
|
protected void loadTestData() throws Exception {... |
| 37 |
0
|
loadXmlFile("ActionsConfig.xml"); |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.17 |
4
-
|
|
| 43 |
0
|
@Test public void testRouteAlreadyRoutedDocument() throws Exception {... |
| 44 |
0
|
WorkflowDocument document = new WorkflowDocument(getPrincipalIdForName("user1"), DOCUMENT_TYPE_NAME); |
| 45 |
0
|
document.routeDocument(""); |
| 46 |
|
|
| 47 |
0
|
assertTrue("Document should be ENROUTE.", document.stateIsEnroute()); |
| 48 |
0
|
assertFalse("There should not be a request to ewestfal.", document.isApprovalRequested()); |
| 49 |
|
|
| 50 |
|
|
| 51 |
0
|
Collection actionTakens = KEWServiceLocator.getActionTakenService().findByRouteHeaderId(document.getRouteHeaderId()); |
| 52 |
0
|
assertEquals("There should be only 1 action taken.", 1, actionTakens.size()); |
| 53 |
|
|
| 54 |
|
|
| 55 |
0
|
try { |
| 56 |
0
|
document.routeDocument(""); |
| 57 |
0
|
fail("A WorkflowException should have been thrown."); |
| 58 |
|
} catch (WorkflowException e) { |
| 59 |
0
|
e.printStackTrace(); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
|
| 63 |
0
|
actionTakens = KEWServiceLocator.getActionTakenService().findByRouteHeaderId(document.getRouteHeaderId()); |
| 64 |
0
|
assertEquals("There should still be only 1 action taken.", 1, actionTakens.size()); |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.2 |
4
-
|
|
| 70 |
0
|
@Test public void testRouteDocumentAsNonInitiatorUser() throws Exception {... |
| 71 |
0
|
WorkflowDocument firstDocument = new WorkflowDocument(getPrincipalIdForName("user1"), DOCUMENT_TYPE_POLICY_TEST_NAME); |
| 72 |
0
|
WorkflowDocument document = new WorkflowDocument(getPrincipalIdForName("user2"), firstDocument.getRouteHeaderId()); |
| 73 |
0
|
try { |
| 74 |
0
|
document.routeDocument(""); |
| 75 |
|
} catch (Exception e) { |
| 76 |
0
|
e.printStackTrace(); |
| 77 |
0
|
fail("Exception thrown but should not have have been... Exception was of type " + e.getClass().getName() + " and message was " + e.getMessage()); |
| 78 |
|
} |
| 79 |
0
|
document = new WorkflowDocument(getPrincipalIdForName("user1"), firstDocument.getRouteHeaderId()); |
| 80 |
0
|
assertEquals("Document should be in Enroute status.", KEWConstants.ROUTE_HEADER_ENROUTE_CD, document.getRouteHeader().getDocRouteStatus()); |
| 81 |
|
|
| 82 |
|
|
| 83 |
0
|
Collection actionTakens = KEWServiceLocator.getActionTakenService().findByRouteHeaderId(document.getRouteHeaderId()); |
| 84 |
0
|
assertEquals("There should be 1 action taken.", 1, actionTakens.size()); |
| 85 |
|
} |
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.2 |
4
-
|
|
| 90 |
0
|
@Test public void testRouteDefaultDocumentAsNonInitiatorUser() throws Exception {... |
| 91 |
0
|
WorkflowDocument firstDocument = new WorkflowDocument(getPrincipalIdForName("user1"), DOCUMENT_TYPE_NAME); |
| 92 |
0
|
WorkflowDocument document = new WorkflowDocument(getPrincipalIdForName("user2"), firstDocument.getRouteHeaderId()); |
| 93 |
0
|
try { |
| 94 |
0
|
document.routeDocument(""); |
| 95 |
0
|
fail("Exception should have been thrown."); |
| 96 |
|
} catch (Exception e) { |
| 97 |
0
|
e.printStackTrace(); |
| 98 |
|
} |
| 99 |
0
|
assertFalse("Document should not be ENROUTE.", document.stateIsEnroute()); |
| 100 |
0
|
assertFalse("There should not be a request to user2.", document.isApprovalRequested()); |
| 101 |
|
|
| 102 |
|
|
| 103 |
0
|
Collection actionTakens = KEWServiceLocator.getActionTakenService().findByRouteHeaderId(document.getRouteHeaderId()); |
| 104 |
0
|
assertEquals("There should be 0 actions taken.", 0, actionTakens.size()); |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
} |