01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.engine;
18:
19: import org.junit.Test;
20: import org.kuali.workflow.test.WorkflowTestCase;
21:
22: import edu.iu.uis.eden.EdenConstants;
23: import edu.iu.uis.eden.clientapp.WorkflowDocument;
24: import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
25:
26: /**
27: * Tests a new document being spawned from the post processing of an existing document
28: *
29: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
30: *
31: */
32: public class PostProcessorSpawnedDocumentTest extends WorkflowTestCase {
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
41: public void testSpawnDocument() throws Exception {
42: WorkflowDocument document = new WorkflowDocument(
43: new NetworkIdVO("jitrue"), DOCUMENT_TYPE_THAT_SPAWNS);
44: document.saveRoutingData();
45: assertNotNull(document.getRouteHeaderId());
46: assertTrue("Document should be initiatied", document
47: .stateIsInitiated());
48: document.routeDocument("Route");
49:
50: // should have generated a request to "bmcgough"
51: document = new WorkflowDocument(new NetworkIdVO("bmcgough"),
52: document.getRouteHeaderId());
53: assertTrue("Document should be enroute", document
54: .stateIsEnroute());
55: assertEquals("Document should be enroute.",
56: EdenConstants.ROUTE_HEADER_ENROUTE_CD, document
57: .getRouteHeader().getDocRouteStatus());
58: assertTrue(document.isApprovalRequested());
59: document.approve("Test approve by bmcgough");
60: Long originalRouteHeaderId = document.getRouteHeaderId();
61:
62: // get spawned document (should be next document id)
63: document = new WorkflowDocument(new NetworkIdVO("jhopf"), Long
64: .valueOf(originalRouteHeaderId.longValue() + 1));
65: assertEquals("Document should be final.",
66: EdenConstants.ROUTE_HEADER_FINAL_CD, document
67: .getRouteHeader().getDocRouteStatus());
68:
69: // get original document
70: document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
71: originalRouteHeaderId);
72: assertEquals("Document should be final.",
73: EdenConstants.ROUTE_HEADER_FINAL_CD, document
74: .getRouteHeader().getDocRouteStatus());
75: }
76: }
|