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 import org.junit.Test;
20 import org.kuali.rice.kew.dto.NetworkIdDTO;
21 import org.kuali.rice.kew.service.WorkflowDocument;
22 import org.kuali.rice.kew.test.KEWTestCase;
23 import org.kuali.rice.kew.util.KEWConstants;
24
25
26
27
28
29
30
31
32 public class PostProcessorSpawnedDocumentTest extends KEWTestCase {
33
34 private static final String DOCUMENT_TYPE_THAT_SPAWNS = "SpawnNewDocumentType";
35
36 protected void loadTestData() throws Exception {
37 loadXmlFile("PostProcessorSpawnedDocConfig.xml");
38 }
39
40 @Test public void testSpawnDocument() throws Exception {
41 WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("jitrue"), DOCUMENT_TYPE_THAT_SPAWNS);
42 document.saveRoutingData();
43 assertNotNull(document.getRouteHeaderId());
44 assertTrue("Document should be initiatied", document.stateIsInitiated());
45 document.routeDocument("Route");
46
47
48 document = new WorkflowDocument(new NetworkIdDTO("bmcgough"), document.getRouteHeaderId());
49 assertTrue("Document should be enroute", document.stateIsEnroute());
50 assertEquals("Document should be enroute.", KEWConstants.ROUTE_HEADER_ENROUTE_CD, document.getRouteHeader().getDocRouteStatus());
51 assertTrue(document.isApprovalRequested());
52 document.approve("Test approve by bmcgough");
53 Long originalRouteHeaderId = document.getRouteHeaderId();
54
55
56 document = new WorkflowDocument(new NetworkIdDTO("jhopf"), Long.valueOf(originalRouteHeaderId.longValue() + 1));
57 assertEquals("Document should be final.", KEWConstants.ROUTE_HEADER_FINAL_CD, document.getRouteHeader().getDocRouteStatus());
58
59
60 document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), originalRouteHeaderId);
61 assertEquals("Document should be final.", KEWConstants.ROUTE_HEADER_FINAL_CD, document.getRouteHeader().getDocRouteStatus());
62 }
63 }