1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.kuali.rice.kew.clientapp; |
18 |
|
|
19 |
|
|
20 |
|
import org.junit.Test; |
21 |
|
|
22 |
|
import org.kuali.rice.kew.dto.RouteNodeInstanceDTO; |
23 |
|
import org.kuali.rice.kew.dto.UserIdDTO; |
24 |
|
import org.kuali.rice.kew.dto.WorkflowIdDTO; |
25 |
|
import org.kuali.rice.kew.service.WorkflowDocument; |
26 |
|
import org.kuali.rice.kew.test.KEWTestCase; |
27 |
|
|
28 |
|
import static org.junit.Assert.*; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
|
|
| 0% |
Uncovered Elements: 75 (75) |
Complexity: 11 |
Complexity Density: 0.18 |
|
34 |
|
public class WorkflowDocumentTest extends KEWTestCase { |
35 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
36 |
0
|
protected void loadTestData() throws Exception {... |
37 |
0
|
loadXmlFile("ClientAppConfig.xml"); |
38 |
|
} |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4
-
|
|
40 |
0
|
@Test public void testLoadNonExistentDocument() throws Exception {... |
41 |
0
|
WorkflowDocument document = new WorkflowDocument(getPrincipalIdForName("ewestfal"), new Long(123456789)); |
42 |
0
|
assertNull("RouteHeaderVO should be null.", document.getRouteHeader()); |
43 |
|
} |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 5 |
Complexity Density: 0.24 |
4
-
|
|
45 |
0
|
@Test public void testWorkflowDocument() throws Exception {... |
46 |
0
|
WorkflowDocument document = new WorkflowDocument(getPrincipalIdForName("rkirkend"), "UnitTestDocument"); |
47 |
0
|
document.routeDocument(""); |
48 |
|
|
49 |
0
|
document = new WorkflowDocument(getPrincipalIdForName("ewestfal"), document.getRouteHeaderId()); |
50 |
0
|
document.approve(""); |
51 |
|
|
52 |
0
|
document = new WorkflowDocument(getPrincipalIdForName("jhopf"), document.getRouteHeaderId()); |
53 |
0
|
document.approve(""); |
54 |
|
|
55 |
0
|
RouteNodeInstanceDTO[] nodeInstances = document.getRouteNodeInstances(); |
56 |
0
|
boolean containsInitiated = false; |
57 |
0
|
boolean containsTemplate1 = false; |
58 |
0
|
boolean containsTemplate2 = false; |
59 |
0
|
for (int j = 0; j < nodeInstances.length; j++) { |
60 |
0
|
RouteNodeInstanceDTO routeNodeInstance = nodeInstances[j]; |
61 |
0
|
if (routeNodeInstance.getName().equals("Initiated")) { |
62 |
0
|
containsInitiated = true; |
63 |
0
|
} else if (routeNodeInstance.getName().equals("Template1")) { |
64 |
0
|
containsTemplate1 = true; |
65 |
0
|
} else if (routeNodeInstance.getName().equals("Template2")) { |
66 |
0
|
containsTemplate2 = true; |
67 |
|
} |
68 |
|
} |
69 |
|
|
70 |
0
|
assertTrue("Should have gone through initiated node", containsInitiated); |
71 |
0
|
assertTrue("Should have gone through template1 node", containsTemplate1); |
72 |
0
|
assertTrue("Should have gone through template2 node", containsTemplate2); |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
@throws |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
4
-
|
|
80 |
0
|
@Test public void testReturnToPreviousCorrectlyUpdatingDocumentStatus() throws Exception {... |
81 |
|
|
82 |
0
|
WorkflowDocument document = new WorkflowDocument(getPrincipalIdForName("rkirkend"), "UnitTestDocument"); |
83 |
0
|
document.routeDocument(""); |
84 |
|
|
85 |
0
|
document = new WorkflowDocument(getPrincipalIdForName("ewestfal"), document.getRouteHeaderId()); |
86 |
0
|
document.returnToPreviousNode("", "Initiated"); |
87 |
|
|
88 |
0
|
assertFalse("ewestfal should no longer have approval status", document.isApprovalRequested()); |
89 |
0
|
assertFalse("ewestfal should no long have blanket approve status", document.isBlanketApproveCapable()); |
90 |
|
|
91 |
|
|
92 |
0
|
document = new WorkflowDocument(getPrincipalIdForName("rkirkend"), document.getRouteHeaderId()); |
93 |
0
|
assertTrue("rkirkend should now have an approve request", document.isApprovalRequested()); |
94 |
|
} |
95 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
4
-
|
|
96 |
0
|
@Test public void testGetPreviousRouteNodeNames() throws Exception {... |
97 |
|
|
98 |
0
|
WorkflowDocument document = new WorkflowDocument(getPrincipalIdForName("rkirkend"), "UnitTestDocument"); |
99 |
0
|
document.routeDocument(""); |
100 |
|
|
101 |
0
|
document = new WorkflowDocument(getPrincipalIdForName("ewestfal"), document.getRouteHeaderId()); |
102 |
0
|
document.approve(""); |
103 |
|
|
104 |
0
|
document = new WorkflowDocument(getPrincipalIdForName("jhopf"), document.getRouteHeaderId()); |
105 |
0
|
String[] previousNodeNames = document.getPreviousNodeNames(); |
106 |
0
|
assertEquals("Should have 2 previous Node Names", 2, previousNodeNames.length); |
107 |
0
|
assertEquals("Last node name should be the first visisted", "Initiated", previousNodeNames[0]); |
108 |
0
|
assertEquals("First node name should be last node visited", "Template1", previousNodeNames[1]); |
109 |
0
|
String[] currentNodes = document.getNodeNames(); |
110 |
0
|
assertEquals("Should have 1 current node name", 1, currentNodes.length); |
111 |
0
|
assertEquals("Current node name incorrect", "Template2", currentNodes[0]); |
112 |
0
|
document.returnToPreviousNode("", "Template1"); |
113 |
0
|
previousNodeNames = document.getPreviousNodeNames(); |
114 |
0
|
assertEquals("Should have 1 previous Node Name", 1, previousNodeNames.length); |
115 |
0
|
assertEquals("Previous Node name incorrect", "Initiated", previousNodeNames[0]); |
116 |
|
|
117 |
|
} |
118 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
4
-
|
|
119 |
0
|
@Test public void testIsRouteCapable() throws Exception {... |
120 |
|
|
121 |
0
|
WorkflowDocument doc = new WorkflowDocument(getPrincipalIdForName("rkirkend"), "UnitTestDocument"); |
122 |
|
|
123 |
0
|
verifyIsRouteCapable(false, getPrincipalIdForName("ewestfal"), doc.getRouteHeaderId()); |
124 |
0
|
verifyIsRouteCapable(false, "2001", doc.getRouteHeaderId()); |
125 |
|
|
126 |
0
|
verifyIsRouteCapable(true, getPrincipalIdForName("rkirkend"), doc.getRouteHeaderId()); |
127 |
0
|
verifyIsRouteCapable(true, "2002", doc.getRouteHeaderId()); |
128 |
|
|
129 |
0
|
doc = new WorkflowDocument(getPrincipalIdForName("rkirkend"), "NonInitiatorCanRouteDocument"); |
130 |
|
|
131 |
0
|
verifyIsRouteCapable(true, getPrincipalIdForName("ewestfal"), doc.getRouteHeaderId()); |
132 |
0
|
verifyIsRouteCapable(true, "2001", doc.getRouteHeaderId()); |
133 |
|
|
134 |
0
|
verifyIsRouteCapable(true, getPrincipalIdForName("rkirkend"), doc.getRouteHeaderId()); |
135 |
0
|
verifyIsRouteCapable(true, "2002", doc.getRouteHeaderId()); |
136 |
|
} |
137 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
138 |
0
|
private void verifyIsRouteCapable(boolean routeCapable, String userId, Long docId) throws Exception {... |
139 |
0
|
WorkflowDocument doc = new WorkflowDocument(userId, docId); |
140 |
0
|
assertEquals(routeCapable, doc.isRouteCapable()); |
141 |
|
} |
142 |
|
|
143 |
|
} |