View Javadoc

1   /*
2    * Copyright 2005-2007 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.actions;
18  
19  import org.junit.Test;
20  import org.kuali.rice.kew.actions.BlanketApproveTest.NotifySetup;
21  import org.kuali.rice.kew.dto.NetworkIdDTO;
22  import org.kuali.rice.kew.service.WorkflowDocument;
23  import org.kuali.rice.kew.test.KEWTestCase;
24  
25  
26  /**
27   * Test SuperUserCancel through WorkflowDocument
28   */
29  public class SuperUserCancelTest extends KEWTestCase {
30  
31      protected void loadTestData() throws Exception {
32  	loadXmlFile("ActionsConfig.xml");
33      }
34  
35      @Test
36      public void testSuperUserCancel() throws Exception {
37  	WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
38  	document.routeDocument("");
39  
40  	document = new WorkflowDocument(new NetworkIdDTO("jhopf"), document.getRouteHeaderId());
41  	assertTrue("WorkflowDocument should indicate jhopf as SuperUser", document.isSuperUser());
42  	document.superUserCancel("");
43  	assertTrue("Document should be final after Super User Cancel", document.stateIsCanceled());
44      }
45  
46      @Test
47      public void testSuperUserInitiatorCancel() throws Exception {
48  	WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
49  	assertTrue("WorkflowDocument should indicate ewestfal as SuperUser", document.isSuperUser());
50  	document.superUserCancel("");
51  	assertTrue("Document should be final after Super User Cancel", document.stateIsCanceled());
52      }
53  
54      @Test
55      public void testSuperUserNonInitiatorCancel() throws Exception {
56  	WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("delyea"), NotifySetup.DOCUMENT_TYPE_NAME);
57  	document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), document.getRouteHeaderId());
58  	assertTrue("WorkflowDocument should indicate ewestfal as SuperUser", document.isSuperUser());
59  	document.superUserCancel("");
60  	assertTrue("Document should be final after Super User Cancel", document.stateIsCanceled());
61      }
62  
63      @Test
64      public void testSuperUserCancelInvalidUser() throws Exception {
65  	WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
66  	document.routeDocument("");
67  
68  	document = new WorkflowDocument(new NetworkIdDTO("quickstart"), document.getRouteHeaderId());
69  	try {
70  	    assertFalse("WorkflowDocument should not indicate quickstart as SuperUser", document.isSuperUser());
71  	    document.superUserCancel("");
72  	    fail("invalid user attempted to SuperUserApprove");
73  	} catch (Exception e) {
74  	}
75  
76      }
77  
78  }