View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.engine;
17  
18  import org.junit.Test;
19  import org.kuali.rice.kew.api.KewApiServiceLocator;
20  import org.kuali.rice.kew.api.WorkflowDocument;
21  import org.kuali.rice.kew.api.WorkflowDocumentFactory;
22  import org.kuali.rice.kew.api.doctype.ProcessDefinition;
23  import org.kuali.rice.kew.api.doctype.RoutePath;
24  import org.kuali.rice.kew.test.KEWTestCase;
25  
26  import static org.junit.Assert.assertNotNull;
27  import static org.junit.Assert.assertNull;
28  import static org.junit.Assert.assertTrue;
29  
30  /**
31   * Integration test cases for documents with empty processes
32   */
33  public class EmptyProcessTest extends KEWTestCase {
34  
35      private static final String DOCUMENT_TYPE_NAME = "EmptyProcessDocType";
36  
37      protected void loadTestData() throws Exception {
38          loadXmlFile("EngineConfig.xml");
39      }
40  
41      /**
42       * creates a new doc of the given type and routes it, asserting that it goes final
43       * @throws Exception
44       */
45      @Test public void testEmptyProcess() throws Exception {
46          WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), DOCUMENT_TYPE_NAME);
47          document.route("test");
48          assertNotNull(document.getDocumentId());
49          assertTrue(document.isFinal());
50      }
51  
52      /**
53       * Tests scenario for KULRICE-7235: Document Type use of Null routePaths causes IllegalArgumentException:
54       * contract was null
55       * @throws Exception
56       */
57      @Test public void testGetRoutePathForDocumentTypeName() throws Exception {
58          RoutePath routePath =
59                  KewApiServiceLocator.getDocumentTypeService().getRoutePathForDocumentTypeName(DOCUMENT_TYPE_NAME);
60          assertNotNull(routePath);
61          ProcessDefinition processDefinition = routePath.getPrimaryProcess();
62          assertNotNull(processDefinition);
63          assertNull("The initial route node *should* be null since this is an empty process", processDefinition.getInitialRouteNode());
64      }
65  
66  }