View Javadoc

1   /*
2    * Copyright 2005-2008 The Kuali Foundation
3    * 
4    * 
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    * http://www.opensource.org/licenses/ecl2.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 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   * Tests a new document being spawned from the post processing of an existing document
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
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          // should have generated a request to "bmcgough"
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      	// get spawned document (should be next document id)
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      	// get original document
60          document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), originalRouteHeaderId);
61          assertEquals("Document should be final.", KEWConstants.ROUTE_HEADER_FINAL_CD, document.getRouteHeader().getDocRouteStatus());
62      }
63  }