View Javadoc

1   /**
2    * Copyright 2005-2011 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.krad.workflow.service;
17  
18  
19  import static org.junit.Assert.assertFalse;
20  import static org.junit.Assert.assertTrue;
21  
22  import org.junit.Test;
23  import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
24  import org.kuali.rice.kew.api.KewApiServiceLocator;
25  import org.kuali.test.KRADTestCase;
26  
27  
28  /**
29   * This class tests the WorkflowUser service.
30   */
31  public class WorkflowInfoServiceTest extends KRADTestCase {
32  
33      @Test public void testRouteHeaderExists_NullId() throws IllegalArgumentException {
34          boolean errorThrown = false;
35          try {
36              KewApiServiceLocator.getWorkflowDocumentService().doesDocumentExist(null);
37          } catch (RiceIllegalArgumentException e) {
38              errorThrown = true;
39          }
40          assertTrue("An error should have been thrown.", errorThrown);
41      }
42  
43      @Test public void testRouteHeaderExists_NegativeId() {
44          boolean errorThrown = false;
45          boolean result = true;
46          try {
47              result = KewApiServiceLocator.getWorkflowDocumentService().doesDocumentExist("-10");
48          } catch (Exception e) {
49              errorThrown = true;
50          }
51          assertFalse("An error should not have been thrown.", errorThrown);
52          assertFalse("The routeHeader should never exist for a negative documentId.", result);
53      }
54      
55      @Test public void testRouteHeaderExists_KnownBadZeroId() {
56          boolean errorThrown = false;
57          boolean result = true;
58          try {
59              result = KewApiServiceLocator.getWorkflowDocumentService().doesDocumentExist("0");
60          }
61          catch (Exception e) {
62              errorThrown = true;
63          }
64          assertFalse("An error should not have been thrown.", errorThrown);
65          assertFalse("The routeHeader should never exist for a documentId of 0.", result);
66      }
67  
68      @Test public void testRouteHeaderExists_KnownGood() {
69          // no good way to test this without mocking the workflow service, and in a
70          // way that will be good over the long term, across data changes
71          assertTrue("This has been checked with a known-good id in the DB at this time.", true);
72      }
73  
74  }