1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
32 public class SuperUserCancelTest extends KEWTestCase {
33
34 protected void loadTestData() throws Exception {
35 loadXmlFile("ActionsConfig.xml");
36 }
37
38 @Test
39 public void testSuperUserCancel() throws Exception {
40 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
41 document.route("");
42
43 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("jhopf"), document.getDocumentId());
44 assertTrue("WorkflowDocument should indicate jhopf as SuperUser", document.isValidAction(ActionType.SU_CANCEL));
45 document.superUserCancel("");
46 assertTrue("Document should be final after Super User Cancel", document.isCanceled());
47 }
48
49 @Test
50 public void testSuperUserInitiatorCancel() 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_CANCEL));
53 document.superUserCancel("");
54 assertTrue("Document should be final after Super User Cancel", document.isCanceled());
55 }
56
57 @Test
58 public void testSuperUserNonInitiatorCancel() throws Exception {
59 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("delyea"), NotifySetup.DOCUMENT_TYPE_NAME);
60 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("ewestfal"), document.getDocumentId());
61 assertTrue("WorkflowDocument should indicate ewestfal as SuperUser", document.isValidAction(ActionType.SU_CANCEL));
62 document.superUserCancel("");
63 assertTrue("Document should be final after Super User Cancel", document.isCanceled());
64 }
65
66 @Test
67 public void testSuperUserCancelInvalidUser() throws Exception {
68 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
69 document.route("");
70
71 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("quickstart"), document.getDocumentId());
72 try {
73 assertFalse("WorkflowDocument should not indicate quickstart as SuperUser", document.isValidAction(ActionType.SU_CANCEL));
74 document.superUserCancel("");
75 fail("invalid user attempted to SuperUserApprove");
76 } catch (Exception e) {
77 }
78
79 }
80
81 }