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.kew.actions;
17  
18  import static org.junit.Assert.assertFalse;
19  import static org.junit.Assert.assertTrue;
20  import static org.junit.Assert.fail;
21  
22  import org.junit.Test;
23  import org.kuali.rice.kew.actions.BlanketApproveTest.NotifySetup;
24  import org.kuali.rice.kew.api.WorkflowDocument;
25  import org.kuali.rice.kew.api.WorkflowDocumentFactory;
26  import org.kuali.rice.kew.api.action.ActionType;
27  import org.kuali.rice.kew.test.KEWTestCase;
28  
29  /**
30   * 
31   * Test SuperUserDissaprove actions from WorkflowDocument
32   *
33   */
34  public class SuperUserDisapproveTest extends KEWTestCase {
35  
36      protected void loadTestData() throws Exception {
37          loadXmlFile("ActionsConfig.xml");
38      }
39  	
40      @Test public void testSuperUserDisapprove() throws Exception {
41          WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
42          document.route("");
43          
44          document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("jhopf"), document.getDocumentId());
45          assertTrue("WorkflowDocument should indicate jhopf as SuperUser", document.isValidAction(ActionType.SU_DISAPPROVE));
46          document.superUserDisapprove("");
47          assertTrue("Document should be final after Super User Disapprove", document.isDisapproved());
48  	}
49  	
50      @Test public void testSuperUserInitiatorDisapprove() throws Exception {
51  		WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
52          assertTrue("WorkflowDocument should indicate ewestfal as SuperUser", document.isValidAction(ActionType.SU_DISAPPROVE));
53          document.superUserDisapprove("");
54          assertTrue("Document should be final after Super User Disapprove", document.isDisapproved());
55  	}
56  	
57      @Test public void testSuperUserDisapproveInvalidUser() throws Exception {
58  		WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
59          document.route("");
60          
61          document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("quickstart"), document.getDocumentId());
62          try {
63          	assertFalse("WorkflowDocument should not indicate quickstart as SuperUser", document.isValidAction(ActionType.SU_DISAPPROVE));
64          	document.superUserDisapprove("");
65          	fail("invalid user attempted to SuperUserApprove");
66          } catch (Exception e) {
67          }
68          
69  	}
70  	
71  }