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
33
34 public class SuperUserDisapproveTest extends KEWTestCase {
35
36 protected void loadTestData() throws Exception {
37 loadXmlFile("ActionsConfig.xml");
38 }
39
40 @Test public void testSuperUserDisapprove() throws Exception {
41 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
42 document.route("");
43
44 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("jhopf"), document.getDocumentId());
45 assertTrue("WorkflowDocument should indicate jhopf as SuperUser", document.isValidAction(ActionType.SU_DISAPPROVE));
46 document.superUserDisapprove("");
47 assertTrue("Document should be final after Super User Disapprove", document.isDisapproved());
48 }
49
50 @Test public void testSuperUserInitiatorDisapprove() 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_DISAPPROVE));
53 document.superUserDisapprove("");
54 assertTrue("Document should be final after Super User Disapprove", document.isDisapproved());
55 }
56
57 @Test public void testSuperUserDisapproveInvalidUser() throws Exception {
58 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), NotifySetup.DOCUMENT_TYPE_NAME);
59 document.route("");
60
61 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("quickstart"), document.getDocumentId());
62 try {
63 assertFalse("WorkflowDocument should not indicate quickstart as SuperUser", document.isValidAction(ActionType.SU_DISAPPROVE));
64 document.superUserDisapprove("");
65 fail("invalid user attempted to SuperUserApprove");
66 } catch (Exception e) {
67 }
68
69 }
70
71 }