001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.kew.engine;
017
018 import org.junit.Test;
019 import org.kuali.rice.kew.api.KewApiServiceLocator;
020 import org.kuali.rice.kew.api.WorkflowDocument;
021 import org.kuali.rice.kew.api.WorkflowDocumentFactory;
022 import org.kuali.rice.kew.api.doctype.ProcessDefinition;
023 import org.kuali.rice.kew.api.doctype.RoutePath;
024 import org.kuali.rice.kew.test.KEWTestCase;
025
026 import static org.junit.Assert.assertNotNull;
027 import static org.junit.Assert.assertNull;
028 import static org.junit.Assert.assertTrue;
029
030 /**
031 * Integration test cases for documents with empty processes
032 */
033 public class EmptyProcessTest extends KEWTestCase {
034
035 private static final String DOCUMENT_TYPE_NAME = "EmptyProcessDocType";
036
037 protected void loadTestData() throws Exception {
038 loadXmlFile("EngineConfig.xml");
039 }
040
041 /**
042 * creates a new doc of the given type and routes it, asserting that it goes final
043 * @throws Exception
044 */
045 @Test public void testEmptyProcess() throws Exception {
046 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), DOCUMENT_TYPE_NAME);
047 document.route("test");
048 assertNotNull(document.getDocumentId());
049 assertTrue(document.isFinal());
050 }
051
052 /**
053 * Tests scenario for KULRICE-7235: Document Type use of Null routePaths causes IllegalArgumentException:
054 * contract was null
055 * @throws Exception
056 */
057 @Test public void testGetRoutePathForDocumentTypeName() throws Exception {
058 RoutePath routePath =
059 KewApiServiceLocator.getDocumentTypeService().getRoutePathForDocumentTypeName(DOCUMENT_TYPE_NAME);
060 assertNotNull(routePath);
061 ProcessDefinition processDefinition = routePath.getPrimaryProcess();
062 assertNotNull(processDefinition);
063 assertNull("The initial route node *should* be null since this is an empty process", processDefinition.getInitialRouteNode());
064 }
065
066 }