Source Code Cross Referenced for RevokeAdHocActionTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » actions » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » edu.iu.uis.eden.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 The Kuali Foundation.
003:         * 
004:         * 
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         * 
009:         * http://www.opensource.org/licenses/ecl1.php
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package edu.iu.uis.eden.actions;
018:
019:        import java.util.Collection;
020:        import java.util.List;
021:
022:        import org.junit.Test;
023:        import org.kuali.workflow.test.WorkflowTestCase;
024:
025:        import edu.iu.uis.eden.EdenConstants;
026:        import edu.iu.uis.eden.KEWServiceLocator;
027:        import edu.iu.uis.eden.clientapp.WorkflowDocument;
028:        import edu.iu.uis.eden.clientapp.WorkflowInfo;
029:        import edu.iu.uis.eden.clientapp.vo.ActionRequestVO;
030:        import edu.iu.uis.eden.clientapp.vo.AdHocRevokeVO;
031:        import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
032:        import edu.iu.uis.eden.clientapp.vo.WorkgroupNameIdVO;
033:        import edu.iu.uis.eden.exception.WorkflowException;
034:        import edu.iu.uis.eden.test.TestUtilities;
035:
036:        public class RevokeAdHocActionTest extends WorkflowTestCase {
037:
038:            private static final String ADH0C_DOC = "AdhocRouteTest";
039:            private Long docId;
040:
041:            protected void loadTestData() throws Exception {
042:                loadXmlFile("ActionsConfig.xml");
043:            }
044:
045:            /**
046:             * Tests revoking by action request id.
047:             */
048:            @Test
049:            public void testRevokeByActionRequestId() throws Exception {
050:                WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
051:                        "rkirkend"), ADH0C_DOC);
052:                docId = doc.getRouteHeaderId();
053:                doc.appSpecificRouteDocumentToUser(
054:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc",
055:                        "annotation1", new NetworkIdVO("dewey"), "respDesc1",
056:                        false);
057:
058:                // check the action requests
059:                TestUtilities.assertNumberOfPendingRequests(docId, 1);
060:                TestUtilities.assertUserHasPendingRequest(docId, "dewey");
061:
062:                // now revoke by a bad action request id, we should recieve a WorkflowException
063:                try {
064:                    doc.revokeAdHocRequests(new AdHocRevokeVO(new Long(
065:                            123456789)), "");
066:                    fail("Revoking by a bad action request id should have thrown an exception!");
067:                } catch (WorkflowException e) {
068:                }
069:
070:                // revoke by the real action request id
071:                ActionRequestVO[] actionRequestVOs = new WorkflowInfo()
072:                        .getActionRequests(docId);
073:                assertEquals(1, actionRequestVOs.length);
074:                Long actionRequestId = actionRequestVOs[0].getActionRequestId();
075:                doc.revokeAdHocRequests(new AdHocRevokeVO(actionRequestId), "");
076:
077:                // there should now be no pending requests
078:                TestUtilities.assertNumberOfPendingRequests(docId, 0);
079:
080:                // route the document, this doc type is configured to route to user1
081:                doc.routeDocument("");
082:                doc = getDocument("user1");
083:                assertTrue(doc.isApprovalRequested());
084:
085:                // now attempt to revoke this non-adhoc request by id, it should throw an error
086:                actionRequestVOs = new WorkflowInfo().getActionRequests(docId);
087:                for (int index = 0; index < actionRequestVOs.length; index++) {
088:                    if (actionRequestVOs[index].isPending()) {
089:                        try {
090:                            doc.revokeAdHocRequests(new AdHocRevokeVO(
091:                                    actionRequestVOs[index]
092:                                            .getActionRequestId()), "");
093:                            fail("Attempted to revoke by an invalid action request id, should have thrown an error!");
094:                        } catch (WorkflowException e) {
095:                        }
096:                    }
097:                }
098:
099:            }
100:
101:            /**
102:             * Tests revoking by user and workgroup.
103:             */
104:            @Test
105:            public void testRevokeByUserAndWorkgroup() throws Exception {
106:                // ad hoc the document to dewey (twice) and the workgroup WorkflowAdmin
107:                WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
108:                        "rkirkend"), ADH0C_DOC);
109:                docId = doc.getRouteHeaderId();
110:                doc.appSpecificRouteDocumentToUser(
111:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc",
112:                        "annotationDewey1", new NetworkIdVO("dewey"),
113:                        "respDesc1", false);
114:                doc.appSpecificRouteDocumentToUser(
115:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc",
116:                        "annotationDewey2", new NetworkIdVO("dewey"),
117:                        "respDesc1", false);
118:                doc.appSpecificRouteDocumentToWorkgroup(
119:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc",
120:                        "Annotation WorkflowAdmin", new WorkgroupNameIdVO(
121:                                "WorkflowAdmin"), "respDesc2", true);
122:
123:                TestUtilities.assertNumberOfPendingRequests(docId, 3);
124:                TestUtilities.assertUserHasPendingRequest(docId, "dewey");
125:                TestUtilities.assertUserHasPendingRequest(docId, "quickstart");
126:
127:                // route the document, this should activate the ad hoc requests
128:                doc.routeDocument("");
129:                assertTrue(doc.stateIsEnroute());
130:                TestUtilities.assertAtNode(doc, "AdHoc");
131:                TestUtilities.assertNumberOfPendingRequests(docId, 3);
132:
133:                // try revoking by a user and workgroup without adhoc requests, it should effectively be a no-op
134:                doc.revokeAdHocRequests(new AdHocRevokeVO(new NetworkIdVO(
135:                        "ewestfal")), "This should be a no-op");
136:                doc.revokeAdHocRequests(new AdHocRevokeVO(
137:                        new WorkgroupNameIdVO("TestWorkgroup")),
138:                        "This should be a no-op");
139:                doc = getDocument("rkirkend");
140:                TestUtilities.assertNumberOfPendingRequests(docId, 3);
141:                TestUtilities.assertUserHasPendingRequest(docId, "dewey");
142:                TestUtilities.assertUserHasPendingRequest(docId, "quickstart");
143:
144:                // now revoke each request in turn, after the second one is invoked the document should transition to it's next route level
145:                // and route to user1
146:                doc.revokeAdHocRequests(new AdHocRevokeVO(new NetworkIdVO(
147:                        "dewey")), "revokeUser");
148:                TestUtilities.assertNumberOfPendingRequests(docId, 1);
149:                doc = getDocument("dewey");
150:                assertFalse("dewey should no longer have an approve request.",
151:                        doc.isApprovalRequested());
152:                doc.revokeAdHocRequests(new AdHocRevokeVO(
153:                        new WorkgroupNameIdVO("WorkflowAdmin")),
154:                        "revokeWorkgroup");
155:
156:                // the doc should now transition to the next node
157:                doc = getDocument("user1");
158:                TestUtilities.assertAtNode(doc, "One");
159:                assertTrue("user1 should have an approve request.", doc
160:                        .isApprovalRequested());
161:                doc.approve("");
162:
163:                // doc should now be final
164:                assertTrue("doc should be final", doc.stateIsFinal());
165:            }
166:
167:            /**
168:             * Tests revoking by node name.
169:             */
170:            @Test
171:            public void testRevokeByNodeName() throws Exception {
172:                // ad hoc requests at the AdHoc node and then revoke the entire node
173:                WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
174:                        "rkirkend"), ADH0C_DOC);
175:                docId = doc.getRouteHeaderId();
176:                doc.appSpecificRouteDocumentToUser(
177:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc",
178:                        "annotationDewey1", new NetworkIdVO("dewey"),
179:                        "respDesc1", false);
180:                doc.appSpecificRouteDocumentToWorkgroup(
181:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc",
182:                        "Annotation WorkflowAdmin", new WorkgroupNameIdVO(
183:                                "WorkflowAdmin"), "respDesc2", true);
184:                TestUtilities.assertNumberOfPendingRequests(docId, 2);
185:
186:                // now revoke the node
187:                doc.revokeAdHocRequests(new AdHocRevokeVO("AdHoc"), "");
188:                TestUtilities.assertNumberOfPendingRequests(docId, 0);
189:                // send an Acknowledge to the AdHoc node prior to routing
190:                doc.appSpecificRouteDocumentToUser(
191:                        EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, "AdHoc",
192:                        "annotationEwestfal1", new NetworkIdVO("ewestfal"),
193:                        "respDesc1", false);
194:
195:                // route the document
196:                doc = getDocument("rkirkend");
197:                doc.routeDocument("");
198:                TestUtilities.assertAtNode(doc, "One");
199:
200:                // ewestfal should have an acknowledge request
201:                doc = getDocument("ewestfal");
202:                assertTrue(doc.isAcknowledgeRequested());
203:
204:                // approve the document, it should go PROCESSED
205:                doc = getDocument("user1");
206:                assertTrue(doc.isApprovalRequested());
207:                doc.approve("");
208:                assertTrue(doc.stateIsProcessed());
209:
210:                // revoke at the "One" node where there are no requests, it should be a no-op (the document should stay processed)
211:                doc.revokeAdHocRequests(new AdHocRevokeVO("One"), "");
212:                doc = getDocument("ewestfal");
213:                assertTrue(doc.stateIsProcessed());
214:
215:                // now revoke the ACKNOWLEDGE to ewestfal by revoking at the "AdHoc" node, the document should go FINAL
216:                doc.revokeAdHocRequests(new AdHocRevokeVO("AdHoc"), "");
217:                doc = getDocument("ewestfal");
218:                assertTrue(doc.stateIsFinal());
219:            }
220:
221:            /**
222:             * Tests the behavior revocation of ad hoc requests prior to the routing of the document.
223:             * 
224:             * @throws Exception
225:             */
226:            @Test
227:            public void testRevokePriorToRouting() throws Exception {
228:                // ad hoc the document to dewey and the workgroup WorkflowAdmin
229:                WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
230:                        "rkirkend"), ADH0C_DOC);
231:                docId = doc.getRouteHeaderId();
232:                doc.appSpecificRouteDocumentToUser(
233:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc",
234:                        "annotation1", new NetworkIdVO("dewey"), "respDesc1",
235:                        false);
236:
237:                doc = getDocument("dewey");
238:                assertFalse(
239:                        "User andlee should not have an approve request yet.  Document not yet routed.",
240:                        doc.isApprovalRequested());
241:                doc.appSpecificRouteDocumentToWorkgroup(
242:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc",
243:                        "annotation2", new WorkgroupNameIdVO("WorkflowAdmin"),
244:                        "respDesc2", true);
245:                doc = getDocument("quickstart");
246:                assertFalse(
247:                        "User should not have approve request yet.  Document not yet routed.",
248:                        doc.isApprovalRequested());
249:
250:                // the document should be initiated at this point
251:                assertTrue("Document should still be intitiated.", doc
252:                        .stateIsInitiated());
253:
254:                // check and revoke the actual ActionRequestVOs
255:                WorkflowInfo info = new WorkflowInfo();
256:                // reaquire the document as the initiator
257:                doc = getDocument("rkirkend");
258:                ActionRequestVO[] actionRequestVOs = info.getActionRequests(doc
259:                        .getRouteHeaderId());
260:                assertEquals("There should be 2 ad hoc requests.", 2,
261:                        actionRequestVOs.length);
262:                for (int index = 0; index < actionRequestVOs.length; index++) {
263:                    ActionRequestVO requestVO = actionRequestVOs[index];
264:                    assertTrue("Should be an ad hoc request.", requestVO
265:                            .isAdHocRequest());
266:                    // revoke by id
267:                    doc.revokeAdHocRequests(new AdHocRevokeVO(requestVO
268:                            .getActionRequestId()), "");
269:                }
270:
271:                // now the document should have no pending action requests on it
272:                List actionRequests = KEWServiceLocator
273:                        .getActionRequestService().findPendingByDoc(docId);
274:                assertEquals("There should be no pending requests.", 0,
275:                        actionRequests.size());
276:
277:                // check that the "ActionTakens" have been properly recorded
278:                Collection actionTakens = KEWServiceLocator
279:                        .getActionTakenService().findByDocIdAndAction(docId,
280:                                EdenConstants.ACTION_TAKEN_ADHOC_REVOKED_CD);
281:                assertEquals("There should be 2 'AdHocRevoked' action takens",
282:                        2, actionTakens.size());
283:
284:                // now check that the document is still intiated
285:                doc = getDocument("rkirkend");
286:                assertTrue("Document should still be intitiated.", doc
287:                        .stateIsInitiated());
288:            }
289:
290:            /**
291:             * Tests the revocation of ad hoc requests after a blanket approve.  The goal of this test is to verify that revocation of
292:             * ad hoc requests doesn't have any adverse effects on the notification requests
293:             */
294:            @Test
295:            public void testRevokeAfterBlanketApprove() throws Exception {
296:                WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
297:                        "rkirkend"), ADH0C_DOC);
298:                docId = doc.getRouteHeaderId();
299:                // send an FYI to the AdHoc node prior to blanket approving
300:                doc.appSpecificRouteDocumentToUser(
301:                        EdenConstants.ACTION_REQUEST_FYI_REQ, "AdHoc",
302:                        "annotationEwestfal1", new NetworkIdVO("ewestfal"),
303:                        "respDesc1", false);
304:
305:                // blanket approve the document
306:                doc.blanketApprove("");
307:                assertTrue(doc.stateIsProcessed());
308:
309:                // ewestfal should have his ad hoc FYI and user1 should have an ack from the blanket approve
310:                doc = getDocument("ewestfal");
311:                assertTrue(doc.isFYIRequested());
312:                doc = getDocument("user1");
313:                assertTrue(doc.isAcknowledgeRequested());
314:
315:                // revoke all ad hoc requests
316:                doc.revokeAdHocRequests(new AdHocRevokeVO(),
317:                        "revoking all adhocs");
318:                assertTrue(doc.stateIsProcessed());
319:                TestUtilities.assertNumberOfPendingRequests(docId, 1);
320:
321:                // user1 should still have acknowledge request
322:                assertTrue(doc.isAcknowledgeRequested());
323:
324:                // ewestfal should no longer have an fyi
325:                doc = getDocument("ewestfal");
326:                assertFalse(doc.isFYIRequested());
327:            }
328:
329:            private WorkflowDocument getDocument(String netid)
330:                    throws WorkflowException {
331:                return new WorkflowDocument(new NetworkIdVO(netid), docId);
332:            }
333:
334:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.