Source Code Cross Referenced for BlanketApproveTest.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.Iterator;
021:        import java.util.List;
022:
023:        import mocks.MockEmailNotificationService;
024:
025:        import org.junit.Ignore;
026:        import org.junit.Test;
027:        import org.kuali.workflow.test.WorkflowTestCase;
028:
029:        import edu.iu.uis.eden.EdenConstants;
030:        import edu.iu.uis.eden.KEWServiceLocator;
031:        import edu.iu.uis.eden.actionrequests.ActionRequestService;
032:        import edu.iu.uis.eden.actionrequests.ActionRequestValue;
033:        import edu.iu.uis.eden.clientapp.WorkflowDocument;
034:        import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
035:        import edu.iu.uis.eden.engine.node.RouteNodeInstance;
036:        import edu.iu.uis.eden.engine.node.RouteNodeService;
037:        import edu.iu.uis.eden.exception.InvalidActionTakenException;
038:        import edu.iu.uis.eden.test.TestUtilities;
039:
040:        public class BlanketApproveTest extends WorkflowTestCase {
041:
042:            protected void loadTestData() throws Exception {
043:                loadXmlFile("ActionsConfig.xml");
044:            }
045:
046:            /**
047:             * When a user is not in the blanket approver workgroup an exception should be thrown and 
048:             * it should have a good message.
049:             * 
050:             * @throws Exception
051:             */
052:            @Test
053:            public void testBlanketApproverNotInBlanketApproverWorkgroup()
054:                    throws Exception {
055:                WorkflowDocument document = new WorkflowDocument(
056:                        new NetworkIdVO("user1"),
057:                        SequentialSetup.DOCUMENT_TYPE_NAME);
058:                try {
059:                    document.blanketApprove("");
060:                    fail("InvalidActionTakenException should have been thrown");
061:                } catch (InvalidActionTakenException iate) {
062:                    assertEquals(
063:                            "Exception on message is incorrent",
064:                            "User is not authorized to BlanketApprove document",
065:                            iate.getMessage());
066:                }
067:
068:            }
069:
070:            /**
071:             * When a user is in the blanket approve workgroup but the user is not the initiator an exception
072:             * should be thrown.
073:             */
074:            @Test
075:            public void testBlanketApproverNotInitiator() throws Exception {
076:                WorkflowDocument document = new WorkflowDocument(
077:                        new NetworkIdVO("user1"),
078:                        SequentialSetup.DOCUMENT_TYPE_NAME);
079:                WorkflowDocument newDocument = new WorkflowDocument(
080:                        new NetworkIdVO("ewestfal"), document
081:                                .getRouteHeaderId());
082:                try {
083:                    newDocument.blanketApprove("");
084:                    fail("Exception should have been thrown when non-initiator user attempts blanket approve on default blanket approve policy document");
085:                } catch (Exception e) {
086:                    e.printStackTrace();
087:                }
088:            }
089:
090:            @SuppressWarnings("deprecation")
091:            @Test
092:            public void testBlanketApproveSequential() throws Exception {
093:                WorkflowDocument document = new WorkflowDocument(
094:                        new NetworkIdVO("ewestfal"),
095:                        SequentialSetup.DOCUMENT_TYPE_NAME);
096:                document.blanketApprove("");
097:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
098:                        document.getRouteHeaderId());
099:                assertTrue("Document should be processed.", document
100:                        .stateIsProcessed());
101:                Collection nodeInstances = getRouteNodeService()
102:                        .getActiveNodeInstances(document.getRouteHeaderId());
103:                // once the document is processed there are no active nodes
104:                assertEquals("Wrong number of active nodes.", 0, nodeInstances
105:                        .size());
106:                nodeInstances = getRouteNodeService().getTerminalNodeInstances(
107:                        document.getRouteHeaderId());
108:                assertEquals("Wrong number of active nodes.", 1, nodeInstances
109:                        .size());
110:                RouteNodeInstance ackNodeInstance = (RouteNodeInstance) nodeInstances
111:                        .iterator().next();
112:                assertEquals("At wrong node.",
113:                        SequentialSetup.ACKNOWLEDGE_2_NODE, ackNodeInstance
114:                                .getRouteNode().getRouteNodeName());
115:                assertTrue("Node should be complete.", ackNodeInstance
116:                        .isComplete());
117:                List actionRequests = KEWServiceLocator
118:                        .getActionRequestService().findPendingByDoc(
119:                                document.getRouteHeaderId());
120:                assertEquals("Wrong number of pending action requests.", 5,
121:                        actionRequests.size());
122:                boolean isNotification1 = false;
123:                boolean isNotification2 = false;
124:                boolean isNotification3 = false;
125:                boolean isAck1 = false;
126:                boolean isAck2 = false;
127:                for (Iterator iterator = actionRequests.iterator(); iterator
128:                        .hasNext();) {
129:                    ActionRequestValue actionRequest = (ActionRequestValue) iterator
130:                            .next();
131:                    assertEquals("Should only be acknowledges.",
132:                            EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
133:                            actionRequest.getActionRequested());
134:                    RouteNodeInstance nodeInstance = actionRequest
135:                            .getNodeInstance();
136:                    assertNotNull(nodeInstance);
137:                    String nodeName = nodeInstance.getRouteNode()
138:                            .getRouteNodeName();
139:                    if (actionRequest.getWorkflowUser()
140:                            .getAuthenticationUserId().getId().equals(
141:                                    "bmcgough")) {
142:                        isNotification1 = true;
143:                        assertEquals(SequentialSetup.WORKFLOW_DOCUMENT_NODE,
144:                                nodeName);
145:                        assertEquals(
146:                                EdenConstants.MACHINE_GENERATED_RESPONSIBILITY_ID,
147:                                actionRequest.getResponsibilityId());
148:                    } else if (actionRequest.getWorkflowUser()
149:                            .getAuthenticationUserId().getId().equals(
150:                                    "rkirkend")) {
151:                        isNotification2 = true;
152:                        assertEquals(SequentialSetup.WORKFLOW_DOCUMENT_NODE,
153:                                nodeName);
154:                        assertEquals(
155:                                EdenConstants.MACHINE_GENERATED_RESPONSIBILITY_ID,
156:                                actionRequest.getResponsibilityId());
157:                    } else if (actionRequest.getWorkflowUser()
158:                            .getAuthenticationUserId().getId()
159:                            .equals("pmckown")) {
160:                        isNotification3 = true;
161:                        assertEquals(SequentialSetup.WORKFLOW_DOCUMENT_2_NODE,
162:                                nodeName);
163:                        assertEquals(
164:                                EdenConstants.MACHINE_GENERATED_RESPONSIBILITY_ID,
165:                                actionRequest.getResponsibilityId());
166:                    } else if (actionRequest.getWorkflowUser()
167:                            .getAuthenticationUserId().getId().equals("temay")) {
168:                        isAck1 = true;
169:                        assertEquals(SequentialSetup.ACKNOWLEDGE_1_NODE,
170:                                nodeName);
171:                        assertFalse(EdenConstants.MACHINE_GENERATED_RESPONSIBILITY_ID
172:                                .equals(actionRequest.getResponsibilityId()));
173:                    } else if (actionRequest.getWorkflowUser()
174:                            .getAuthenticationUserId().getId().equals("jhopf")) {
175:                        isAck2 = true;
176:                        assertEquals(SequentialSetup.ACKNOWLEDGE_2_NODE,
177:                                nodeName);
178:                        assertFalse(EdenConstants.MACHINE_GENERATED_RESPONSIBILITY_ID
179:                                .equals(actionRequest.getResponsibilityId()));
180:                    }
181:                }
182:                assertTrue(isNotification1);
183:                assertTrue(isNotification2);
184:                assertTrue(isNotification3);
185:                assertTrue(isAck1);
186:                assertTrue(isAck2);
187:                document = new WorkflowDocument(new NetworkIdVO("bmcgough"),
188:                        document.getRouteHeaderId());
189:                assertTrue(document.stateIsProcessed());
190:                assertTrue(document.isAcknowledgeRequested());
191:                assertEquals(
192:                        "bmcgough should not have been sent an approve email",
193:                        0, getMockEmailService().emailsSent("bmcgough",
194:                                document.getRouteHeaderId(),
195:                                EdenConstants.ACTION_REQUEST_APPROVE_REQ));
196:                assertEquals("bmcgough should not have been sent an ack email",
197:                        1, getMockEmailService().emailsSent("bmcgough",
198:                                document.getRouteHeaderId(),
199:                                EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ));
200:                document.acknowledge("");
201:
202:                document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
203:                        document.getRouteHeaderId());
204:                assertTrue(document.stateIsProcessed());
205:                assertTrue(document.isAcknowledgeRequested());
206:                assertEquals(
207:                        "rkirkend should not have been sent an approve email",
208:                        0, getMockEmailService().emailsSent("rkirkend",
209:                                document.getRouteHeaderId(),
210:                                EdenConstants.ACTION_REQUEST_APPROVE_REQ));
211:                assertEquals("rkirkend should not have been sent an ack email",
212:                        1, getMockEmailService().emailsSent("rkirkend",
213:                                document.getRouteHeaderId(),
214:                                EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ));
215:                document.acknowledge("");
216:
217:                document = new WorkflowDocument(new NetworkIdVO("pmckown"),
218:                        document.getRouteHeaderId());
219:                assertTrue(document.stateIsProcessed());
220:                assertTrue(document.isAcknowledgeRequested());
221:                assertEquals(
222:                        "pmckown should not have been sent an approve email",
223:                        0, getMockEmailService().emailsSent("pmckown",
224:                                document.getRouteHeaderId(),
225:                                EdenConstants.ACTION_REQUEST_APPROVE_REQ));
226:                assertEquals("pmckown should not have been sent an ack email",
227:                        1, getMockEmailService().emailsSent("pmckown",
228:                                document.getRouteHeaderId(),
229:                                EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ));
230:                document.acknowledge("");
231:
232:                document = new WorkflowDocument(new NetworkIdVO("temay"),
233:                        document.getRouteHeaderId());
234:                assertTrue(document.stateIsProcessed());
235:                assertTrue(document.isAcknowledgeRequested());
236:                assertEquals("rkirkend should have been sent an temay", 1,
237:                        getMockEmailService().emailsSent("temay",
238:                                document.getRouteHeaderId(),
239:                                EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ));
240:                document.acknowledge("");
241:
242:                document = new WorkflowDocument(new NetworkIdVO("jhopf"),
243:                        document.getRouteHeaderId());
244:                assertTrue(document.stateIsProcessed());
245:                assertTrue(document.isAcknowledgeRequested());
246:                assertEquals("rkirkend should have been sent an jhopf", 1,
247:                        getMockEmailService().emailsSent("jhopf",
248:                                document.getRouteHeaderId(),
249:                                EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ));
250:                document.acknowledge("");
251:
252:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
253:                        document.getRouteHeaderId());
254:                assertTrue(document.stateIsFinal());
255:
256:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
257:                        SequentialSetup.DOCUMENT_TYPE_NAME);
258:                document.blanketApprove("",
259:                        SequentialSetup.WORKFLOW_DOCUMENT_2_NODE);
260:                assertTrue("Document should be enroute.", document
261:                        .stateIsEnroute());
262:                nodeInstances = getRouteNodeService().getActiveNodeInstances(
263:                        document.getRouteHeaderId());
264:                assertEquals("Should be one active node.", 1, nodeInstances
265:                        .size());
266:                RouteNodeInstance doc2Instance = (RouteNodeInstance) nodeInstances
267:                        .iterator().next();
268:                assertEquals("At wrong node.",
269:                        SequentialSetup.WORKFLOW_DOCUMENT_2_NODE, doc2Instance
270:                                .getRouteNode().getRouteNodeName());
271:
272:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
273:                        SequentialSetup.DOCUMENT_TYPE_NAME);
274:                document.blanketApprove("", new Integer(2));
275:                assertTrue("Document should be enroute.", document
276:                        .stateIsEnroute());
277:                nodeInstances = getRouteNodeService().getActiveNodeInstances(
278:                        document.getRouteHeaderId());
279:                assertEquals("Should be one active node.", 1, nodeInstances
280:                        .size());
281:                doc2Instance = (RouteNodeInstance) nodeInstances.iterator()
282:                        .next();
283:                assertEquals("At wrong node.",
284:                        SequentialSetup.WORKFLOW_DOCUMENT_2_NODE, doc2Instance
285:                                .getRouteNode().getRouteNodeName());
286:
287:            }
288:
289:            @Test
290:            public void testBlanketApproveSequentialErrors() throws Exception {
291:                // blanket approve to invalid node
292:                WorkflowDocument document = new WorkflowDocument(
293:                        new NetworkIdVO("ewestfal"),
294:                        SequentialSetup.DOCUMENT_TYPE_NAME);
295:                try {
296:                    document.blanketApprove("", "TotallyInvalidNode");
297:                    fail("Should have thrown exception");
298:                } catch (Exception e) {
299:                }
300:
301:                // blanket approve backwards
302:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
303:                        SequentialSetup.DOCUMENT_TYPE_NAME);
304:                document.blanketApprove("",
305:                        SequentialSetup.WORKFLOW_DOCUMENT_2_NODE);
306:                try {
307:                    document.blanketApprove("",
308:                            SequentialSetup.WORKFLOW_DOCUMENT_NODE);
309:                    fail("Should have thrown exception");
310:                } catch (Exception e) {
311:                }
312:
313:                // blanket approve to current node
314:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
315:                        SequentialSetup.DOCUMENT_TYPE_NAME);
316:                document.routeDocument("");
317:                try {
318:                    document.blanketApprove("",
319:                            SequentialSetup.WORKFLOW_DOCUMENT_NODE);
320:                    fail("Should have thrown exception");
321:                } catch (Exception e) {
322:                }
323:
324:                // blanket approve as user not in the blanket approve workgroup
325:                document = new WorkflowDocument(new NetworkIdVO("user1"),
326:                        SequentialSetup.DOCUMENT_TYPE_NAME);
327:                try {
328:                    document.blanketApprove("");
329:                    fail("Shouldn't be able to blanket approve if not in blanket approve workgroup");
330:                } catch (Exception e) {
331:                }
332:            }
333:
334:            @Test
335:            public void testBlanketApproveParallel() throws Exception {
336:                WorkflowDocument document = new WorkflowDocument(
337:                        new NetworkIdVO("ewestfal"),
338:                        ParallelSetup.DOCUMENT_TYPE_NAME);
339:                document.blanketApprove("");
340:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
341:                        document.getRouteHeaderId());
342:                assertTrue("Document should be processed.", document
343:                        .stateIsProcessed());
344:                Collection nodeInstances = getRouteNodeService()
345:                        .getActiveNodeInstances(document.getRouteHeaderId());
346:                // once the document has gone processed there are no active nodes
347:                assertEquals("Wrong number of active nodes.", 0, nodeInstances
348:                        .size());
349:                nodeInstances = getRouteNodeService().getTerminalNodeInstances(
350:                        document.getRouteHeaderId());
351:                assertEquals("Wrong number of terminal nodes.", 1,
352:                        nodeInstances.size());
353:                RouteNodeInstance ackNodeInstance = (RouteNodeInstance) nodeInstances
354:                        .iterator().next();
355:                assertEquals("At wrong node.",
356:                        SequentialSetup.ACKNOWLEDGE_2_NODE, ackNodeInstance
357:                                .getRouteNode().getRouteNodeName());
358:                assertTrue("Node should be complete.", ackNodeInstance
359:                        .isComplete());
360:                List actionRequests = KEWServiceLocator
361:                        .getActionRequestService().findPendingByDoc(
362:                                document.getRouteHeaderId());
363:                assertEquals("Wrong number of pending action requests.", 10,
364:                        actionRequests.size());
365:
366:            }
367:
368:            @Test
369:            public void testBlanketApproveIntoBranch() throws Exception {
370:                WorkflowDocument document = new WorkflowDocument(
371:                        new NetworkIdVO("ewestfal"),
372:                        ParallelSetup.DOCUMENT_TYPE_NAME);
373:                document.blanketApprove("",
374:                        ParallelSetup.WORKFLOW_DOCUMENT_2_B1_NODE);
375:                List actionRequests = KEWServiceLocator
376:                        .getActionRequestService().findPendingByDoc(
377:                                document.getRouteHeaderId());
378:                assertEquals("Wrong number of pending action requests.", 5,
379:                        actionRequests.size());
380:
381:                // document should now be at the node we blanket approved to and the join node
382:                Collection activeNodes = getRouteNodeService()
383:                        .getActiveNodeInstances(document.getRouteHeaderId());
384:                assertEquals("Wrong number of active nodes.", 3, activeNodes
385:                        .size());
386:                boolean isAtWD2B1 = false;
387:                boolean isAtJoin = false;
388:                boolean isAtWD3B2 = false;
389:                boolean isAtWD4B3 = false;
390:                for (Iterator iterator = activeNodes.iterator(); iterator
391:                        .hasNext();) {
392:                    RouteNodeInstance nodeInstance = (RouteNodeInstance) iterator
393:                            .next();
394:                    isAtWD2B1 = isAtWD2B1
395:                            || nodeInstance.getName().equals(
396:                                    ParallelSetup.WORKFLOW_DOCUMENT_2_B1_NODE);
397:                    isAtWD3B2 = isAtWD3B2
398:                            || nodeInstance.getName().equals(
399:                                    ParallelSetup.WORKFLOW_DOCUMENT_3_B2_NODE);
400:                    isAtWD4B3 = isAtWD4B3
401:                            || nodeInstance.getName().equals(
402:                                    ParallelSetup.WORKFLOW_DOCUMENT_4_B3_NODE);
403:                    isAtJoin = isAtJoin
404:                            || nodeInstance.getName().equals(
405:                                    ParallelSetup.JOIN_NODE);
406:                }
407:                assertTrue("Should be at blanket approved node.", isAtWD2B1);
408:                assertTrue("Should be at blanket approved node WD3B2.",
409:                        isAtWD3B2);
410:                assertTrue("Should be at blanket approved node WD4B3.",
411:                        isAtWD4B3);
412:                assertFalse("Should be at join node.", isAtJoin);
413:
414:                document.blanketApprove("");
415:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
416:                        document.getRouteHeaderId());
417:                assertTrue("Document should be processed.", document
418:                        .stateIsProcessed());
419:                actionRequests = KEWServiceLocator.getActionRequestService()
420:                        .findPendingByDoc(document.getRouteHeaderId());
421:
422:                assertEquals("Wrong number of pending action requests.", 10,
423:                        actionRequests.size());
424:            }
425:
426:            @Test
427:            public void testBlanketApproveToMultipleNodes() throws Exception {
428:
429:                WorkflowDocument document = new WorkflowDocument(
430:                        new NetworkIdVO("ewestfal"),
431:                        ParallelSetup.DOCUMENT_TYPE_NAME);
432:                document.blanketApprove("", new String[] {
433:                        ParallelSetup.WORKFLOW_DOCUMENT_2_B1_NODE,
434:                        ParallelSetup.WORKFLOW_DOCUMENT_3_B2_NODE });
435:                List actionRequests = KEWServiceLocator
436:                        .getActionRequestService().findPendingByDoc(
437:                                document.getRouteHeaderId());
438:                assertEquals("Wrong number of pending action requests.", 5,
439:                        actionRequests.size());
440:
441:                // document should now be at both nodes we blanket approved to and the join node
442:                Collection activeNodes = getRouteNodeService()
443:                        .getActiveNodeInstances(document.getRouteHeaderId());
444:                assertEquals("Wrong number of active nodes.", 3, activeNodes
445:                        .size());
446:                boolean isAtWD2B1 = false;
447:                boolean isAtWD3B2 = false;
448:                boolean isAtJoin = false;
449:                boolean isAtWD4B3 = false;
450:                for (Iterator iterator = activeNodes.iterator(); iterator
451:                        .hasNext();) {
452:                    RouteNodeInstance nodeInstance = (RouteNodeInstance) iterator
453:                            .next();
454:                    isAtWD2B1 = isAtWD2B1
455:                            || nodeInstance.getName().equals(
456:                                    ParallelSetup.WORKFLOW_DOCUMENT_2_B1_NODE);
457:                    isAtWD3B2 = isAtWD3B2
458:                            || nodeInstance.getName().equals(
459:                                    ParallelSetup.WORKFLOW_DOCUMENT_3_B2_NODE);
460:                    isAtWD4B3 = isAtWD4B3
461:                            || nodeInstance.getName().equals(
462:                                    ParallelSetup.WORKFLOW_DOCUMENT_4_B3_NODE);
463:                    isAtJoin = isAtJoin
464:                            || nodeInstance.getName().equals(
465:                                    ParallelSetup.JOIN_NODE);
466:                }
467:                assertTrue("Should be at blanket approved node WD2B1.",
468:                        isAtWD2B1);
469:                assertTrue("Should be at blanket approved node WD3B2.",
470:                        isAtWD3B2);
471:                assertTrue("Should be at blanket approved node WD4B3.",
472:                        isAtWD4B3);
473:                assertFalse("Should not be at join node.", isAtJoin);
474:
475:                document.blanketApprove("");
476:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
477:                        document.getRouteHeaderId());
478:                assertTrue("Document should be processed.", document
479:                        .stateIsProcessed());
480:                actionRequests = KEWServiceLocator.getActionRequestService()
481:                        .findPendingByDoc(document.getRouteHeaderId());
482:                assertEquals("Wrong number of pending action requests.", 10,
483:                        actionRequests.size());
484:            }
485:
486:            @Test
487:            public void testBlanketApproveToJoin() throws Exception {
488:
489:                WorkflowDocument document = new WorkflowDocument(
490:                        new NetworkIdVO("ewestfal"),
491:                        ParallelSetup.DOCUMENT_TYPE_NAME);
492:                document.blanketApprove("", ParallelSetup.JOIN_NODE);
493:                assertTrue("Document should still be enroute.", document
494:                        .stateIsEnroute());
495:
496:                // document should now be at the workflow document final node
497:                Collection activeNodes = getRouteNodeService()
498:                        .getActiveNodeInstances(document.getRouteHeaderId());
499:                assertEquals("Wrong number of active nodes.", 1, activeNodes
500:                        .size());
501:                RouteNodeInstance nodeInstance = (RouteNodeInstance) activeNodes
502:                        .iterator().next();
503:                assertEquals("Document at wrong node.",
504:                        ParallelSetup.WORKFLOW_DOCUMENT_FINAL_NODE,
505:                        nodeInstance.getName());
506:
507:                document = new WorkflowDocument(new NetworkIdVO("xqi"),
508:                        document.getRouteHeaderId());
509:                assertTrue("Should have approve request.", document
510:                        .isApprovalRequested());
511:                document.blanketApprove("", ParallelSetup.ACKNOWLEDGE_1_NODE);
512:
513:                activeNodes = getRouteNodeService().getActiveNodeInstances(
514:                        document.getRouteHeaderId());
515:                assertEquals("Wrong number of active nodes.", 0, activeNodes
516:                        .size());
517:                Collection terminalNodes = getRouteNodeService()
518:                        .getTerminalNodeInstances(document.getRouteHeaderId());
519:                assertEquals("Wrong number of terminal nodes.", 1,
520:                        terminalNodes.size());
521:                nodeInstance = (RouteNodeInstance) terminalNodes.iterator()
522:                        .next();
523:                assertEquals("Document at wrong node.",
524:                        ParallelSetup.ACKNOWLEDGE_2_NODE, nodeInstance
525:                                .getName());
526:                assertTrue("Final node not complete.", nodeInstance
527:                        .isComplete());
528:            }
529:
530:            @Test
531:            public void testBlanketApproveToAcknowledge() throws Exception {
532:
533:                WorkflowDocument document = new WorkflowDocument(
534:                        new NetworkIdVO("ewestfal"),
535:                        ParallelSetup.DOCUMENT_TYPE_NAME);
536:                document.blanketApprove("", ParallelSetup.ACKNOWLEDGE_1_NODE);
537:                assertTrue("Document should be processed.", document
538:                        .stateIsProcessed());
539:
540:                // document should now be terminal
541:                Collection activeNodes = getRouteNodeService()
542:                        .getActiveNodeInstances(document.getRouteHeaderId());
543:                assertEquals("Wrong number of active nodes.", 0, activeNodes
544:                        .size());
545:                Collection terminalNodes = getRouteNodeService()
546:                        .getTerminalNodeInstances(document.getRouteHeaderId());
547:                assertEquals("Wrong number of terminal nodes.", 1,
548:                        terminalNodes.size());
549:                RouteNodeInstance nodeInstance = (RouteNodeInstance) terminalNodes
550:                        .iterator().next();
551:                assertEquals("Document at wrong node.",
552:                        ParallelSetup.ACKNOWLEDGE_2_NODE, nodeInstance
553:                                .getName());
554:                assertTrue("Final node not complete.", nodeInstance
555:                        .isComplete());
556:            }
557:
558:            @Test
559:            public void testBlanketApproveToMultipleNodesErrors()
560:                    throws Exception {
561:
562:                WorkflowDocument document = new WorkflowDocument(
563:                        new NetworkIdVO("ewestfal"),
564:                        ParallelSetup.DOCUMENT_TYPE_NAME);
565:                try {
566:                    document.blanketApprove("", new String[] {
567:                            ParallelSetup.WORKFLOW_DOCUMENT_2_B1_NODE,
568:                            ParallelSetup.ACKNOWLEDGE_1_NODE });
569:                    fail("document should have thrown exception");
570:                } catch (Exception e) {
571:                    // Shouldn't be able to blanket approve past the join in conjunction with blanket approve within a branch
572:                    TestUtilities.getExceptionThreader().join();
573:                    document = new WorkflowDocument(
574:                            new NetworkIdVO("ewestfal"), document
575:                                    .getRouteHeaderId());
576:                    assertTrue("Document should be in exception routing.",
577:                            document.stateIsException());
578:                }
579:            }
580:
581:            @Ignore("This test needs to be implemented!")
582:            @Test
583:            public void testBlanketApproveCycle() throws Exception {
584:                // TODO it would be cool to get this implemented but right now it looks like we can't quite handle cycles
585:                /*CustomCycleSplit.configureCycle("B1", "B2", 5);
586:                WorkflowDocument document = new WorkflowDocument(new NetworkIdVO("ewestfal"), CycleSetup.DOCUMENT_TYPE_NAME);
587:                document.blanketApprove("");
588:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"), document.getRouteHeaderId());
589:                assertTrue("Document should be processed.", document.stateIsProcessed());
590:                // should have cycled 5 times
591:                assertEquals("Wrong number of cycles.", 5, CustomCycleSplit.getTimesCycled());
592:                
593:                CustomCycleSplit.configureCycle("B1", "B2", 1000);
594:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"), CycleSetup.DOCUMENT_TYPE_NAME);
595:                document.blanketApprove("");
596:                // an exception should have happened in routing
597:                assertTrue("Exception should have happened because of runaway cycle.", TestUtilities.isInExceptionRouting(document.getRouteHeaderId()));*/
598:            }
599:
600:            /**
601:             * Tests that the notifications are generated properly on a blanket approve.  Works against the "NotificationTest" document type.
602:             */
603:            @Test
604:            public void testBlanketApproveNotification() throws Exception {
605:                WorkflowDocument document = new WorkflowDocument(
606:                        new NetworkIdVO("ewestfal"),
607:                        NotifySetup.DOCUMENT_TYPE_NAME);
608:                document.blanketApprove("");
609:                ActionRequestService arService = KEWServiceLocator
610:                        .getActionRequestService();
611:                List actionRequests = arService.getRootRequests(arService
612:                        .findPendingByDoc(document.getRouteHeaderId()));
613:                assertEquals(
614:                        "Should be 5 pending acknowledgements and 1 pending fyi",
615:                        6, actionRequests.size());
616:                boolean foundJhopfNotification = false;
617:                boolean foundRkirkendNotification = false;
618:                boolean foundJitrueNotification = false;
619:                boolean foundBmcgoughNotification = false;
620:                boolean foundXqiAck = false;
621:                boolean foundJthomasFYI = false;
622:                for (Iterator iterator = actionRequests.iterator(); iterator
623:                        .hasNext();) {
624:                    ActionRequestValue actionRequest = (ActionRequestValue) iterator
625:                            .next();
626:                    RouteNodeInstance nodeInstance = actionRequest
627:                            .getNodeInstance();
628:                    String netId = (actionRequest.getWorkflowUser() == null ? null
629:                            : actionRequest.getWorkflowUser()
630:                                    .getAuthenticationUserId().getId());
631:                    if ("jhopf".equals(netId)) {
632:                        foundJhopfNotification = true;
633:                        assertTrue("Action request should be an acknowledge.",
634:                                actionRequest.isAcknowledgeRequest());
635:                        assertEquals(NotifySetup.NOTIFY_FIRST_NODE,
636:                                nodeInstance.getName());
637:                    } else if ("rkirkend".equals(netId)) {
638:                        foundRkirkendNotification = true;
639:                        assertTrue("Action request should be an acknowledge.",
640:                                actionRequest.isAcknowledgeRequest());
641:                        assertEquals(NotifySetup.NOTIFY_LEFT_NODE, nodeInstance
642:                                .getName());
643:                        assertEquals(
644:                                "Rkirkend should have three delegate acks.", 3,
645:                                actionRequest.getChildrenRequests().size());
646:                        assertTrue("Should be primary delegation.",
647:                                actionRequest.isPrimaryDelegator());
648:                        boolean foundTemayDelegate = false;
649:                        boolean foundNonSITWGDelegate = false;
650:                        boolean foundPmckownDelegate = false;
651:                        for (Iterator iterator2 = actionRequest
652:                                .getChildrenRequests().iterator(); iterator2
653:                                .hasNext();) {
654:                            ActionRequestValue childRequest = (ActionRequestValue) iterator2
655:                                    .next();
656:                            assertTrue(
657:                                    "Child request should be an acknowledge.",
658:                                    actionRequest.isAcknowledgeRequest());
659:                            String childId = (childRequest.isWorkgroupRequest() ? childRequest
660:                                    .getWorkgroup().getGroupNameId()
661:                                    .getNameId()
662:                                    : childRequest.getWorkflowUser()
663:                                            .getAuthenticationUserId().getId());
664:                            if ("temay".equals(childId)) {
665:                                foundTemayDelegate = true;
666:                                assertEquals("Should be primary delegation.",
667:                                        EdenConstants.DELEGATION_PRIMARY,
668:                                        childRequest.getDelegationType());
669:                            } else if ("pmckown".equals(childId)) {
670:                                foundPmckownDelegate = true;
671:                                assertEquals("Should be secondary delegation.",
672:                                        EdenConstants.DELEGATION_SECONDARY,
673:                                        childRequest.getDelegationType());
674:                            } else if ("NonSIT".equals(childId)) {
675:                                foundNonSITWGDelegate = true;
676:                                assertEquals("Should be primary delegation.",
677:                                        EdenConstants.DELEGATION_PRIMARY,
678:                                        childRequest.getDelegationType());
679:                            }
680:                        }
681:                        assertTrue(
682:                                "Could not locate delegate request for temay.",
683:                                foundTemayDelegate);
684:                        assertTrue(
685:                                "Could not locate delegate request for NonSIT Workgroup.",
686:                                foundNonSITWGDelegate);
687:                        assertTrue(
688:                                "Could not locate delegate request for pmckown.",
689:                                foundPmckownDelegate);
690:                    } else if ("bmcgough".equals(netId)) {
691:                        foundBmcgoughNotification = true;
692:                        assertTrue("Action request should be an acknowledge.",
693:                                actionRequest.isAcknowledgeRequest());
694:                        assertEquals(NotifySetup.NOTIFY_FINAL_NODE,
695:                                nodeInstance.getName());
696:
697:                    } else if ("xqi".equals(netId)) {
698:                        foundXqiAck = true;
699:                        assertTrue("Action request should be an acknowledge.",
700:                                actionRequest.isAcknowledgeRequest());
701:                        assertEquals(NotifySetup.NOTIFY_FINAL_NODE,
702:                                nodeInstance.getName());
703:
704:                    } else if ("jthomas".equals(netId)) {
705:                        foundJthomasFYI = true;
706:                        assertTrue("Action request should be an FYI.",
707:                                actionRequest.isFYIRequest());
708:                        assertEquals(NotifySetup.NOTIFY_FINAL_NODE,
709:                                nodeInstance.getName());
710:                    } else if (actionRequest.isRoleRequest()) {
711:                        List topLevelRequests = arService
712:                                .getTopLevelRequests(actionRequest);
713:                        assertEquals(1, topLevelRequests.size());
714:                        actionRequest = (ActionRequestValue) topLevelRequests
715:                                .get(0);
716:                        // this tests the notofication of the role to jitrue with delegates
717:                        assertEquals("Should be to jitrue.", "jitrue",
718:                                actionRequest.getWorkflowUser()
719:                                        .getAuthenticationUserId().getId());
720:                        foundJitrueNotification = true;
721:                        List delegateRoleRequests = arService
722:                                .getDelegateRequests(actionRequest);
723:                        assertEquals("Should be 1 delegate role requests", 1,
724:                                delegateRoleRequests.size());
725:                        ActionRequestValue delegateRoleRequest = (ActionRequestValue) delegateRoleRequests
726:                                .get(0);
727:                        assertEquals("Should be NotifyDelegate role",
728:                                "NotifyDelegate", delegateRoleRequest
729:                                        .getRoleName());
730:                        assertEquals("Should be secondary delegation",
731:                                EdenConstants.DELEGATION_SECONDARY,
732:                                delegateRoleRequest.getDelegationType());
733:                        List delegateRequests = arService
734:                                .getTopLevelRequests(delegateRoleRequest);
735:                        assertEquals("Should be 2 delegate requests", 2,
736:                                delegateRequests.size());
737:                        boolean foundNatjohnsDelegate = false;
738:                        boolean foundShenlDelegate = false;
739:                        for (Iterator iterator2 = delegateRequests.iterator(); iterator2
740:                                .hasNext();) {
741:                            ActionRequestValue delegateRequest = (ActionRequestValue) iterator2
742:                                    .next();
743:                            String delNetId = delegateRequest.getWorkflowUser()
744:                                    .getAuthenticationUserId().getId();
745:                            if ("natjohns".equals(delNetId)) {
746:                                foundNatjohnsDelegate = true;
747:                            } else if ("shenl".equals(delNetId)) {
748:                                foundShenlDelegate = true;
749:                            }
750:                        }
751:                        assertTrue(
752:                                "Could not locate natjohns role delegate request.",
753:                                foundNatjohnsDelegate);
754:                        assertTrue(
755:                                "Could not locate shenl role delegate request.",
756:                                foundShenlDelegate);
757:                    }
758:                }
759:                assertTrue("Could not locate notification for jhopf.",
760:                        foundJhopfNotification);
761:                assertTrue("Could not locate notification for rkirkend.",
762:                        foundRkirkendNotification);
763:                assertTrue("Could not locate notification for bmcgough.",
764:                        foundBmcgoughNotification);
765:                assertTrue("Could not locate acknowledgment for xqi.",
766:                        foundXqiAck);
767:                assertTrue("Could not locate FYI for jthomas.", foundJthomasFYI);
768:                assertTrue("Could not locate notification for jitrue.",
769:                        foundJitrueNotification);
770:            }
771:
772:            /**
773:             * Tests that we can blanket approve past mandatory route nodes.
774:             * Addresses issue http://fms.dfa.cornell.edu:8080/browse/KULWF-461
775:             */
776:            @Test
777:            public void testBlanketApprovePastMandatoryNode() throws Exception {
778:                WorkflowDocument document = new WorkflowDocument(
779:                        new NetworkIdVO("ewestfal"),
780:                        "BlanketApproveMandatoryNodeTest");
781:                document.blanketApprove("");
782:                assertTrue("Document should be processed.", document
783:                        .stateIsProcessed());
784:            }
785:
786:            /**
787:             * Tests the behavior of blanket approve through a role node and then through a node with a Workgroup including
788:             * the individual(s) in the role.  Verifies that the Action List contains the proper entries in this case.
789:             */
790:            @Test
791:            public void testBlanketApproveThroughRoleAndWorkgroup()
792:                    throws Exception {
793:                NetworkIdVO jitrue = new NetworkIdVO("jitrue");
794:                WorkflowDocument document = new WorkflowDocument(
795:                        new NetworkIdVO("user1"),
796:                        "BlanketApproveThroughRoleAndWorkgroupTest");
797:                document.saveDocument("");
798:                assertTrue(document.stateIsSaved());
799:                TestUtilities.assertNotInActionList(jitrue, document
800:                        .getRouteHeaderId());
801:                document.blanketApprove("");
802:
803:                // document should now be processed
804:                document = new WorkflowDocument(jitrue, document
805:                        .getRouteHeaderId());
806:                assertTrue(document.stateIsProcessed());
807:                assertTrue(document.isAcknowledgeRequested());
808:
809:                // there should be 3 root acknowledge requests, one to the WorkflowAdmin workgroup, one to jitrue in the Notify role and one to jitrue in the Notify2 role
810:                List actionRequests = KEWServiceLocator
811:                        .getActionRequestService()
812:                        .findPendingRootRequestsByDocId(
813:                                document.getRouteHeaderId());
814:                assertEquals("There should be 3 root requests.", 3,
815:                        actionRequests.size());
816:
817:                // now check that the document is in jitrue's action list
818:                TestUtilities.assertInActionList(jitrue, document
819:                        .getRouteHeaderId());
820:
821:                // acknowledge as a member of the workgroup who is not jitrue
822:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
823:                        document.getRouteHeaderId());
824:                assertTrue(document.isAcknowledgeRequested());
825:                document.acknowledge("");
826:
827:                // document should still be processed
828:                document = new WorkflowDocument(jitrue, document
829:                        .getRouteHeaderId());
830:                assertTrue(document.stateIsProcessed());
831:                assertTrue(document.isAcknowledgeRequested());
832:
833:                // there should now be 2 root acknowledge requests, one to jitrue in the Notify role and one to jitrue in the Notify2 role
834:                actionRequests = KEWServiceLocator.getActionRequestService()
835:                        .findPendingRootRequestsByDocId(
836:                                document.getRouteHeaderId());
837:                assertEquals("There should be 2 root requests.", 2,
838:                        actionRequests.size());
839:
840:                // jitrue should still have this in his action list
841:                TestUtilities.assertInActionList(jitrue, document
842:                        .getRouteHeaderId());
843:                document.acknowledge("");
844:
845:                // document should now be final
846:                assertTrue(document.stateIsFinal());
847:            }
848:
849:            private RouteNodeService getRouteNodeService() {
850:                return KEWServiceLocator.getRouteNodeService();
851:            }
852:
853:            private class SequentialSetup {
854:
855:                public static final String DOCUMENT_TYPE_NAME = "BlanketApproveSequentialTest";
856:                public static final String ADHOC_NODE = "AdHoc";
857:                public static final String WORKFLOW_DOCUMENT_NODE = "WorkflowDocument";
858:                public static final String WORKFLOW_DOCUMENT_2_NODE = "WorkflowDocument2";
859:                public static final String ACKNOWLEDGE_1_NODE = "Acknowledge1";
860:                public static final String ACKNOWLEDGE_2_NODE = "Acknowledge2";
861:
862:            }
863:
864:            private class ParallelSetup {
865:
866:                public static final String DOCUMENT_TYPE_NAME = "BlanketApproveParallelTest";
867:                public static final String ADHOC_NODE = "AdHoc";
868:                public static final String WORKFLOW_DOCUMENT_NODE = "WorkflowDocument";
869:                public static final String WORKFLOW_DOCUMENT_2_B1_NODE = "WorkflowDocument2-B1";
870:                public static final String WORKFLOW_DOCUMENT_2_B2_NODE = "WorkflowDocument2-B2";
871:                public static final String WORKFLOW_DOCUMENT_3_B1_NODE = "WorkflowDocument3-B1";
872:                public static final String WORKFLOW_DOCUMENT_3_B2_NODE = "WorkflowDocument3-B2";
873:                public static final String WORKFLOW_DOCUMENT_4_B3_NODE = "WorkflowDocument4-B3";
874:                public static final String ACKNOWLEDGE_1_NODE = "Acknowledge1";
875:                public static final String ACKNOWLEDGE_2_NODE = "Acknowledge2";
876:                public static final String JOIN_NODE = "Join";
877:                public static final String SPLIT_NODE = "Split";
878:                public static final String WORKFLOW_DOCUMENT_FINAL_NODE = "WorkflowDocumentFinal";
879:
880:            }
881:
882:            /*private class CycleSetup {
883:
884:                public static final String DOCUMENT_TYPE_NAME = "BlanketApproveCycleTest";
885:                public static final String ADHOC_NODE = "AdHoc";
886:                public static final String WORKFLOW_DOCUMENT_NODE = "WorkflowDocument";
887:                public static final String WORKFLOW_DOCUMENT_2_NODE = "WorkflowDocument2";
888:                public static final String WORKFLOW_DOCUMENT_FINAL_NODE = "WorkflowDocumentFinal";
889:                public static final String JOIN_NODE = "Join";
890:                public static final String CUSTOM_CYCLE_SPLIT_NODE = "CustomCycleSplit";
891:                
892:            }*/
893:
894:            public static class NotifySetup {
895:
896:                public static final String DOCUMENT_TYPE_NAME = "NotificationTest";
897:                public static final String ADHOC_NODE = "AdHoc";
898:                public static final String NOTIFY_FIRST_NODE = "NotifyFirst";
899:                public static final String NOTIFY_LEFT_NODE = "NotifyLeftBranch";
900:                public static final String NOTIFY_RIGHT_NODE = "NotifyRightBranch";
901:                public static final String NOTIFY_FINAL_NODE = "NotifyFinal";
902:                public static final String SPLIT_NODE = "Split";
903:                public static final String JOIN_NODE = "Join";
904:
905:            }
906:
907:            private MockEmailNotificationService getMockEmailService() {
908:                return (MockEmailNotificationService) KEWServiceLocator
909:                        .getActionListEmailService();
910:            }
911:
912:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.