1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.engine;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertTrue;
21
22 import org.junit.Test;
23 import org.kuali.rice.kew.api.WorkflowDocument;
24 import org.kuali.rice.kew.api.WorkflowDocumentFactory;
25 import org.kuali.rice.kew.test.KEWTestCase;
26 import org.kuali.rice.kew.api.KewApiConstants;
27
28
29
30
31
32
33
34 public class PostProcessorSpawnedDocumentTest extends KEWTestCase {
35
36 private static final String DOCUMENT_TYPE_THAT_SPAWNS = "SpawnNewDocumentType";
37
38 protected void loadTestData() throws Exception {
39 loadXmlFile("PostProcessorSpawnedDocConfig.xml");
40 }
41
42 @Test public void testSpawnDocument() throws Exception {
43 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("jitrue"), DOCUMENT_TYPE_THAT_SPAWNS);
44 document.saveDocumentData();
45 assertNotNull(document.getDocumentId());
46 assertTrue("Document should be initiatied", document.isInitiated());
47 document.route("Route");
48
49
50 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("bmcgough"), document.getDocumentId());
51 assertTrue("Document should be enroute", document.isEnroute());
52 assertEquals("Document should be enroute.", KewApiConstants.ROUTE_HEADER_ENROUTE_CD, document.getStatus().getCode());
53 assertTrue(document.isApprovalRequested());
54 document.approve("Test approve by bmcgough");
55
56 String originalDocumentId = document.getDocumentId();
57 Long originalDocumentIdLong = Long.parseLong(originalDocumentId.trim());
58 Long spawnedDocumentIdLong = (originalDocumentIdLong + 1);
59 String spawnedDocumentId = spawnedDocumentIdLong.toString();
60
61
62 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("jhopf"), spawnedDocumentId);
63 assertEquals("Document should be final.", KewApiConstants.ROUTE_HEADER_FINAL_CD, document.getStatus().getCode());
64
65
66 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("ewestfal"), originalDocumentId);
67 assertEquals("Document should be final.", KewApiConstants.ROUTE_HEADER_FINAL_CD, document.getStatus().getCode());
68 }
69 }