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
21 import org.junit.Test;
22 import org.kuali.rice.kew.api.WorkflowDocument;
23 import org.kuali.rice.kew.api.WorkflowDocumentFactory;
24 import org.kuali.rice.kew.test.KEWTestCase;
25
26 public class ApproveActionTest extends KEWTestCase {
27
28 protected void loadTestData() throws Exception {
29 loadXmlFile("ActionsConfig.xml");
30 }
31
32 @Test public void testPreapprovals() throws Exception {
33 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "PreApprovalTest");
34 doc.route("");
35
36
37 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("ewestfal"), doc.getDocumentId());
38 doc.approve("");
39
40 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user2"), doc.getDocumentId());
41 doc.acknowledge("");
42
43 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user3"), doc.getDocumentId());
44 doc.complete("");
45
46
47 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user1"), doc.getDocumentId());
48 doc.approve("");
49
50 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user1"), doc.getDocumentId());
51 assertTrue("the document should be final", doc.isFinal());
52 }
53
54 @Test public void testInitiatorRole() throws Exception {
55 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "InitiatorRoleApprovalTest");
56 doc.route("");
57
58 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("ewestfal"), doc.getDocumentId());
59 doc.approve("");
60
61 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user2"), doc.getDocumentId());
62 doc.acknowledge("");
63
64 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("user3"), doc.getDocumentId());
65 doc.complete("");
66
67 assertFalse("the document should NOT be final", doc.isFinal());
68
69
70 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), doc.getDocumentId());
71 doc.approve("");
72
73 assertTrue("the document should be final", doc.isFinal());
74 }
75 }