01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.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 edu.iu.uis.eden.actions;
18:
19: import java.util.Collection;
20: import java.util.List;
21:
22: import org.junit.Test;
23: import org.kuali.workflow.test.WorkflowTestCase;
24:
25: import edu.iu.uis.eden.KEWServiceLocator;
26: import edu.iu.uis.eden.actions.BlanketApproveTest.NotifySetup;
27: import edu.iu.uis.eden.clientapp.WorkflowDocument;
28: import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
29:
30: public class CancelActionTest extends WorkflowTestCase {
31:
32: protected void loadTestData() throws Exception {
33: loadXmlFile("ActionsConfig.xml");
34: }
35:
36: @Test
37: public void testCancel() throws Exception {
38: WorkflowDocument document = new WorkflowDocument(
39: new NetworkIdVO("ewestfal"),
40: NotifySetup.DOCUMENT_TYPE_NAME);
41: document.routeDocument("");
42:
43: document = new WorkflowDocument(new NetworkIdVO("jhopf"),
44: document.getRouteHeaderId());
45: document.approve("");
46:
47: document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
48: document.getRouteHeaderId());
49: document.approve("");//ewestfal had ignore previous rule
50:
51: document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
52: document.getRouteHeaderId());
53: document.approve("");
54:
55: //this be the role delegate of jitrue
56: document = new WorkflowDocument(new NetworkIdVO("natjohns"),
57: document.getRouteHeaderId());
58: document.approve("");
59:
60: document = new WorkflowDocument(new NetworkIdVO("bmcgough"),
61: document.getRouteHeaderId());
62: document.cancel("");
63:
64: assertTrue("Document should be disapproved", document
65: .stateIsCanceled());
66:
67: //verify that the document is truly dead - no more action requests or action items.
68:
69: List requests = KEWServiceLocator.getActionRequestService()
70: .findPendingByDoc(document.getRouteHeaderId());
71: assertEquals("Should not have any active requests", 0, requests
72: .size());
73:
74: Collection actionItems = KEWServiceLocator
75: .getActionListService().findByRouteHeaderId(
76: document.getRouteHeaderId());
77: assertEquals("Should not have any action items", 0, actionItems
78: .size());
79:
80: }
81:
82: @Test
83: public void testInitiatorOnlyCancel() throws Exception {
84: WorkflowDocument document = new WorkflowDocument(
85: new NetworkIdVO("ewestfal"),
86: NotifySetup.DOCUMENT_TYPE_NAME);
87:
88: document = new WorkflowDocument(new NetworkIdVO("user1"),
89: document.getRouteHeaderId());
90: try {
91: document.cancel("");
92: fail("Document should not be allowed to be cancelled due to initiator check.");
93: } catch (Exception e) {
94:
95: }
96: }
97: }
|