Source Code Cross Referenced for AdHocRouteTest.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.List;
020:
021:        import org.junit.Test;
022:        import org.kuali.workflow.test.WorkflowTestCase;
023:
024:        import edu.iu.uis.eden.EdenConstants;
025:        import edu.iu.uis.eden.KEWServiceLocator;
026:        import edu.iu.uis.eden.actionrequests.ActionRequestValue;
027:        import edu.iu.uis.eden.clientapp.WorkflowDocument;
028:        import edu.iu.uis.eden.clientapp.vo.ActionRequestVO;
029:        import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
030:        import edu.iu.uis.eden.clientapp.vo.WorkgroupNameIdVO;
031:        import edu.iu.uis.eden.exception.WorkflowException;
032:        import edu.iu.uis.eden.test.TestUtilities;
033:
034:        public class AdHocRouteTest extends WorkflowTestCase {
035:
036:            private static final String ADHOC_DOC = "AdhocRouteTest";
037:            private Long docId;
038:
039:            protected void loadTestData() throws Exception {
040:                loadXmlFile("ActionsConfig.xml");
041:            }
042:
043:            @Test
044:            public void testParallelAdHocRouting() throws Exception {
045:                WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
046:                        "rkirkend"), ADHOC_DOC);
047:                docId = doc.getRouteHeaderId();
048:                doc.appSpecificRouteDocumentToUser(
049:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc",
050:                        "annotation1", new NetworkIdVO("dewey"), "respDesc1",
051:                        false);
052:
053:                doc = getDocument("dewey");
054:                assertFalse(
055:                        "User andlee should not have an approve request yet.  Document not yet routed.",
056:                        doc.isApprovalRequested());
057:                doc.appSpecificRouteDocumentToWorkgroup(
058:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc",
059:                        "annotation2", new WorkgroupNameIdVO("WorkflowAdmin"),
060:                        "respDesc2", true);
061:
062:                doc = getDocument("quickstart");
063:                assertFalse(
064:                        "User should not have approve request yet.  Document not yet routed.",
065:                        doc.isApprovalRequested());
066:
067:                doc = getDocument("rkirkend");
068:                doc.routeDocument("");
069:
070:                // there should be two adhoc requests
071:                ActionRequestVO[] actionRequests = doc.getActionRequests();
072:                for (int index = 0; index < actionRequests.length; index++) {
073:                    assertTrue("Request should be an adhoc request.",
074:                            actionRequests[index].isAdHocRequest());
075:                }
076:
077:                //all users should now have active approvals
078:                WorkflowDocument deweyDoc = getDocument("dewey");
079:                assertTrue("Dewey should have an approve request", deweyDoc
080:                        .isApprovalRequested());
081:
082:                doc = getDocument("ewestfal");// test that more than 1 member got
083:                // requests
084:                assertTrue("WorkflowAdmin should have an approve request", doc
085:                        .isApprovalRequested());
086:
087:                deweyDoc.approve("");
088:                doc.approve("");
089:                doc = getDocument("user1");//this dude has a rule in ActionsConfig.xml
090:                doc.approve("");
091:                assertTrue("The document should be final", doc.stateIsFinal());
092:            }
093:
094:            /**
095:             * Test generation of an initial ad-hoc request to initiator prior to
096:             * routing.
097:             *
098:             * This test will fail until EN-643 is resolved.
099:             */
100:            @Test
101:            public void testAdHocToInitiator() throws Exception {
102:                final String ADHOC_NODE = "AdHoc";
103:                WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
104:                        "rkirkend"), ADHOC_DOC);
105:                docId = doc.getRouteHeaderId();
106:                doc.appSpecificRouteDocumentToUser(
107:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, ADHOC_NODE,
108:                        "annotation1", new NetworkIdVO("rkirkend"), "", true);
109:
110:                doc.routeDocument("");
111:                assertTrue(doc.stateIsEnroute());
112:
113:                doc = getDocument("rkirkend");
114:                assertTrue(
115:                        "rkirkend should have an approval request on the document",
116:                        doc.isApprovalRequested());
117:                TestUtilities.assertAtNode(doc, ADHOC_NODE);
118:
119:                // now try it with ignore previous=false
120:                doc = new WorkflowDocument(new NetworkIdVO("rkirkend"),
121:                        ADHOC_DOC);
122:                docId = doc.getRouteHeaderId();
123:                doc.appSpecificRouteDocumentToUser(
124:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, ADHOC_NODE,
125:                        "annotation1", new NetworkIdVO("rkirkend"), "", false);
126:
127:                doc.routeDocument("");
128:                assertTrue(doc.stateIsEnroute());
129:
130:                doc = getDocument("rkirkend");
131:                assertFalse(
132:                        "rkirkend should NOT have an approval request on the document",
133:                        doc.isApprovalRequested());
134:                TestUtilities.assertAtNode(doc, "One");
135:                doc = getDocument("user1");
136:                assertTrue(
137:                        "user1 should have an approval request on the document",
138:                        doc.isApprovalRequested());
139:            }
140:
141:            @Test
142:            public void testSerialAdHocRouting() throws Exception {
143:                WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
144:                        "rkirkend"), ADHOC_DOC);
145:                docId = doc.getRouteHeaderId();
146:                doc.routeDocument("");
147:                doc = getDocument("user1");
148:                doc.appSpecificRouteDocumentToUser(
149:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "One",
150:                        "annotation1", new NetworkIdVO("user2"), "", false);
151:                doc.appSpecificRouteDocumentToUser(
152:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "One",
153:                        "annotation1", new NetworkIdVO("rkirkend"), "", true);
154:                doc.approve("");
155:                doc = getDocument("rkirkend");
156:                assertFalse(
157:                        "rkirkend should not have the document at this point 'S' activation",
158:                        doc.isApprovalRequested());
159:                doc = getDocument("user2");
160:                assertTrue("user2 should have an approve request", doc
161:                        .isApprovalRequested());
162:                doc.approve("");
163:                doc = getDocument("rkirkend");
164:                doc.approve("");
165:                assertTrue("The document should be final", doc.stateIsFinal());
166:            }
167:
168:            @Test
169:            public void testAdHocWhenDocumentIsInitiated() throws Exception {
170:                WorkflowDocument document = new WorkflowDocument(
171:                        new NetworkIdVO("ewestfal"),
172:                        "TakeWorkgroupAuthorityDoc");
173:                document.saveRoutingData();
174:                assertTrue(document.stateIsInitiated());
175:
176:                document.appSpecificRouteDocumentToUser(
177:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ,
178:                        "My Annotation", new NetworkIdVO("rkirkend"), "", true);
179:                document.appSpecificRouteDocumentToUser(
180:                        EdenConstants.ACTION_REQUEST_FYI_REQ, "My Annotation",
181:                        new NetworkIdVO("user1"), "", true);
182:
183:                // this is an initiated document, the requests should not be activated yet
184:                document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
185:                        document.getRouteHeaderId());
186:                assertFalse(document.isApprovalRequested());
187:                document = new WorkflowDocument(new NetworkIdVO("user1"),
188:                        document.getRouteHeaderId());
189:                assertFalse(document.isFYIRequested());
190:
191:                // now route the document, the requests should be activated
192:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
193:                        document.getRouteHeaderId());
194:                document.routeDocument("");
195:                document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
196:                        document.getRouteHeaderId());
197:                assertTrue(document.isApprovalRequested());
198:                document = new WorkflowDocument(new NetworkIdVO("user1"),
199:                        document.getRouteHeaderId());
200:                assertTrue(document.isFYIRequested());
201:            }
202:
203:            @Test
204:            public void testAdHocWhenDocumentIsFinal() throws Exception {
205:                WorkflowDocument document = new WorkflowDocument(
206:                        new NetworkIdVO("ewestfal"),
207:                        "TakeWorkgroupAuthorityDoc");
208:                document.routeDocument("");
209:
210:                try {
211:                    document.appSpecificRouteDocumentToUser("A", "AdHoc", "",
212:                            new NetworkIdVO("ewestfal"), "", true);
213:                    fail("document should not be allowed to route to nodes that are complete");
214:                } catch (Exception e) {
215:                }
216:
217:                document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
218:                        document.getRouteHeaderId());
219:                document.approve("");
220:
221:                assertTrue("Document should be final", document.stateIsFinal());
222:
223:                document = new WorkflowDocument(new NetworkIdVO("user1"),
224:                        document.getRouteHeaderId());
225:                ActionRequestVO[] requests = document.getActionRequests();
226:                for (int i = 0; i < requests.length; i++) {
227:                    ActionRequestVO request = requests[i];
228:                    if (request.isActivated()) {
229:                        fail("Active requests should not be present on a final document");
230:                    }
231:                }
232:
233:                // try and adhoc a request to a final document, should blow up
234:                try {
235:                    document.appSpecificRouteDocumentToUser("A",
236:                            "WorkgroupByDocument", "", new NetworkIdVO(
237:                                    "ewestfal"), "", true);
238:                    fail("Should not be allowed to adhoc approve to a final document.");
239:                } catch (Exception e) {
240:
241:                }
242:
243:                // it should be legal to adhoc an FYI on a FINAL document
244:                document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
245:                        document.getRouteHeaderId());
246:                assertFalse("rkirkend should not have an FYI request.",
247:                        document.isFYIRequested());
248:                document.appSpecificRouteDocumentToUser(
249:                        EdenConstants.ACTION_REQUEST_FYI_REQ,
250:                        "WorkgroupByDocument", "", new NetworkIdVO("rkirkend"),
251:                        "", true);
252:                document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
253:                        document.getRouteHeaderId());
254:                assertTrue("rkirkend should have an FYI request", document
255:                        .isFYIRequested());
256:            }
257:
258:            @Test
259:            public void testAdHocWhenDocumentIsSaved() throws Exception {
260:                WorkflowDocument document = new WorkflowDocument(
261:                        new NetworkIdVO("ewestfal"),
262:                        "TakeWorkgroupAuthorityDoc");
263:                document.saveDocument("");
264:
265:                // TODO test adhocing of approve requests
266:
267:                assertTrue("Document should be saved.", document.stateIsSaved());
268:                document.appSpecificRouteDocumentToUser(
269:                        EdenConstants.ACTION_REQUEST_FYI_REQ, "AdHoc", "",
270:                        new NetworkIdVO("rkirkend"), "", true);
271:                document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
272:                        document.getRouteHeaderId());
273:                assertTrue("rkirkend should have an FYI request", document
274:                        .isFYIRequested());
275:            }
276:
277:            @Test
278:            public void testAdHocFieldsSavedCorrectly() throws Exception {
279:                WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
280:                        "rkirkend"), ADHOC_DOC);
281:                docId = doc.getRouteHeaderId();
282:                doc.routeDocument("");
283:                doc = getDocument("user1");
284:                doc.appSpecificRouteDocumentToUser(
285:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ, "One",
286:                        "annotation1", new NetworkIdVO("user2"), "respDesc",
287:                        false);
288:
289:                List requests = KEWServiceLocator.getActionRequestService()
290:                        .findAllActionRequestsByRouteHeaderId(
291:                                doc.getRouteHeaderId());
292:                // if sync routequeue is working our adhoc request should always be the
293:                // second one out
294:                ActionRequestValue request = (ActionRequestValue) requests
295:                        .get(1);
296:
297:                assertEquals("annotation incorrect", "annotation1", request
298:                        .getAnnotation());
299:                assertEquals("action requested code incorrect", request
300:                        .getActionRequested(),
301:                        EdenConstants.ACTION_REQUEST_APPROVE_REQ);
302:                assertEquals("responsibility desc incorrect", request
303:                        .getResponsibilityDesc(), "respDesc");
304:                assertEquals("wrong person", request.getWorkflowUser()
305:                        .getAuthenticationUserId().getAuthenticationId(),
306:                        "user2");
307:                assertEquals("wrong ignore previous", request
308:                        .getIgnorePrevAction(), Boolean.FALSE);
309:
310:            }
311:
312:            @Test
313:            public void testAdHocDissaprovedDocument() throws Exception {
314:                WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
315:                        "ewestfal"), ADHOC_DOC);
316:                docId = doc.getRouteHeaderId();
317:                doc.routeDocument("");
318:
319:                doc = getDocument("user1");
320:                TestUtilities.assertAtNode(doc, "One");
321:                doc.disapprove("");
322:                TestUtilities.assertAtNode(doc, "One");
323:                //adhoc an ack and fyi
324:
325:                doc.appSpecificRouteDocumentToUser("F", "One", "",
326:                        new NetworkIdVO("rkirkend"), "", true);
327:                doc.appSpecificRouteDocumentToUser("K", "One", "",
328:                        new NetworkIdVO("user2"), "", true);
329:
330:                doc = getDocument("rkirkend");
331:                assertTrue(doc.isFYIRequested());
332:                doc.fyi();
333:                doc = getDocument("user2");
334:                assertTrue(doc.isAcknowledgeRequested());
335:                doc.acknowledge("");
336:
337:                //make sure we cant ad hoc approves or completes
338:                doc = new WorkflowDocument(new NetworkIdVO("rkirkend"),
339:                        ADHOC_DOC);
340:                docId = doc.getRouteHeaderId();
341:                doc.routeDocument("");
342:
343:                doc = getDocument("user1");
344:                doc.disapprove("");
345:
346:                // try to ad hoc an approve request
347:                try {
348:                    doc.appSpecificRouteDocumentToUser("A", "One", "",
349:                            new NetworkIdVO("rkirkend"), "", true);
350:                    fail("should have thrown exception cant adhoc approvals on dissaproved documents");
351:                } catch (Exception e) {
352:
353:                }
354:
355:                // try to ad hoc a complete request
356:                try {
357:                    doc.appSpecificRouteDocumentToUser("C", "One", "",
358:                            new NetworkIdVO("rkirkend"), "", true);
359:                    fail("should have thrown exception cant ad hoc completes on dissaproved documents");
360:                } catch (Exception e) {
361:
362:                }
363:
364:                // try to ad hoc an ack request
365:                try {
366:                    doc.appSpecificRouteDocumentToUser("K", "",
367:                            new NetworkIdVO("user1"), "", true);
368:                } catch (Exception e) {
369:                    e.printStackTrace();
370:                    fail("should have thrown exception cant ad hoc completes on dissaproved documents");
371:                }
372:
373:                // try to ad hoc a fyi request
374:                try {
375:                    doc.appSpecificRouteDocumentToUser("F", "",
376:                            new NetworkIdVO("user1"), "", true);
377:                } catch (Exception e) {
378:                    e.printStackTrace();
379:                    fail("should have thrown exception cant ad hoc completes on dissaproved documents");
380:                }
381:
382:            }
383:
384:            /**
385:             *
386:             * @throws Exception
387:             */
388:            @Test
389:            public void testAdHocNoNodeName() throws Exception {
390:                WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
391:                        "user1"), ADHOC_DOC);
392:                docId = doc.getRouteHeaderId();
393:
394:                // do an appspecific route to jitrue and NonSIT (w/ ignore previous =
395:                // false), should end up at the current node
396:                doc.appSpecificRouteDocumentToUser("A", "", new NetworkIdVO(
397:                        "jitrue"), "", false);
398:                doc.appSpecificRouteDocumentToWorkgroup("A", "",
399:                        new WorkgroupNameIdVO("NonSIT"), "", false);
400:                doc.routeDocument("");
401:
402:                // user1 should not have a request, his action should have counted for
403:                // the ad hoc request to the workgroup
404:                doc = getDocument("user1");
405:                assertFalse(doc.isApprovalRequested());
406:                doc = getDocument("jitrue");
407:                assertTrue(doc.isApprovalRequested());
408:                // we should still be at the "AdHoc" node because we sent an ad hoc
409:                // request to jitrue and the workgroup
410:                TestUtilities.assertAtNode(doc, "AdHoc");
411:
412:                // now disapprove as jitrue
413:                doc = getDocument("jitrue");
414:                TestUtilities.assertAtNode(doc, "AdHoc");
415:                doc.disapprove("");
416:                // we should stay at the AdHoc node following the disapprove
417:                TestUtilities.assertAtNode(doc, "AdHoc");
418:                assertTrue(doc.stateIsDisapproved());
419:                //adhoc an ack and fyi
420:
421:                doc.appSpecificRouteDocumentToUser("F", "", new NetworkIdVO(
422:                        "rkirkend"), "", true);
423:                doc.appSpecificRouteDocumentToUser("K", "", new NetworkIdVO(
424:                        "user2"), "", true);
425:                doc.appSpecificRouteDocumentToWorkgroup("K", "",
426:                        new WorkgroupNameIdVO("NonSIT"), "", true);
427:
428:                // rkirkend should have an FYI ad hoc request
429:                doc = getDocument("rkirkend");
430:                assertTrue(doc.isFYIRequested());
431:                doc.fyi();
432:
433:                // user3 should have an ACK ad hoc request because user3 is in the
434:                // NonSIT workgroup
435:                doc = getDocument("user3");
436:                assertTrue(doc.isAcknowledgeRequested());
437:
438:                // user2 should have an ACK ad hoc request (because of their individual
439:                // ack and because they are in the NonSIT workgroup)
440:                doc = getDocument("user2");
441:                assertTrue(doc.isAcknowledgeRequested());
442:                doc.acknowledge("");
443:
444:                // user2's ACK should have counted for the NonSIT workgroup request,
445:                // user 3 should no longer have an ACK
446:                doc = getDocument("user3");
447:                assertFalse(doc.isAcknowledgeRequested());
448:
449:                // finally user1 should have an acknowledge as a result of the
450:                // disapprove since user1 was the initiator
451:                doc = getDocument("user1");
452:                assertTrue(doc.isAcknowledgeRequested());
453:                doc.acknowledge("");
454:
455:                // there should now be no remaining pending requests on the document
456:                TestUtilities.assertNumberOfPendingRequests(doc
457:                        .getRouteHeaderId(), 0);
458:
459:                // make sure we cant ad hoc approves or completes on a "terminal"
460:                // document
461:                try {
462:                    doc.appSpecificRouteDocumentToUser("A", "",
463:                            new NetworkIdVO("rkirkend"), "", true);
464:                    fail("should have thrown exception cant adhoc approvals on dissaproved documents");
465:                } catch (Exception e) {
466:                }
467:                // try to ad hoc a complete request
468:                try {
469:                    doc.appSpecificRouteDocumentToUser("C", "",
470:                            new NetworkIdVO("rkirkend"), "", true);
471:                    fail("should have thrown exception cant ad hoc completes on dissaproved documents");
472:                } catch (Exception e) {
473:                }
474:
475:            }
476:
477:            private WorkflowDocument getDocument(String netid)
478:                    throws WorkflowException {
479:                return new WorkflowDocument(new NetworkIdVO(netid), docId);
480:            }
481:
482:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.