001 /**
002 * Copyright 2005-2011 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.actions;
017
018 import static org.junit.Assert.assertFalse;
019 import static org.junit.Assert.assertTrue;
020
021 import org.junit.Test;
022 import org.kuali.rice.kew.api.WorkflowDocument;
023 import org.kuali.rice.kew.api.WorkflowDocumentFactory;
024 import org.kuali.rice.kew.test.KEWTestCase;
025
026 public class ApproveActionTest extends KEWTestCase {
027
028 protected void loadTestData() throws Exception {
029 loadXmlFile("ActionsConfig.xml");
030 }
031
032 @Test public void testPreapprovals() throws Exception {
033 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "PreApprovalTest");
034 doc.route("");
035
036 //rock some preapprovals and other actions...
037 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("ewestfal"), doc.getDocumentId());
038 doc.approve("");
039
040 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user2"), doc.getDocumentId());
041 doc.acknowledge("");
042
043 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user3"), doc.getDocumentId());
044 doc.complete("");
045
046 //approve as the person the doc is routed to so we can move the documen on and hopefully to final
047 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user1"), doc.getDocumentId());
048 doc.approve("");
049
050 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user1"), doc.getDocumentId());
051 assertTrue("the document should be final", doc.isFinal());
052 }
053
054 @Test public void testInitiatorRole() throws Exception {
055 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "InitiatorRoleApprovalTest");
056 doc.route("");
057 //rock some preapprovals and other actions...
058 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("ewestfal"), doc.getDocumentId());
059 doc.approve("");
060
061 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user2"), doc.getDocumentId());
062 doc.acknowledge("");
063
064 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user3"), doc.getDocumentId());
065 doc.complete("");
066
067 assertFalse("the document should NOT be final", doc.isFinal());
068
069 //approve as the person the doc is routed (initiator) to so we can move the document on and hopefully to final
070 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), doc.getDocumentId());
071 doc.approve("");
072
073 assertTrue("the document should be final", doc.isFinal());
074 }
075 }