1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.rule;
17
18 import org.junit.Test;
19 import org.kuali.rice.kew.dto.NetworkIdDTO;
20 import org.kuali.rice.kew.exception.WorkflowException;
21 import org.kuali.rice.kew.service.WorkflowDocument;
22 import org.kuali.rice.kew.test.KEWTestCase;
23
24
25
26
27
28
29
30
31
32
33 public class KRAMetaRuleGroovyTest extends KEWTestCase {
34 protected void loadTestData() throws Exception {
35 loadXmlFile("KRAMetaRuleGroovy.xml");
36 loadXmlFile("KRAMetaRuleMapsGroovy.xml");
37 }
38
39 @Test public void testKRAMetaRuleGroovy() throws WorkflowException {
40 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("arh14"), "KRAMetaRuleTest");
41 doc.routeDocument("routing");
42
43 doc = new WorkflowDocument(new NetworkIdDTO("user2"), doc.getRouteHeaderId());
44
45
46 assertTrue(doc.isApprovalRequested());
47
48 doc.approve("approving as user2");
49
50 doc = new WorkflowDocument(new NetworkIdDTO("user2"), doc.getRouteHeaderId());
51
52 assertFalse(doc.isApprovalRequested());
53
54
55 doc = new WorkflowDocument(new NetworkIdDTO("user3"), doc.getRouteHeaderId());
56
57
58 assertTrue(doc.isApprovalRequested());
59
60 doc.approve("approving as user3");
61
62 doc = new WorkflowDocument(new NetworkIdDTO("user3"), doc.getRouteHeaderId());
63 assertFalse(doc.isApprovalRequested());
64 doc = new WorkflowDocument(new NetworkIdDTO("user2"), doc.getRouteHeaderId());
65 assertFalse(doc.isApprovalRequested());
66 doc = new WorkflowDocument(new NetworkIdDTO("user1"), doc.getRouteHeaderId());
67 assertFalse(doc.isApprovalRequested());
68
69 assertTrue(doc.stateIsFinal());
70 }
71
72 @Test public void testKRAMetaRuleMapsGroovy() throws WorkflowException {
73 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("arh14"), "KRAMetaRuleMapsTest");
74 doc.routeDocument("routing");
75
76
77
78
79 doc = new WorkflowDocument(new NetworkIdDTO("xqi"), doc.getRouteHeaderId());
80 assertTrue(doc.isApprovalRequested());
81 doc = new WorkflowDocument(new NetworkIdDTO("shenl"), doc.getRouteHeaderId());
82 assertFalse(doc.isApprovalRequested());
83 doc = new WorkflowDocument(new NetworkIdDTO("dewey"), doc.getRouteHeaderId());
84 assertFalse(doc.isApprovalRequested());
85
86 doc = new WorkflowDocument(new NetworkIdDTO("xqi"), doc.getRouteHeaderId());
87 doc.approve("approving as xqi");
88
89
90 doc = new WorkflowDocument(new NetworkIdDTO("xqi"), doc.getRouteHeaderId());
91 assertFalse(doc.isApprovalRequested());
92 doc = new WorkflowDocument(new NetworkIdDTO("shenl"), doc.getRouteHeaderId());
93 assertTrue(doc.isApprovalRequested());
94 doc = new WorkflowDocument(new NetworkIdDTO("jhopf"), doc.getRouteHeaderId());
95 assertTrue(doc.isApprovalRequested());
96 doc = new WorkflowDocument(new NetworkIdDTO("dewey"), doc.getRouteHeaderId());
97 assertFalse(doc.isApprovalRequested());
98
99 doc = new WorkflowDocument(new NetworkIdDTO("shenl"), doc.getRouteHeaderId());
100 doc.approve("approving as shenl");
101
102
103 doc = new WorkflowDocument(new NetworkIdDTO("xqi"), doc.getRouteHeaderId());
104 assertFalse(doc.isApprovalRequested());
105 doc = new WorkflowDocument(new NetworkIdDTO("shenl"), doc.getRouteHeaderId());
106 assertFalse(doc.isApprovalRequested());
107 doc = new WorkflowDocument(new NetworkIdDTO("jhopf"), doc.getRouteHeaderId());
108 assertFalse(doc.isApprovalRequested());
109 doc = new WorkflowDocument(new NetworkIdDTO("dewey"), doc.getRouteHeaderId());
110 assertTrue(doc.isApprovalRequested());
111
112 doc = new WorkflowDocument(new NetworkIdDTO("dewey"), doc.getRouteHeaderId());
113 doc.approve("approving as dewey");
114
115 assertTrue(doc.stateIsFinal());
116 }
117 }