View Javadoc
1   /**
2    * Copyright 2005-2014 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  
21  import org.junit.Test;
22  import org.kuali.rice.kew.api.WorkflowDocument;
23  import org.kuali.rice.kew.api.WorkflowDocumentFactory;
24  import org.kuali.rice.kew.test.KEWTestCase;
25  
26  public class ApproveActionTest extends KEWTestCase {
27  
28      protected void loadTestData() throws Exception {
29          loadXmlFile("ActionsConfig.xml");
30      }
31      
32      @Test public void testPreapprovals() throws Exception {
33      	WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "PreApprovalTest");
34      	doc.route("");
35      	
36      	//rock some preapprovals and other actions... 
37      	doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("ewestfal"), doc.getDocumentId());
38      	doc.approve("");
39      	
40      	doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user2"), doc.getDocumentId());
41      	doc.acknowledge("");
42      	
43      	doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user3"), doc.getDocumentId());
44      	doc.complete("");
45      	
46      	//approve as the person the doc is routed to so we can move the documen on and hopefully to final
47      	doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user1"), doc.getDocumentId());
48      	doc.approve("");
49      	
50      	doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user1"), doc.getDocumentId());
51      	assertTrue("the document should be final", doc.isFinal());
52      }
53  
54      @Test public void testInitiatorRole() throws Exception {
55          WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "InitiatorRoleApprovalTest");
56          doc.route("");
57          //rock some preapprovals and other actions... 
58          doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("ewestfal"), doc.getDocumentId());
59          doc.approve("");
60          
61          doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user2"), doc.getDocumentId());
62          doc.acknowledge("");
63          
64          doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user3"), doc.getDocumentId());
65          doc.complete("");
66  
67          assertFalse("the document should NOT be final", doc.isFinal());
68  
69          //approve as the person the doc is routed (initiator) to so we can move the document on and hopefully to final
70          doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), doc.getDocumentId());
71          doc.approve("");
72          
73          assertTrue("the document should be final", doc.isFinal());
74      }
75  }