1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.actions;
18
19 import org.junit.Test;
20 import org.kuali.rice.kew.actions.BlanketApproveTest.NotifySetup;
21 import org.kuali.rice.kew.dto.NetworkIdDTO;
22 import org.kuali.rice.kew.service.WorkflowDocument;
23 import org.kuali.rice.kew.test.KEWTestCase;
24
25
26
27
28
29 public class SuperUserCancelTest extends KEWTestCase {
30
31 protected void loadTestData() throws Exception {
32 loadXmlFile("ActionsConfig.xml");
33 }
34
35 @Test
36 public void testSuperUserCancel() throws Exception {
37 WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
38 document.routeDocument("");
39
40 document = new WorkflowDocument(new NetworkIdDTO("jhopf"), document.getRouteHeaderId());
41 assertTrue("WorkflowDocument should indicate jhopf as SuperUser", document.isSuperUser());
42 document.superUserCancel("");
43 assertTrue("Document should be final after Super User Cancel", document.stateIsCanceled());
44 }
45
46 @Test
47 public void testSuperUserInitiatorCancel() throws Exception {
48 WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
49 assertTrue("WorkflowDocument should indicate ewestfal as SuperUser", document.isSuperUser());
50 document.superUserCancel("");
51 assertTrue("Document should be final after Super User Cancel", document.stateIsCanceled());
52 }
53
54 @Test
55 public void testSuperUserNonInitiatorCancel() throws Exception {
56 WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("delyea"), NotifySetup.DOCUMENT_TYPE_NAME);
57 document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), document.getRouteHeaderId());
58 assertTrue("WorkflowDocument should indicate ewestfal as SuperUser", document.isSuperUser());
59 document.superUserCancel("");
60 assertTrue("Document should be final after Super User Cancel", document.stateIsCanceled());
61 }
62
63 @Test
64 public void testSuperUserCancelInvalidUser() throws Exception {
65 WorkflowDocument document = new WorkflowDocument(new NetworkIdDTO("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
66 document.routeDocument("");
67
68 document = new WorkflowDocument(new NetworkIdDTO("quickstart"), document.getRouteHeaderId());
69 try {
70 assertFalse("WorkflowDocument should not indicate quickstart as SuperUser", document.isSuperUser());
71 document.superUserCancel("");
72 fail("invalid user attempted to SuperUserApprove");
73 } catch (Exception e) {
74 }
75
76 }
77
78 }