Source Code Cross Referenced for SimpleDocumentActionsWebServiceTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » server » 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.server 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 2005-2007 The Kuali Foundation.
0003:         *
0004:         *
0005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
0006:         * you may not use this file except in compliance with the License.
0007:         * You may obtain a copy of the License at
0008:         *
0009:         * http://www.opensource.org/licenses/ecl1.php
0010:         *
0011:         * Unless required by applicable law or agreed to in writing, software
0012:         * distributed under the License is distributed on an "AS IS" BASIS,
0013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         * See the License for the specific language governing permissions and
0015:         * limitations under the License.
0016:         */
0017:        package edu.iu.uis.eden.server;
0018:
0019:        import java.net.URL;
0020:        import java.util.List;
0021:        import java.util.Map;
0022:
0023:        import javax.xml.namespace.QName;
0024:
0025:        import org.apache.commons.httpclient.URI;
0026:        import org.apache.commons.httpclient.URIException;
0027:        import org.apache.commons.lang.StringUtils;
0028:        import org.codehaus.xfire.MessageContext;
0029:        import org.codehaus.xfire.aegis.AegisBindingProvider;
0030:        import org.codehaus.xfire.client.Client;
0031:        import org.codehaus.xfire.client.XFireProxyFactory;
0032:        import org.codehaus.xfire.exchange.OutMessage;
0033:        import org.codehaus.xfire.service.Service;
0034:        import org.codehaus.xfire.service.binding.ObjectServiceFactory;
0035:        import org.codehaus.xfire.transport.http.AbstractMessageSender;
0036:        import org.codehaus.xfire.transport.http.CommonsHttpMessageSender;
0037:        import org.codehaus.xfire.util.LoggingHandler;
0038:        import org.codehaus.xfire.util.dom.DOMInHandler;
0039:        import org.codehaus.xfire.util.dom.DOMOutHandler;
0040:        import org.junit.Test;
0041:        import org.kuali.bus.services.KSBServiceLocator;
0042:        import org.kuali.workflow.test.WorkflowTestCase;
0043:
0044:        import edu.iu.uis.eden.EdenConstants;
0045:        import edu.iu.uis.eden.clientapp.WorkflowDocument;
0046:        import edu.iu.uis.eden.clientapp.vo.ActionRequestVO;
0047:        import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
0048:        import edu.iu.uis.eden.clientapp.vo.RouteHeaderVO;
0049:        import edu.iu.uis.eden.clientapp.vo.UserIdVO;
0050:        import edu.iu.uis.eden.exception.WorkflowException;
0051:        import edu.iu.uis.eden.messaging.RemotedServiceHolder;
0052:        import edu.iu.uis.eden.server.SimpleDocumentActionsWebService.DocumentResponse;
0053:        import edu.iu.uis.eden.server.SimpleDocumentActionsWebService.ErrorResponse;
0054:        import edu.iu.uis.eden.server.SimpleDocumentActionsWebService.NoteDetail;
0055:        import edu.iu.uis.eden.server.SimpleDocumentActionsWebService.NoteResponse;
0056:        import edu.iu.uis.eden.server.SimpleDocumentActionsWebService.StandardResponse;
0057:        import edu.iu.uis.eden.server.SimpleDocumentActionsWebService.UserInRouteLogResponse;
0058:
0059:        /**
0060:         * Tests SimpleDocumentActionsWebService
0061:         * @author ewestfal
0062:         */
0063:        public class SimpleDocumentActionsWebServiceTest extends
0064:                WorkflowTestCase {
0065:
0066:            private static final String WSDL_URL1 = "http://localhost:9912/en-test/remoting/{KEW}simpleDocumentActionsService?wsdl";
0067:
0068:            private static final String WSDL_URL2 = "http://localhost:9912/en-test/wsdl/{KEW}simpleDocumentActionsService.wsdl";
0069:
0070:            private static final String ENDPOINT_URL = "http://localhost:9912/en-test/remoting/{KEW}simpleDocumentActionsService";
0071:
0072:            private SimpleDocumentActionsWebService service;
0073:
0074:            @Override
0075:            protected void setUpTransaction() throws Exception {
0076:                super .setUpTransaction();
0077:                // turn off bus security for the service
0078:                RemotedServiceHolder holder = KSBServiceLocator
0079:                        .getServiceDeployer()
0080:                        .getRemotedServiceHolder(
0081:                                new QName("KEW", "simpleDocumentActionsService"));
0082:                holder.getServiceInfo().getServiceDefinition().setBusSecurity(
0083:                        false);
0084:                ((Runnable) KSBServiceLocator.getServiceDeployer()).run();
0085:
0086:                service = createStaticBindingService();
0087:            }
0088:
0089:            protected void loadTestData() throws Exception {
0090:                loadXmlFile("SimpleDocumentActionsConfig.xml");
0091:            }
0092:
0093:            @Test
0094:            public void testWsdlGeneration() throws Exception {
0095:
0096:                Client client = new Client(new URL(WSDL_URL1));
0097:                client.setProperty(
0098:                        AbstractMessageSender.MESSAGE_SENDER_CLASS_NAME,
0099:                        EncodedCommonsHttpMessageSender.class.getName());
0100:                client.addInHandler(new DOMInHandler());
0101:                client.addInHandler(new LoggingHandler());
0102:
0103:                client.addOutHandler(new DOMOutHandler());
0104:                client.addOutHandler(new LoggingHandler());
0105:                Object[] results = client.invoke("create", new Object[] {
0106:                        "ewestfal", "123", "TestDocumentType",
0107:                        "Testing create via webservices" });
0108:                assertNotNull(results);
0109:                assertTrue(results.length > 0);
0110:
0111:                // do it again, this time with the other wsdl
0112:                client = new Client(new URL(WSDL_URL2));
0113:                client.setProperty(
0114:                        AbstractMessageSender.MESSAGE_SENDER_CLASS_NAME,
0115:                        EncodedCommonsHttpMessageSender.class.getName());
0116:                client.addInHandler(new DOMInHandler());
0117:                client.addInHandler(new LoggingHandler());
0118:
0119:                client.addOutHandler(new DOMOutHandler());
0120:                client.addOutHandler(new LoggingHandler());
0121:                results = client.invoke("create", new Object[] { "ewestfal",
0122:                        "123", "TestDocumentType",
0123:                        "Testing create via webservices" });
0124:                assertNotNull(results);
0125:                assertTrue(results.length > 0);
0126:
0127:            }
0128:
0129:            private static final String TEST_USER_DISPLAY_NAME = "User One";
0130:            private static final String TEST_USER = "user1";
0131:            private static final String TEST_USER2 = "ewestfal";
0132:            private static final String TEST_FYI_USER = "user2";
0133:            private static final String TEST_ADHOC_USER = "user2";
0134:            private static final String TEST_ADHOC_GROUP = "TestAdhocWorkgroup";
0135:            private static final String TEST_DOC_TYPE = "servicesTestRequest";
0136:            private static final String TEST_TITLE = "Test Doc";
0137:            private static final String TEST_NOTE_TEXT = "This is a test note.";
0138:            private static final String TEST_NOTE_TEXT2 = "This is an updated test note.";
0139:
0140:            protected static ActionRequestVO actionHasBeenRequested(
0141:                    ActionRequestVO[] actionsRequested, String recipient,
0142:                    String action) {
0143:                for (ActionRequestVO actionRequested : actionsRequested) {
0144:                    if (recipient != null) {
0145:                        if (actionRequested.getUserVO() != null) {
0146:                            if (!recipient.equals(actionRequested.getUserVO()
0147:                                    .getNetworkId()))
0148:                                continue;
0149:                        } else if (actionRequested.getWorkgroupVO() != null) {
0150:                            if (!recipient.equals(actionRequested
0151:                                    .getWorkgroupVO().getWorkgroupName()))
0152:                                continue;
0153:                        } else {
0154:                            throw new RuntimeException(
0155:                                    "Action request not sent to user or workgroup");
0156:                        }
0157:                    }
0158:                    if (action != null) {
0159:                        if (!action
0160:                                .equals(actionRequested.getActionRequested()))
0161:                            continue;
0162:                    }
0163:                    return actionRequested;
0164:                }
0165:                return null;
0166:            }
0167:
0168:            /**
0169:             * Tests passing an empty string parameter
0170:             */
0171:            @Test
0172:            public void testEmptyStringParameter() throws WorkflowException,
0173:                    InterruptedException {
0174:                DocumentResponse results = service.create(TEST_USER, "",
0175:                        TEST_DOC_TYPE, TEST_TITLE);
0176:                assertEquals(EdenConstants.ROUTE_HEADER_INITIATED_CD, results
0177:                        .getDocStatus());
0178:            }
0179:
0180:            /**
0181:             * Tests passing a null string parameter
0182:             */
0183:            @Test
0184:            public void testNullStringParameter() throws WorkflowException,
0185:                    InterruptedException {
0186:                DocumentResponse results = service.create(TEST_USER, null,
0187:                        TEST_DOC_TYPE, TEST_TITLE);
0188:                assertEquals(EdenConstants.ROUTE_HEADER_INITIATED_CD, results
0189:                        .getDocStatus());
0190:            }
0191:
0192:            /**
0193:             * Test method for
0194:             * {@link edu.cornell.kew.service.impl.serviceImpl#acknowledge(java.lang.String, java.lang.String, java.lang.String)}.
0195:             *
0196:             * @throws WorkflowException
0197:             * @throws InterruptedException
0198:             */
0199:            @Test
0200:            public void testAcknowledge() throws WorkflowException,
0201:                    InterruptedException {
0202:                final int EXPECTED_RESULT_FIELDS = 8;
0203:
0204:                RouteHeaderVO routeHeader = createTestDoc();
0205:                routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
0206:
0207:                approveTestDoc(routeHeader.getRouteHeaderId(), "test approve");
0208:
0209:                StandardResponse results = service.acknowledge(routeHeader
0210:                        .getRouteHeaderId().toString(), TEST_USER,
0211:                        "test acknowledge");
0212:
0213:                //assertEquals("There should be " + EXPECTED_RESULT_FIELDS + " elements in the result return set.", EXPECTED_RESULT_FIELDS, results.size());
0214:                assertEquals(
0215:                        "There shouldn't be an error message if things went well.",
0216:                        "", results.getErrorMessage());
0217:                assertEquals("The document should be in FINAL status",
0218:                        EdenConstants.ROUTE_HEADER_FINAL_CD, (String) results
0219:                                .getDocStatus());
0220:                // TODO: better date test
0221:                assertTrue("createDate should not be empty", StringUtils
0222:                        .isNotEmpty((String) results.getCreateDate()));
0223:                assertEquals("We were expecting the initiator to be "
0224:                        + TEST_USER, TEST_USER, (String) results
0225:                        .getInitiatorId());
0226:                assertEquals("We aren't using appDocId so it should be empty",
0227:                        "", (String) results.getAppDocId());
0228:                assertEquals("We were expecting the initiator name to be "
0229:                        + TEST_USER_DISPLAY_NAME, TEST_USER_DISPLAY_NAME,
0230:                        (String) results.getInitiatorName());
0231:
0232:                Long docId = routeHeader.getRouteHeaderId();
0233:                routeHeader = getTestDoc(docId.longValue());
0234:                assertEquals("The docTitle should be " + TEST_TITLE,
0235:                        TEST_TITLE, routeHeader.getDocTitle());
0236:                assertEquals("The docRouteStatus should be F)inal ",
0237:                        EdenConstants.ROUTE_HEADER_FINAL_CD, routeHeader
0238:                                .getDocRouteStatus());
0239:                // TODO: better date test
0240:                assertNotNull("dateCreated should NOT be null", routeHeader
0241:                        .getDateCreated());
0242:                assertEquals("We were expecting the initiator to be "
0243:                        + TEST_USER, TEST_USER, routeHeader.getInitiator()
0244:                        .getNetworkId());
0245:                assertEquals("We were expecting the initiator name to be "
0246:                        + TEST_USER_DISPLAY_NAME, TEST_USER_DISPLAY_NAME,
0247:                        routeHeader.getInitiator().getDisplayName());
0248:                assertNull("We aren't using appDocId so it should be null",
0249:                        routeHeader.getAppDocId());
0250:                assertTrue(
0251:                        "The last modified date should be after the create date",
0252:                        routeHeader.getDateLastModified().after(
0253:                                routeHeader.getDateCreated()));
0254:
0255:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
0256:                WorkflowDocument workflowDocument = new WorkflowDocument(
0257:                        userIdVO, docId);
0258:                ActionRequestVO[] actionRequests = workflowDocument
0259:                        .getActionRequests();
0260:                assertNotNull("We should have some action requests",
0261:                        actionRequests);
0262:                assertEquals("There should be 3 action requests", 3,
0263:                        actionRequests.length);
0264:                assertNotNull(actionHasBeenRequested(actionRequests, TEST_USER,
0265:                        "A"));
0266:                assertNotNull(actionHasBeenRequested(actionRequests, TEST_USER,
0267:                        "K"));
0268:                assertNotNull(actionHasBeenRequested(actionRequests,
0269:                        TEST_FYI_USER, "F"));
0270:                ActionRequestVO actionRequest = actionHasBeenRequested(
0271:                        actionRequests, TEST_USER, "A");
0272:                assertEquals("A", actionRequest.getActionRequested());
0273:                assertNull("We didn't send an annotation so it should be null",
0274:                        actionRequest.getAnnotation());
0275:                assertEquals(TEST_USER, actionRequest.getUserVO()
0276:                        .getNetworkId());
0277:                assertTrue("This should be an approval request", actionRequest
0278:                        .isApprovalRequest());
0279:                assertTrue("The action request should have been done",
0280:                        actionRequest.isDone());
0281:                assertEquals("A", actionRequest.getActionTaken()
0282:                        .getActionTaken());
0283:                actionRequest = actionHasBeenRequested(actionRequests,
0284:                        TEST_USER, "K");
0285:                assertEquals("K", actionRequest.getActionRequested());
0286:                assertNull("We didn't send an annotation so it should be null",
0287:                        actionRequest.getAnnotation());
0288:                assertEquals(TEST_USER, actionRequest.getUserVO()
0289:                        .getNetworkId());
0290:                assertTrue("This should be an acknowledge request",
0291:                        actionRequest.isAcknowledgeRequest());
0292:                assertTrue("The action request should have been done",
0293:                        actionRequest.isDone());
0294:                actionRequest = actionHasBeenRequested(actionRequests,
0295:                        TEST_FYI_USER, "F");
0296:                assertEquals("F", actionRequest.getActionRequested());
0297:                assertNull("We didn't send an annotation so it should be null",
0298:                        actionRequest.getAnnotation());
0299:                assertEquals(TEST_FYI_USER, actionRequest.getUserVO()
0300:                        .getNetworkId());
0301:                assertFalse("The action request should have been done",
0302:                        actionRequest.isDone());
0303:
0304:                // let's cleanup shall we
0305:                deleteTestDoc(docId.longValue());
0306:            }
0307:
0308:            /**
0309:             * Test method for
0310:             * {@link edu.cornell.kew.service.impl.serviceImpl#approve(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
0311:             *
0312:             * @throws WorkflowException
0313:             * @throws InterruptedException
0314:             */
0315:            @Test
0316:            public void testApprove() throws WorkflowException,
0317:                    InterruptedException {
0318:
0319:                RouteHeaderVO routeHeader = createTestDoc();
0320:                routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
0321:
0322:                StandardResponse results = service.approve(routeHeader
0323:                        .getRouteHeaderId().toString(), TEST_USER, TEST_TITLE,
0324:                        "<key>value</key>", "test approve");
0325:
0326:                //assertEquals("We are expecting six entries in the result Map", 6, results.size());
0327:                assertEquals(EdenConstants.ROUTE_HEADER_PROCESSED_CD,
0328:                        (String) results.getDocStatus());
0329:                // TODO: better date test
0330:                assertTrue("Create date shouldn't be null", StringUtils
0331:                        .isNotEmpty((String) results.getCreateDate()));
0332:                assertEquals(TEST_USER, (String) results.getInitiatorId());
0333:                assertEquals("", (String) results.getAppDocId());
0334:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
0335:                        .getInitiatorName());
0336:                assertEquals(
0337:                        "There shouldn't be an error message if things went well.",
0338:                        "", (String) results.getErrorMessage());
0339:
0340:                Long docId = routeHeader.getRouteHeaderId();
0341:                routeHeader = getTestDoc(docId.longValue());
0342:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
0343:                assertEquals("P", routeHeader.getDocRouteStatus());
0344:                // TODO: better date test
0345:                assertNotNull("dateCreated should NOT be null", routeHeader
0346:                        .getDateCreated());
0347:                assertEquals(TEST_USER, routeHeader.getInitiator()
0348:                        .getNetworkId());
0349:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
0350:                        .getDisplayName());
0351:                assertNull("AppDocId should be null since we're not using it.",
0352:                        routeHeader.getAppDocId());
0353:                assertTrue("dateLastModified should be after dateCreated",
0354:                        routeHeader.getDateLastModified().after(
0355:                                routeHeader.getDateCreated()));
0356:
0357:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
0358:                WorkflowDocument workflowDocument = new WorkflowDocument(
0359:                        userIdVO, docId);
0360:                ActionRequestVO[] actionRequests = workflowDocument
0361:                        .getActionRequests();
0362:                assertNotNull("We should have some action requests",
0363:                        actionRequests);
0364:                assertEquals(3, actionRequests.length);
0365:                ActionRequestVO actionRequest = actionHasBeenRequested(
0366:                        actionRequests, TEST_USER, "A");
0367:                assertEquals("A", actionRequest.getActionRequested());
0368:                assertNull("Annotation should be null since we didn't set it",
0369:                        actionRequest.getAnnotation());
0370:                assertEquals(TEST_USER, actionRequest.getUserVO()
0371:                        .getNetworkId());
0372:                assertTrue("Should be an approval request", actionRequest
0373:                        .isApprovalRequest());
0374:                assertTrue("ActionRequest should be Done", actionRequest
0375:                        .isDone());
0376:                assertEquals("A", actionRequest.getActionTaken()
0377:                        .getActionTaken());
0378:                actionRequest = actionHasBeenRequested(actionRequests,
0379:                        TEST_USER, "K");
0380:                assertEquals("K", actionRequest.getActionRequested());
0381:                assertNull("Annotation should be null since we didn't set it",
0382:                        actionRequest.getAnnotation());
0383:                assertEquals(TEST_USER, actionRequest.getUserVO()
0384:                        .getNetworkId());
0385:                assertTrue("Should be an Acknowledge Request", actionRequest
0386:                        .isAcknowledgeRequest());
0387:                assertFalse("Should NOT be Done", actionRequest.isDone());
0388:                actionRequest = actionHasBeenRequested(actionRequests,
0389:                        TEST_FYI_USER, "F");
0390:                assertEquals("F", actionRequest.getActionRequested());
0391:                assertNull("Annotation should be null since we didn't set it",
0392:                        actionRequest.getAnnotation());
0393:                assertEquals(TEST_FYI_USER, actionRequest.getUserVO()
0394:                        .getNetworkId());
0395:                assertFalse("Should NOT be Done", actionRequest.isDone());
0396:
0397:                // let's cleanup shall we
0398:                deleteTestDoc(docId.longValue());
0399:            }
0400:
0401:            /**
0402:             * Test method for
0403:             * {@link edu.cornell.kew.service.impl.serviceImpl#blanketApprove(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
0404:             *
0405:             * @throws WorkflowException
0406:             * @throws InterruptedException
0407:             */
0408:            @Test
0409:            public void testBlanketApprove() throws WorkflowException,
0410:                    InterruptedException {
0411:
0412:                RouteHeaderVO routeHeader = createTestDoc();
0413:                routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
0414:
0415:                StandardResponse results = service.blanketApprove(routeHeader
0416:                        .getRouteHeaderId().toString(), TEST_USER, TEST_TITLE,
0417:                        "<key>value</key>", "test blanket approve");
0418:
0419:                //assertEquals(6, results.size());
0420:                assertEquals("", (String) results.getErrorMessage());
0421:                assertEquals(EdenConstants.ROUTE_HEADER_PROCESSED_CD,
0422:                        (String) results.getDocStatus());
0423:                // TODO: better date test
0424:                assertTrue("createDate should not be empty", StringUtils
0425:                        .isNotEmpty((String) results.getCreateDate()));
0426:                assertEquals(TEST_USER, (String) results.getInitiatorId());
0427:                assertEquals("", (String) results.getAppDocId());
0428:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
0429:                        .getInitiatorName());
0430:
0431:                Long docId = routeHeader.getRouteHeaderId();
0432:                routeHeader = getTestDoc(docId.longValue());
0433:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
0434:                assertEquals("P", routeHeader.getDocRouteStatus());
0435:                // TODO: better date test
0436:                assertNotNull("dateCreated should NOT be null", routeHeader
0437:                        .getDateCreated());
0438:                assertEquals(TEST_USER, routeHeader.getInitiator()
0439:                        .getNetworkId());
0440:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
0441:                        .getDisplayName());
0442:                assertNull("We aren't using appDocId so it should be null",
0443:                        routeHeader.getAppDocId());
0444:                assertTrue("lastModifiedDate should be after createDate",
0445:                        routeHeader.getDateLastModified().after(
0446:                                routeHeader.getDateCreated()));
0447:
0448:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
0449:                WorkflowDocument workflowDocument = new WorkflowDocument(
0450:                        userIdVO, docId);
0451:                ActionRequestVO[] actionRequests = workflowDocument
0452:                        .getActionRequests();
0453:                assertNotNull("We should have some action requests",
0454:                        actionRequests);
0455:                assertEquals(3, actionRequests.length);
0456:                ActionRequestVO actionRequest = actionHasBeenRequested(
0457:                        actionRequests, TEST_USER, "A");
0458:                assertEquals("A", actionRequest.getActionRequested());
0459:                assertNull("Annotation should be null since we didn't set it",
0460:                        actionRequest.getAnnotation());
0461:                assertEquals(TEST_USER, actionRequest.getUserVO()
0462:                        .getNetworkId());
0463:                assertTrue("Should be an Approval Request", actionRequest
0464:                        .isApprovalRequest());
0465:                assertTrue("ActionRequest should be Done", actionRequest
0466:                        .isDone());
0467:                assertEquals("B", actionRequest.getActionTaken()
0468:                        .getActionTaken());
0469:                actionRequest = actionHasBeenRequested(actionRequests,
0470:                        TEST_USER, "K");
0471:                assertEquals("K", actionRequest.getActionRequested());
0472:                assertNull("Annotation should be null since we didn't set it",
0473:                        actionRequest.getAnnotation());
0474:                assertEquals(TEST_USER, actionRequest.getUserVO()
0475:                        .getNetworkId());
0476:                assertTrue("Should be an Acknowledge Request", actionRequest
0477:                        .isAcknowledgeRequest());
0478:                assertFalse("Should NOT be Done", actionRequest.isDone());
0479:                actionRequest = actionHasBeenRequested(actionRequests,
0480:                        TEST_FYI_USER, "F");
0481:                assertEquals("F", actionRequest.getActionRequested());
0482:                assertNull("Annotation should be null since we didn't set it",
0483:                        actionRequest.getAnnotation());
0484:                assertEquals(TEST_FYI_USER, actionRequest.getUserVO()
0485:                        .getNetworkId());
0486:                assertFalse("Should NOT be Done", actionRequest.isDone());
0487:
0488:                // let's cleanup shall we
0489:                deleteTestDoc(docId.longValue());
0490:            }
0491:
0492:            /**
0493:             * Test method for
0494:             * {@link edu.cornell.kew.service.impl.serviceImpl#cancel(java.lang.String, java.lang.String, java.lang.String)}.
0495:             *
0496:             * @throws WorkflowException
0497:             * @throws InterruptedException
0498:             */
0499:            @Test
0500:            public void testCancel() throws WorkflowException,
0501:                    InterruptedException {
0502:
0503:                RouteHeaderVO routeHeader = createTestDoc();
0504:
0505:                StandardResponse results = service.cancel(routeHeader
0506:                        .getRouteHeaderId().toString(), TEST_USER,
0507:                        "test cancel");
0508:
0509:                //assertEquals(6, results.size());
0510:                assertEquals(EdenConstants.ROUTE_HEADER_CANCEL_CD,
0511:                        (String) results.getDocStatus());
0512:                // TODO: better date test
0513:                assertTrue("createDate should not be empty", StringUtils
0514:                        .isNotEmpty((String) results.getCreateDate()));
0515:                assertEquals(TEST_USER, (String) results.getInitiatorId());
0516:                assertEquals("", (String) results.getAppDocId());
0517:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
0518:                        .getInitiatorName());
0519:                assertEquals("", (String) results.getErrorMessage());
0520:
0521:                Long docId = routeHeader.getRouteHeaderId();
0522:                routeHeader = getTestDoc(docId.longValue());
0523:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
0524:                assertEquals("X", routeHeader.getDocRouteStatus());
0525:                // TODO: better date test
0526:                assertNotNull("dateCreated should NOT be null", routeHeader
0527:                        .getDateCreated());
0528:                assertEquals(TEST_USER, routeHeader.getInitiator()
0529:                        .getNetworkId());
0530:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
0531:                        .getDisplayName());
0532:                assertNull("We aren't using appDocId so it should be null",
0533:                        routeHeader.getAppDocId());
0534:                assertTrue("dateLastModified should be after createDate",
0535:                        routeHeader.getDateLastModified().compareTo(
0536:                                routeHeader.getDateCreated()) >= 0);
0537:
0538:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
0539:                WorkflowDocument workflowDocument = new WorkflowDocument(
0540:                        userIdVO, docId);
0541:                ActionRequestVO[] actionRequests = workflowDocument
0542:                        .getActionRequests();
0543:                assertNotNull("We should have some action requests",
0544:                        actionRequests);
0545:
0546:                assertEquals(0, actionRequests.length);
0547:
0548:                // let's cleanup shall we
0549:                deleteTestDoc(docId.longValue());
0550:            }
0551:
0552:            /**
0553:             * Test method for
0554:             * {@link edu.cornell.kew.service.impl.serviceImpl#create(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
0555:             *
0556:             * @throws WorkflowException
0557:             */
0558:            @Test
0559:            public void testCreate() throws WorkflowException {
0560:
0561:                DocumentResponse results = service.create(TEST_USER, "1234",
0562:                        TEST_DOC_TYPE, TEST_TITLE);
0563:                //assertEquals(7, results.size());
0564:
0565:                assertEquals(EdenConstants.ROUTE_HEADER_INITIATED_CD,
0566:                        (String) results.getDocStatus());
0567:
0568:                // TODO: better date test
0569:                assertTrue("createDate should not be empty", StringUtils
0570:                        .isNotEmpty((String) results.getCreateDate()));
0571:                assertEquals(TEST_USER, (String) results.getInitiatorId());
0572:                assertEquals("1234", (String) results.getAppDocId());
0573:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
0574:                        .getInitiatorName());
0575:                assertEquals("", (String) results.getErrorMessage());
0576:                String docId = (String) results.getDocId();
0577:                assertTrue("docId should not be empty", StringUtils
0578:                        .isNotEmpty(docId));
0579:                long docIdLong = Long.parseLong(docId);
0580:                assertTrue("docId should be >= 2000", docIdLong >= 2000);
0581:
0582:                RouteHeaderVO routeHeader = getTestDoc(docIdLong);
0583:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
0584:                assertEquals("I", routeHeader.getDocRouteStatus());
0585:                // TODO: better date test
0586:                assertNotNull("dateCreated should NOT be null", routeHeader
0587:                        .getDateCreated());
0588:                assertEquals(TEST_USER, routeHeader.getInitiator()
0589:                        .getNetworkId());
0590:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
0591:                        .getDisplayName());
0592:                assertEquals("1234", routeHeader.getAppDocId());
0593:
0594:                deleteTestDoc(docIdLong);
0595:            }
0596:
0597:            /**
0598:             * Test method for
0599:             * {@link edu.cornell.kew.service.impl.serviceImpl#disapprove(java.lang.String, java.lang.String, java.lang.String)}.
0600:             *
0601:             * @throws WorkflowException
0602:             * @throws InterruptedException
0603:             */
0604:            @Test
0605:            public void testDisapprove() throws WorkflowException,
0606:                    InterruptedException {
0607:
0608:                RouteHeaderVO routeHeader = createTestDoc();
0609:                routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
0610:
0611:                StandardResponse results = service.disapprove(routeHeader
0612:                        .getRouteHeaderId().toString(), TEST_USER,
0613:                        "test disapprove");
0614:
0615:                //assertEquals(6, results.size());
0616:                assertEquals(
0617:                        "There shouldn't be an error message if things went well.",
0618:                        "", (String) results.getErrorMessage());
0619:                assertEquals(EdenConstants.ROUTE_HEADER_DISAPPROVED_CD,
0620:                        (String) results.getDocStatus());
0621:                // TODO: better date test
0622:                assertTrue("createDate should not be empty", StringUtils
0623:                        .isNotEmpty((String) results.getCreateDate()));
0624:                assertEquals(TEST_USER, (String) results.getInitiatorId());
0625:                assertEquals("", (String) results.getAppDocId());
0626:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
0627:                        .getInitiatorName());
0628:
0629:                Long docId = routeHeader.getRouteHeaderId();
0630:                routeHeader = getTestDoc(docId.longValue());
0631:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
0632:                assertEquals(EdenConstants.ROUTE_HEADER_DISAPPROVED_CD,
0633:                        routeHeader.getDocRouteStatus());
0634:                // TODO: better date test
0635:                assertNotNull("dateCreated should NOT be null", routeHeader
0636:                        .getDateCreated());
0637:                assertEquals(TEST_USER, routeHeader.getInitiator()
0638:                        .getNetworkId());
0639:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
0640:                        .getDisplayName());
0641:                assertNull("We aren't using appDocId so it should be null",
0642:                        routeHeader.getAppDocId());
0643:                assertTrue("dateLastModified should be after createDate",
0644:                        routeHeader.getDateLastModified().compareTo(
0645:                                routeHeader.getDateCreated()) >= 0);
0646:
0647:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
0648:                WorkflowDocument workflowDocument = new WorkflowDocument(
0649:                        userIdVO, docId);
0650:                ActionRequestVO[] actionRequests = workflowDocument
0651:                        .getActionRequests();
0652:                assertNotNull("We should have some action requests",
0653:                        actionRequests);
0654:                assertEquals(2, actionRequests.length);
0655:                ActionRequestVO actionRequest = actionHasBeenRequested(
0656:                        actionRequests, TEST_USER, "A");
0657:                assertEquals("A", actionRequest.getActionRequested());
0658:                assertNull("Annotation should be null since we didn't set it",
0659:                        actionRequest.getAnnotation());
0660:                assertEquals(TEST_USER, actionRequest.getUserVO()
0661:                        .getNetworkId());
0662:                assertTrue("Should be an Approval request", actionRequest
0663:                        .isApprovalRequest());
0664:                assertTrue("ActionRequeset should be Done", actionRequest
0665:                        .isDone());
0666:                assertEquals("D", actionRequest.getActionTaken()
0667:                        .getActionTaken());
0668:                actionRequest = actionHasBeenRequested(actionRequests,
0669:                        TEST_USER, "K");
0670:                assertEquals("K", actionRequest.getActionRequested());
0671:                assertEquals(
0672:                        "Action ACKNOWLEDGE generated by Workflow because User One took action DISAPPROVED",
0673:                        actionRequest.getAnnotation());
0674:                assertEquals(TEST_USER, actionRequest.getUserVO()
0675:                        .getNetworkId());
0676:                assertTrue("Should be an Acknowledge request", actionRequest
0677:                        .isAcknowledgeRequest());
0678:                assertFalse("Should NOT be Done", actionRequest.isDone());
0679:
0680:                // let's cleanup shall we
0681:                deleteTestDoc(docId.longValue());
0682:            }
0683:
0684:            /**
0685:             * Test method for
0686:             * {@link edu.cornell.kew.service.impl.serviceImpl#fyi(java.lang.String, java.lang.String)}.
0687:             *
0688:             * @throws WorkflowException
0689:             * @throws InterruptedException
0690:             */
0691:            @Test
0692:            public void testFyi() throws WorkflowException,
0693:                    InterruptedException {
0694:
0695:                RouteHeaderVO routeHeader = createTestDoc();
0696:                routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
0697:
0698:                approveTestDoc(routeHeader.getRouteHeaderId(), "test approve");
0699:
0700:                acknowledgeTestDoc(routeHeader.getRouteHeaderId(),
0701:                        "test acknowledge");
0702:
0703:                StandardResponse results = service.fyi(routeHeader
0704:                        .getRouteHeaderId().toString(), TEST_FYI_USER);
0705:
0706:                //assertEquals(6, results.size());
0707:                assertEquals(
0708:                        "There shouldn't be an error message if things went well.",
0709:                        "", (String) results.getErrorMessage());
0710:                assertTrue("docStatus should be FINAL", ((String) results
0711:                        .getDocStatus())
0712:                        .equals(EdenConstants.ROUTE_HEADER_FINAL_CD));
0713:                // TODO: better date test
0714:                assertTrue("createDate should not be empty", StringUtils
0715:                        .isNotEmpty((String) results.getCreateDate()));
0716:                assertEquals(TEST_USER, (String) results.getInitiatorId());
0717:                assertEquals("", (String) results.getAppDocId());
0718:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
0719:                        .getInitiatorName());
0720:
0721:                Long docId = routeHeader.getRouteHeaderId();
0722:                routeHeader = getTestDoc(docId.longValue());
0723:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
0724:                assertEquals("F", routeHeader.getDocRouteStatus());
0725:                // TODO: better date test
0726:                assertNotNull("dateCreated should NOT be null", routeHeader
0727:                        .getDateCreated());
0728:                assertEquals(TEST_USER, routeHeader.getInitiator()
0729:                        .getNetworkId());
0730:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
0731:                        .getDisplayName());
0732:                assertNull("We aren't using appDocId so it should be null",
0733:                        routeHeader.getAppDocId());
0734:                assertTrue("dateLastModified should be after createDate",
0735:                        routeHeader.getDateLastModified().after(
0736:                                routeHeader.getDateCreated()));
0737:
0738:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
0739:                WorkflowDocument workflowDocument = new WorkflowDocument(
0740:                        userIdVO, docId);
0741:                ActionRequestVO[] actionRequests = workflowDocument
0742:                        .getActionRequests();
0743:                assertNotNull("We should have some action requests",
0744:                        actionRequests);
0745:                assertEquals(3, actionRequests.length);
0746:
0747:                ActionRequestVO actionRequest = actionHasBeenRequested(
0748:                        actionRequests, "user1", "A");
0749:                //		ActionRequestVO actionRequest = actionRequests[0];
0750:                //		assertEquals("A", actionRequest.getActionRequested());
0751:
0752:                assertNull("Annotation should be null since we didn't set it",
0753:                        actionRequest.getAnnotation());
0754:                assertEquals(TEST_USER, actionRequest.getUserVO()
0755:                        .getNetworkId());
0756:                assertTrue("Should be an Approval request", actionRequest
0757:                        .isApprovalRequest());
0758:                assertTrue("ActionRequest should be Done", actionRequest
0759:                        .isDone());
0760:                assertEquals("A", actionRequest.getActionTaken()
0761:                        .getActionTaken());
0762:
0763:                actionRequest = actionHasBeenRequested(actionRequests, null,
0764:                        "K");
0765:                assertEquals("K", actionRequest.getActionRequested());
0766:
0767:                assertNull("Annotation should be null since we didn't set it",
0768:                        actionRequest.getAnnotation());
0769:                assertEquals(TEST_USER, actionRequest.getUserVO()
0770:                        .getNetworkId());
0771:                assertTrue("Should be an Acknowledge request", actionRequest
0772:                        .isAcknowledgeRequest());
0773:                assertTrue("ActionRequest should be Done", actionRequest
0774:                        .isDone());
0775:
0776:                actionRequest = actionHasBeenRequested(actionRequests, null,
0777:                        "F");
0778:                assertEquals("F", actionRequest.getActionRequested());
0779:
0780:                assertNull("Annotation should be null since we didn't set it",
0781:                        actionRequest.getAnnotation());
0782:                assertEquals(TEST_FYI_USER, actionRequest.getUserVO()
0783:                        .getNetworkId());
0784:                assertTrue("ActionRequest should be Done", actionRequest
0785:                        .isDone());
0786:
0787:                // let's cleanup shall we
0788:                deleteTestDoc(docId.longValue());
0789:            }
0790:
0791:            /**
0792:             * Test method for
0793:             * {@link edu.cornell.kew.service.impl.serviceImpl#getDocument(java.lang.String)}.
0794:             *
0795:             * @throws WorkflowException
0796:             * @throws InterruptedException
0797:             */
0798:            @Test
0799:            public void testGetDocument() throws WorkflowException,
0800:                    InterruptedException {
0801:
0802:                RouteHeaderVO routeHeader = createTestDoc();
0803:                routeTestDoc(routeHeader.getRouteHeaderId(),
0804:                        "<key>value</key>", "test doc title", "test route");
0805:
0806:                DocumentResponse results = service.getDocument(routeHeader
0807:                        .getRouteHeaderId().toString(), TEST_USER);
0808:
0809:                //assertEquals(10, results.size());
0810:                assertEquals(
0811:                        "There shouldn't be an error message if things went well.",
0812:                        "", (String) results.getErrorMessage());
0813:                assertEquals(EdenConstants.ROUTE_HEADER_ENROUTE_CD,
0814:                        (String) results.getDocStatus());
0815:                // TODO: better date test
0816:                assertTrue("createDate should not be empty", StringUtils
0817:                        .isNotEmpty((String) results.getCreateDate()));
0818:                assertEquals(TEST_USER, (String) results.getInitiatorId());
0819:                assertEquals("", (String) results.getAppDocId());
0820:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
0821:                        .getInitiatorName());
0822:                assertEquals("<key>value</key>", (String) results
0823:                        .getDocContent());
0824:                assertEquals("test doc title", (String) results.getTitle());
0825:                assertEquals("APPROVE", (String) results.getActionRequested());
0826:                List<NoteDetail> notes = results.getNotes();
0827:                assertNotNull(notes);
0828:                assertEquals(0, notes.size());
0829:
0830:                approveTestDoc(routeHeader.getRouteHeaderId(), "test approve");
0831:
0832:                // sleep for two seconds to allow that status to change
0833:                Thread.sleep(2000);
0834:
0835:                results = service.getDocument(routeHeader.getRouteHeaderId()
0836:                        .toString(), TEST_USER);
0837:
0838:                //assertEquals(10, results.size());
0839:                assertEquals(EdenConstants.ROUTE_HEADER_PROCESSED_CD,
0840:                        (String) results.getDocStatus());
0841:                // TODO: better date test
0842:                assertTrue("createDate should not be empty", StringUtils
0843:                        .isNotEmpty((String) results.getCreateDate()));
0844:                assertEquals(TEST_USER, (String) results.getInitiatorId());
0845:                assertEquals("", (String) results.getAppDocId());
0846:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
0847:                        .getInitiatorName());
0848:                assertEquals("", (String) results.getErrorMessage());
0849:                assertEquals("<key>value</key>", (String) results
0850:                        .getDocContent());
0851:                assertEquals("test doc title", (String) results.getTitle());
0852:                assertEquals("ACKNOWLEDGE", (String) results
0853:                        .getActionRequested());
0854:                notes = results.getNotes();
0855:                assertNotNull(notes);
0856:                assertEquals(0, notes.size());
0857:
0858:                acknowledgeTestDoc(routeHeader.getRouteHeaderId(), "test ack");
0859:
0860:                // sleep for two seconds to allow that status to change
0861:                Thread.sleep(2000);
0862:
0863:                results = service.getDocument(routeHeader.getRouteHeaderId()
0864:                        .toString(), TEST_FYI_USER);
0865:
0866:                //assertEquals(10, results.size());
0867:                assertEquals(EdenConstants.ROUTE_HEADER_FINAL_CD,
0868:                        (String) results.getDocStatus());
0869:                // TODO: better date test
0870:                assertTrue("createDate should not be empty", StringUtils
0871:                        .isNotEmpty((String) results.getCreateDate()));
0872:                assertEquals(TEST_USER, (String) results.getInitiatorId());
0873:                assertEquals("", (String) results.getAppDocId());
0874:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
0875:                        .getInitiatorName());
0876:                assertEquals("", (String) results.getErrorMessage());
0877:                assertEquals("<key>value</key>", (String) results
0878:                        .getDocContent());
0879:                assertEquals("test doc title", (String) results.getTitle());
0880:                assertEquals("FYI", (String) results.getActionRequested());
0881:                notes = results.getNotes();
0882:                assertNotNull(notes);
0883:                assertEquals(0, notes.size());
0884:
0885:                // let's cleanup shall we
0886:                deleteTestDoc(routeHeader.getRouteHeaderId());
0887:            }
0888:
0889:            /**
0890:             * Test method for
0891:             * {@link edu.cornell.kew.service.impl.serviceImpl#isUserInRouteLog(java.lang.String, java.lang.String)}.
0892:             *
0893:             * @throws WorkflowException
0894:             */
0895:            public void testIsUserInRouteLog() throws WorkflowException {
0896:
0897:                // create a new document
0898:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
0899:                WorkflowDocument doc = new WorkflowDocument(userIdVO,
0900:                        TEST_DOC_TYPE);
0901:                String docId = doc.getRouteHeaderId().toString();
0902:
0903:                UserInRouteLogResponse results = service.isUserInRouteLog(
0904:                        docId, TEST_USER);
0905:                //assertEquals(2, results.size());
0906:
0907:                assertTrue(
0908:                        "time1-demo should be in the route log for document: 2005",
0909:                        Boolean.parseBoolean((String) results
0910:                                .getIsUserInRouteLog()));
0911:                assertEquals(
0912:                        "There shouldn't be an error message if things went well.",
0913:                        "", (String) results.getErrorMessage());
0914:
0915:                results = service.isUserInRouteLog(docId, TEST_USER2);
0916:                assertFalse(
0917:                        "TEST_USER2 should NOT be in the route log for document: 2005",
0918:                        Boolean.parseBoolean((String) results
0919:                                .getIsUserInRouteLog()));
0920:                assertEquals(
0921:                        "There shouldn't be an error message if things went well.",
0922:                        "", (String) results.getErrorMessage());
0923:            }
0924:
0925:            /**
0926:             * Test method for
0927:             * {@link edu.cornell.kew.service.impl.serviceImpl#requestAdHocAckToGroup(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
0928:             *
0929:             * @throws WorkflowException
0930:             * @throws InterruptedException
0931:             */
0932:            public void testRequestAdHocAckGroup() throws WorkflowException,
0933:                    InterruptedException {
0934:
0935:                RouteHeaderVO routeHeader = createTestDoc();
0936:                // routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
0937:
0938:                service.requestAdHocAckToGroup(routeHeader.getRouteHeaderId()
0939:                        .toString(), TEST_USER, TEST_ADHOC_GROUP,
0940:                        "requesting adhoc acknowledge for " + TEST_ADHOC_GROUP);
0941:                StandardResponse results = service.route(String
0942:                        .valueOf(routeHeader.getRouteHeaderId()), TEST_USER,
0943:                        null, null, "adhoc route - acknowledge for "
0944:                                + TEST_ADHOC_GROUP);
0945:
0946:                //assertEquals(6, results.size());
0947:                assertEquals(
0948:                        "There shouldn't be an error message if things went well.",
0949:                        "", (String) results.getErrorMessage());
0950:                assertEquals("ENROUTE", (String) results.getDocStatus());
0951:                // TODO: better date test
0952:                assertTrue("createDate should not be empty", StringUtils
0953:                        .isNotEmpty((String) results.getCreateDate()));
0954:                assertEquals(TEST_USER, (String) results.getInitiatorId());
0955:                assertEquals("", (String) results.getAppDocId());
0956:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
0957:                        .getInitiatorName());
0958:
0959:                // sleep for two seconds to allow that status to change
0960:                Thread.sleep(2000);
0961:
0962:                Long docId = routeHeader.getRouteHeaderId();
0963:                routeHeader = getTestDoc(docId.longValue());
0964:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
0965:                assertEquals("R", routeHeader.getDocRouteStatus());
0966:                // TODO: better date test
0967:                assertNotNull("dateCreated should NOT be null", routeHeader
0968:                        .getDateCreated());
0969:                assertEquals(TEST_USER, routeHeader.getInitiator()
0970:                        .getNetworkId());
0971:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
0972:                        .getDisplayName());
0973:                assertNull("We aren't using appDocId so it should be null",
0974:                        routeHeader.getAppDocId());
0975:                assertTrue("dateLastModified should be after createDate",
0976:                        routeHeader.getDateLastModified().after(
0977:                                routeHeader.getDateCreated()));
0978:
0979:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
0980:                WorkflowDocument workflowDocument = new WorkflowDocument(
0981:                        userIdVO, docId);
0982:                ActionRequestVO[] actionRequests = workflowDocument
0983:                        .getActionRequests();
0984:                assertNotNull("We should have some action requests",
0985:                        actionRequests);
0986:
0987:                assertEquals(2, actionRequests.length);
0988:                ActionRequestVO actionRequest = actionHasBeenRequested(
0989:                        actionRequests, TEST_ADHOC_GROUP, "K");
0990:                assertEquals("K", actionRequest.getActionRequested());
0991:                assertEquals("requesting adhoc acknowledge for "
0992:                        + TEST_ADHOC_GROUP, actionRequest.getAnnotation());
0993:                assertEquals(TEST_ADHOC_GROUP, actionRequest.getWorkgroupVO()
0994:                        .getWorkgroupName());
0995:                assertTrue("Should be an Acknowledge request", actionRequest
0996:                        .isAcknowledgeRequest());
0997:                assertTrue("Should be an AdHoc request", actionRequest
0998:                        .isAdHocRequest());
0999:                assertFalse("Should NOT be Done", actionRequest.isDone());
1000:                actionRequest = actionRequests[1];
1001:                assertEquals("A", actionRequest.getActionRequested());
1002:                assertNull("Annotation should be null since we didn't set it",
1003:                        actionRequest.getAnnotation());
1004:                assertEquals(TEST_USER, actionRequest.getUserVO()
1005:                        .getNetworkId());
1006:                assertTrue("Should be an Approval request", actionRequest
1007:                        .isApprovalRequest());
1008:                assertFalse("Should NOT be Done", actionRequest.isDone());
1009:
1010:                // let's cleanup shall we
1011:                deleteTestDoc(docId.longValue());
1012:            }
1013:
1014:            /**
1015:             * Test method for
1016:             * {@link edu.cornell.kew.service.impl.serviceImpl#requestAdHocAckToUser(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
1017:             *
1018:             * @throws WorkflowException
1019:             * @throws InterruptedException
1020:             */
1021:            public void testRequestAdHocAckUser() throws WorkflowException,
1022:                    InterruptedException {
1023:
1024:                RouteHeaderVO routeHeader = createTestDoc();
1025:                // routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
1026:
1027:                service.requestAdHocAckToUser(routeHeader.getRouteHeaderId()
1028:                        .toString(), TEST_USER, TEST_ADHOC_USER,
1029:                        "requesting adhoc acknowledge for " + TEST_ADHOC_USER);
1030:                StandardResponse results = service.route(String
1031:                        .valueOf(routeHeader.getRouteHeaderId()), TEST_USER,
1032:                        null, null, "adhoc route - acknowledge for "
1033:                                + TEST_ADHOC_USER);
1034:
1035:                //assertEquals(6, results.size());
1036:                assertEquals(
1037:                        "There shouldn't be an error message if things went well.",
1038:                        "", (String) results.getErrorMessage());
1039:                assertEquals("ENROUTE", (String) results.getDocStatus());
1040:                // TODO: better date test
1041:                assertTrue("createDate should not be empty", StringUtils
1042:                        .isNotEmpty((String) results.getCreateDate()));
1043:                assertEquals(TEST_USER, (String) results.getInitiatorId());
1044:                assertEquals("", (String) results.getAppDocId());
1045:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
1046:                        .getInitiatorName());
1047:
1048:                // sleep for two seconds to allow that status to change
1049:                Thread.sleep(2000);
1050:
1051:                Long docId = routeHeader.getRouteHeaderId();
1052:                routeHeader = getTestDoc(docId.longValue());
1053:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
1054:                assertEquals("R", routeHeader.getDocRouteStatus());
1055:                // TODO: better date test
1056:                assertNotNull("dateCreated should NOT be null", routeHeader
1057:                        .getDateCreated());
1058:                assertEquals(TEST_USER, routeHeader.getInitiator()
1059:                        .getNetworkId());
1060:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
1061:                        .getDisplayName());
1062:                assertNull("We aren't using appDocId so it should be null",
1063:                        routeHeader.getAppDocId());
1064:                assertTrue("dateLastModified should be after createDate",
1065:                        routeHeader.getDateLastModified().after(
1066:                                routeHeader.getDateCreated()));
1067:
1068:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
1069:                WorkflowDocument workflowDocument = new WorkflowDocument(
1070:                        userIdVO, docId);
1071:                ActionRequestVO[] actionRequests = workflowDocument
1072:                        .getActionRequests();
1073:                assertNotNull("We should have some action requests",
1074:                        actionRequests);
1075:
1076:                assertEquals(2, actionRequests.length);
1077:                ActionRequestVO actionRequest = actionRequests[0];
1078:                assertEquals("K", actionRequest.getActionRequested());
1079:                assertEquals("requesting adhoc acknowledge for "
1080:                        + TEST_ADHOC_USER, actionRequest.getAnnotation());
1081:                assertEquals(TEST_ADHOC_USER, actionRequest.getUserVO()
1082:                        .getNetworkId());
1083:                assertTrue("should be an Acknowledge request", actionRequest
1084:                        .isAcknowledgeRequest());
1085:                assertTrue("should be an AdHoc request", actionRequest
1086:                        .isAdHocRequest());
1087:                assertFalse("Should NOT be Done", actionRequest.isDone());
1088:                actionRequest = actionRequests[1];
1089:                assertEquals("A", actionRequest.getActionRequested());
1090:                assertNull("Annotation should be null since we didn't set it",
1091:                        actionRequest.getAnnotation());
1092:                assertEquals(TEST_USER, actionRequest.getUserVO()
1093:                        .getNetworkId());
1094:                assertTrue("should be an Approval request", actionRequest
1095:                        .isApprovalRequest());
1096:                assertFalse("Should NOT be Done", actionRequest.isDone());
1097:
1098:                // let's cleanup shall we
1099:                deleteTestDoc(docId.longValue());
1100:            }
1101:
1102:            /**
1103:             * Test method for
1104:             * {@link edu.cornell.kew.service.impl.serviceImpl#requestAdHocApproveToGroup(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
1105:             *
1106:             * @throws WorkflowException
1107:             * @throws InterruptedException
1108:             */
1109:            public void testRequestAdHocApproveGroup()
1110:                    throws WorkflowException, InterruptedException {
1111:
1112:                RouteHeaderVO routeHeader = createTestDoc();
1113:                // routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
1114:
1115:                service.requestAdHocApproveToGroup(routeHeader
1116:                        .getRouteHeaderId().toString(), TEST_USER,
1117:                        TEST_ADHOC_GROUP, "requesting adhoc approve for "
1118:                                + TEST_ADHOC_GROUP);
1119:                StandardResponse results = service.route(String
1120:                        .valueOf(routeHeader.getRouteHeaderId()), TEST_USER,
1121:                        null, null, "adhoc route - approve for "
1122:                                + TEST_ADHOC_GROUP);
1123:
1124:                //assertEquals(6, results.size());
1125:                assertEquals(
1126:                        "There shouldn't be an error message if things went well.",
1127:                        "", (String) results.getErrorMessage());
1128:                assertEquals("ENROUTE", (String) results.getDocStatus());
1129:                // TODO: better date test
1130:                assertTrue("createDate should not be empty", StringUtils
1131:                        .isNotEmpty((String) results.getCreateDate()));
1132:                assertEquals(TEST_USER, (String) results.getInitiatorId());
1133:                assertEquals("", (String) results.getAppDocId());
1134:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
1135:                        .getInitiatorName());
1136:
1137:                // sleep for two seconds to allow that status to change
1138:                Thread.sleep(2000);
1139:
1140:                Long docId = routeHeader.getRouteHeaderId();
1141:                routeHeader = getTestDoc(docId.longValue());
1142:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
1143:                assertEquals("R", routeHeader.getDocRouteStatus());
1144:                // TODO: better date test
1145:                assertNotNull("dateCreated should NOT be null", routeHeader
1146:                        .getDateCreated());
1147:                assertEquals(TEST_USER, routeHeader.getInitiator()
1148:                        .getNetworkId());
1149:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
1150:                        .getDisplayName());
1151:                assertNull("We aren't using appDocId so it should be null",
1152:                        routeHeader.getAppDocId());
1153:                assertTrue("dateLastModified should be after dateCreated",
1154:                        routeHeader.getDateLastModified().after(
1155:                                routeHeader.getDateCreated()));
1156:
1157:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
1158:                WorkflowDocument workflowDocument = new WorkflowDocument(
1159:                        userIdVO, docId);
1160:                ActionRequestVO[] actionRequests = workflowDocument
1161:                        .getActionRequests();
1162:                assertNotNull("We should have some action requests",
1163:                        actionRequests);
1164:
1165:                assertEquals(1, actionRequests.length);
1166:                ActionRequestVO actionRequest = actionRequests[0];
1167:                assertEquals("A", actionRequest.getActionRequested());
1168:                assertEquals(
1169:                        "requesting adhoc approve for " + TEST_ADHOC_GROUP,
1170:                        actionRequest.getAnnotation());
1171:                assertEquals(TEST_ADHOC_GROUP, actionRequest.getWorkgroupVO()
1172:                        .getWorkgroupName());
1173:                assertTrue("Should be an Approval request", actionRequest
1174:                        .isApprovalRequest());
1175:                assertTrue("Should be an AdHoc request", actionRequest
1176:                        .isAdHocRequest());
1177:                assertFalse("Should NOT be Done", actionRequest.isDone());
1178:                // actionRequest = actionRequests[1];
1179:                // assertEquals("A", actionRequest.getActionRequested());
1180:                // assertNull(actionRequest.getAnnotation());
1181:                // assertEquals(TEST_USER, actionRequest.getUserVO().getNetworkId());
1182:                // assertTrue(actionRequest.isApprovalRequest());
1183:                // assertFalse(actionRequest.isDone());
1184:
1185:                // let's cleanup shall we
1186:                deleteTestDoc(docId.longValue());
1187:            }
1188:
1189:            /**
1190:             * Test method for
1191:             * {@link edu.cornell.kew.service.impl.serviceImpl#requestAdHocApproveToUser(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
1192:             *
1193:             * @throws WorkflowException
1194:             * @throws InterruptedException
1195:             */
1196:            public void testRequestAdHocAproveUser() throws WorkflowException,
1197:                    InterruptedException {
1198:
1199:                RouteHeaderVO routeHeader = createTestDoc();
1200:                // routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
1201:
1202:                service.requestAdHocApproveToUser(routeHeader
1203:                        .getRouteHeaderId().toString(), TEST_USER,
1204:                        TEST_ADHOC_USER, "requesting adhoc approve for "
1205:                                + TEST_ADHOC_USER);
1206:                StandardResponse results = service.route(String
1207:                        .valueOf(routeHeader.getRouteHeaderId()), TEST_USER,
1208:                        null, null, "adhoc route - approve for "
1209:                                + TEST_ADHOC_USER);
1210:
1211:                //assertEquals(6, results.size());
1212:                assertEquals(
1213:                        "There shouldn't be an error message if things went well.",
1214:                        "", (String) results.getErrorMessage());
1215:                assertEquals("ENROUTE", (String) results.getDocStatus());
1216:                // TODO: better date test
1217:                assertTrue("createDate should not be empty", StringUtils
1218:                        .isNotEmpty((String) results.getCreateDate()));
1219:                assertEquals(TEST_USER, (String) results.getInitiatorId());
1220:                assertEquals("", (String) results.getAppDocId());
1221:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
1222:                        .getInitiatorName());
1223:
1224:                // sleep for two seconds to allow that status to change
1225:                Thread.sleep(2000);
1226:
1227:                Long docId = routeHeader.getRouteHeaderId();
1228:                routeHeader = getTestDoc(docId.longValue());
1229:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
1230:                assertEquals("R", routeHeader.getDocRouteStatus());
1231:                // TODO: better date test
1232:                assertNotNull("dateCreated should NOT be null", routeHeader
1233:                        .getDateCreated());
1234:                assertEquals(TEST_USER, routeHeader.getInitiator()
1235:                        .getNetworkId());
1236:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
1237:                        .getDisplayName());
1238:                assertNull("We aren't using appDocId so it should be null",
1239:                        routeHeader.getAppDocId());
1240:                assertTrue("dateLastModified should be after createDate",
1241:                        routeHeader.getDateLastModified().after(
1242:                                routeHeader.getDateCreated()));
1243:
1244:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
1245:                WorkflowDocument workflowDocument = new WorkflowDocument(
1246:                        userIdVO, docId);
1247:                ActionRequestVO[] actionRequests = workflowDocument
1248:                        .getActionRequests();
1249:                assertNotNull("We should have some action requests",
1250:                        actionRequests);
1251:
1252:                assertEquals(1, actionRequests.length);
1253:                ActionRequestVO actionRequest = actionRequests[0];
1254:                assertEquals("A", actionRequest.getActionRequested());
1255:                assertEquals("requesting adhoc approve for " + TEST_ADHOC_USER,
1256:                        actionRequest.getAnnotation());
1257:                assertEquals(TEST_ADHOC_USER, actionRequest.getUserVO()
1258:                        .getNetworkId());
1259:                assertTrue("should be an Approval request", actionRequest
1260:                        .isApprovalRequest());
1261:                assertTrue("should be an AdHoc request", actionRequest
1262:                        .isAdHocRequest());
1263:                assertFalse("Should NOT be Done", actionRequest.isDone());
1264:                // actionRequest = actionRequests[1];
1265:                // assertEquals("A", actionRequest.getActionRequested());
1266:                // assertNull(actionRequest.getAnnotation());
1267:                // assertEquals(TEST_USER, actionRequest.getUserVO().getNetworkId());
1268:                // assertTrue(actionRequest.isApprovalRequest());
1269:                // assertFalse(actionRequest.isDone());
1270:
1271:                // let's cleanup shall we
1272:                deleteTestDoc(docId.longValue());
1273:            }
1274:
1275:            /**
1276:             * Test method for
1277:             * {@link edu.cornell.kew.service.impl.serviceImpl#requestAdHocApproveToUser(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
1278:             *
1279:             * @throws WorkflowException
1280:             * @throws InterruptedException
1281:             */
1282:            public void testRequestAdHocApproveUserMulti()
1283:                    throws WorkflowException, InterruptedException {
1284:
1285:                RouteHeaderVO routeHeader = createTestAdhocDoc();
1286:                // routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
1287:
1288:                service.requestAdHocApproveToUser(routeHeader
1289:                        .getRouteHeaderId().toString(), TEST_USER2,
1290:                        TEST_ADHOC_USER, "requesting adhoc approve for "
1291:                                + TEST_ADHOC_USER);
1292:                StandardResponse results = service.route(String
1293:                        .valueOf(routeHeader.getRouteHeaderId()), TEST_USER2,
1294:                        null, null, "adhoc route - approve for "
1295:                                + TEST_ADHOC_USER);
1296:
1297:                //assertEquals(6, results.size());
1298:                assertEquals(
1299:                        "There shouldn't be an error message if things went well.",
1300:                        "", (String) results.getErrorMessage());
1301:                assertEquals("ENROUTE", (String) results.getDocStatus());
1302:                // TODO: better date test
1303:                assertTrue("createDate should not be empty", StringUtils
1304:                        .isNotEmpty((String) results.getCreateDate()));
1305:                assertEquals(TEST_USER2, (String) results.getInitiatorId());
1306:                assertEquals("", (String) results.getAppDocId());
1307:                assertEquals("Eric Westfall", (String) results
1308:                        .getInitiatorName());
1309:
1310:                // sleep for two seconds to allow that status to change
1311:                Thread.sleep(2000);
1312:
1313:                Long docId = routeHeader.getRouteHeaderId();
1314:                routeHeader = getTestDoc(docId.longValue());
1315:                assertEquals("test adhoc doc", routeHeader.getDocTitle());
1316:                assertEquals("R", routeHeader.getDocRouteStatus());
1317:                // TODO: better date test
1318:                assertNotNull("dateCreated should NOT be null", routeHeader
1319:                        .getDateCreated());
1320:                assertEquals(TEST_USER2, routeHeader.getInitiator()
1321:                        .getNetworkId());
1322:                assertEquals("Eric Westfall", routeHeader.getInitiator()
1323:                        .getDisplayName());
1324:                assertNull("We aren't using appDocId so it should be null",
1325:                        routeHeader.getAppDocId());
1326:                assertTrue("dateLastModified should be after createDate",
1327:                        routeHeader.getDateLastModified().after(
1328:                                routeHeader.getDateCreated()));
1329:
1330:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER2);
1331:                WorkflowDocument workflowDocument = new WorkflowDocument(
1332:                        userIdVO, docId);
1333:                ActionRequestVO[] actionRequests = workflowDocument
1334:                        .getActionRequests();
1335:                assertNotNull("We should have some action requests",
1336:                        actionRequests);
1337:
1338:                assertEquals(1, actionRequests.length);
1339:                ActionRequestVO actionRequest = actionRequests[0];
1340:                assertEquals("A", actionRequest.getActionRequested());
1341:                assertEquals("requesting adhoc approve for " + TEST_ADHOC_USER,
1342:                        actionRequest.getAnnotation());
1343:                assertEquals(TEST_ADHOC_USER, actionRequest.getUserVO()
1344:                        .getNetworkId());
1345:                assertTrue("Should be an Approval request", actionRequest
1346:                        .isApprovalRequest());
1347:                assertTrue("Should be an AdHoc request", actionRequest
1348:                        .isAdHocRequest());
1349:                assertFalse("Should NOT be Done", actionRequest.isDone());
1350:                // actionRequest = actionRequests[1];
1351:                // assertEquals("A", actionRequest.getActionRequested());
1352:                // assertNull(actionRequest.getAnnotation());
1353:                // assertEquals(TEST_USER, actionRequest.getUserVO().getNetworkId());
1354:                // assertTrue(actionRequest.isApprovalRequest());
1355:                // assertFalse(actionRequest.isDone());
1356:
1357:                results = service.approve(routeHeader.getRouteHeaderId()
1358:                        .toString(), TEST_ADHOC_USER, null, null,
1359:                        "test adhoc approve");
1360:                // sleep for three seconds to allow that status to change
1361:                Thread.sleep(3000);
1362:                // test status after approve?
1363:                //assertEquals(6, results.size());
1364:                assertEquals("", (String) results.getErrorMessage());
1365:
1366:                // return to previous and test results
1367:                results = service.returnToPreviousNode(routeHeader
1368:                        .getRouteHeaderId().toString(), TEST_USER2,
1369:                        "returning to Adhoc node", "Adhoc");
1370:
1371:                // sleep for three seconds to allow that status to change
1372:                Thread.sleep(3000);
1373:
1374:                //assertEquals(6, results.size());
1375:                assertEquals(
1376:                        "There shouldn't be an error message if things went well.",
1377:                        "", (String) results.getErrorMessage());
1378:                assertEquals("ENROUTE", (String) results.getDocStatus());
1379:                // TODO: better date test
1380:                assertTrue("createDate should not be empty", StringUtils
1381:                        .isNotEmpty((String) results.getCreateDate()));
1382:                assertEquals(TEST_USER2, (String) results.getInitiatorId());
1383:                assertEquals("", (String) results.getAppDocId());
1384:                assertEquals("Eric Westfall", (String) results
1385:                        .getInitiatorName());
1386:
1387:                docId = routeHeader.getRouteHeaderId();
1388:                routeHeader = getTestDoc(docId.longValue());
1389:                assertEquals("test adhoc doc", routeHeader.getDocTitle());
1390:                assertEquals("R", routeHeader.getDocRouteStatus());
1391:                // TODO: better date test
1392:                assertNotNull("dateCreated should NOT be null", routeHeader
1393:                        .getDateCreated());
1394:                assertEquals(TEST_USER2, routeHeader.getInitiator()
1395:                        .getNetworkId());
1396:                assertEquals("Eric Westfall", routeHeader.getInitiator()
1397:                        .getDisplayName());
1398:                assertNull("We aren't using appDocId so it should be null",
1399:                        routeHeader.getAppDocId());
1400:                assertTrue("dateLastModified should be after createDate",
1401:                        routeHeader.getDateLastModified().after(
1402:                                routeHeader.getDateCreated()));
1403:
1404:                userIdVO = new NetworkIdVO(TEST_USER);
1405:                workflowDocument = new WorkflowDocument(userIdVO, docId);
1406:                actionRequests = workflowDocument.getActionRequests();
1407:                assertNotNull("We should have some action requests",
1408:                        actionRequests);
1409:                assertEquals(1, actionRequests.length);
1410:                actionRequest = actionRequests[0];
1411:                assertEquals("A", actionRequest.getActionRequested());
1412:                assertEquals(
1413:                        "Action APPROVE generated by Workflow because Eric Westfall took action RETURNED TO PREVIOUS ROUTE LEVEL",
1414:                        actionRequest.getAnnotation());
1415:                assertEquals(TEST_USER2, actionRequest.getUserVO()
1416:                        .getNetworkId());
1417:                assertTrue("Should be an Approval request", actionRequest
1418:                        .isApprovalRequest());
1419:                assertFalse("Should NOT be Done", actionRequest.isDone());
1420:
1421:                service.requestAdHocApproveToUser(routeHeader
1422:                        .getRouteHeaderId().toString(), TEST_USER2,
1423:                        TEST_ADHOC_USER, "requesting adhoc approve for "
1424:                                + TEST_ADHOC_USER);
1425:
1426:                // sleep for two seconds to allow that status to change
1427:                Thread.sleep(2000);
1428:
1429:                results = service.getDocument(routeHeader.getRouteHeaderId()
1430:                        .toString(), TEST_USER);
1431:                // service.route(String.valueOf(routeHeader.getRouteHeaderId()),
1432:                // TEST_USER2, null, null, "adhoc route - approve for " +
1433:                // TEST_ADHOC_USER);
1434:
1435:                //assertEquals(10, results.size());
1436:                assertEquals(
1437:                        "There shouldn't be an error message if things went well.",
1438:                        "", (String) results.getErrorMessage());
1439:                assertEquals("ENROUTE", (String) results.getDocStatus());
1440:                // TODO: better date test
1441:                assertTrue("createDate should not be empty", StringUtils
1442:                        .isNotEmpty((String) results.getCreateDate()));
1443:                assertEquals(TEST_USER2, (String) results.getInitiatorId());
1444:                assertEquals("", (String) results.getAppDocId());
1445:                assertEquals("Eric Westfall", (String) results
1446:                        .getInitiatorName());
1447:
1448:                docId = routeHeader.getRouteHeaderId();
1449:                routeHeader = getTestDoc(docId.longValue());
1450:                assertEquals("test adhoc doc", routeHeader.getDocTitle());
1451:                assertEquals("R", routeHeader.getDocRouteStatus());
1452:                // TODO: better date test
1453:                assertNotNull("dateCreated should NOT be null", routeHeader
1454:                        .getDateCreated());
1455:                assertEquals(TEST_USER2, routeHeader.getInitiator()
1456:                        .getNetworkId());
1457:                assertEquals("Eric Westfall", routeHeader.getInitiator()
1458:                        .getDisplayName());
1459:                assertNull("We aren't using appDocId so it should be null",
1460:                        routeHeader.getAppDocId());
1461:                assertTrue("dateLastModified should be after createDate",
1462:                        routeHeader.getDateLastModified().after(
1463:                                routeHeader.getDateCreated()));
1464:
1465:                userIdVO = new NetworkIdVO(TEST_USER2);
1466:                workflowDocument = new WorkflowDocument(userIdVO, docId);
1467:                actionRequests = workflowDocument.getActionRequests();
1468:                assertNotNull("We should have some action requests",
1469:                        actionRequests);
1470:
1471:                assertEquals(2, actionRequests.length);
1472:                actionRequest = actionHasBeenRequested(actionRequests,
1473:                        TEST_ADHOC_USER, "A");
1474:                assertEquals("A", actionRequest.getActionRequested());
1475:                assertEquals("requesting adhoc approve for " + TEST_ADHOC_USER,
1476:                        actionRequest.getAnnotation());
1477:                assertEquals(TEST_ADHOC_USER, actionRequest.getUserVO()
1478:                        .getNetworkId());
1479:                assertTrue("Should be an Approval request", actionRequest
1480:                        .isApprovalRequest());
1481:                assertTrue("Should be an AdHoc request", actionRequest
1482:                        .isAdHocRequest());
1483:                assertFalse("Should NOT be Done", actionRequest.isDone());
1484:
1485:                // let's cleanup shall we
1486:                deleteTestDoc(docId.longValue());
1487:            }
1488:
1489:            /**
1490:             * Test method for
1491:             * {@link edu.cornell.kew.service.impl.serviceImpl#requestAdHocFyiToGroup(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
1492:             *
1493:             * @throws WorkflowException
1494:             * @throws InterruptedException
1495:             */
1496:            public void testRequestAdHocFyiGroup() throws WorkflowException,
1497:                    InterruptedException {
1498:
1499:                RouteHeaderVO routeHeader = createTestDoc();
1500:                // routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
1501:
1502:                service.requestAdHocFyiToGroup(routeHeader.getRouteHeaderId()
1503:                        .toString(), TEST_USER, TEST_ADHOC_GROUP,
1504:                        "requesting adhoc fyi for " + TEST_ADHOC_GROUP);
1505:                StandardResponse results = service
1506:                        .route(String.valueOf(routeHeader.getRouteHeaderId()),
1507:                                TEST_USER, null, null, "adhoc route - fyi for "
1508:                                        + TEST_ADHOC_GROUP);
1509:
1510:                //assertEquals(6, results.size());
1511:                assertEquals(
1512:                        "There shouldn't be an error message if things went well.",
1513:                        "", (String) results.getErrorMessage());
1514:                assertEquals("ENROUTE", (String) results.getDocStatus());
1515:                // TODO: better date test
1516:                assertTrue("createDate should not be empty", StringUtils
1517:                        .isNotEmpty((String) results.getCreateDate()));
1518:                assertEquals(TEST_USER, (String) results.getInitiatorId());
1519:                assertEquals("", (String) results.getAppDocId());
1520:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
1521:                        .getInitiatorName());
1522:
1523:                // sleep for two seconds to allow that status to change
1524:                Thread.sleep(2000);
1525:
1526:                Long docId = routeHeader.getRouteHeaderId();
1527:                routeHeader = getTestDoc(docId.longValue());
1528:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
1529:                assertEquals("R", routeHeader.getDocRouteStatus());
1530:                // TODO: better date test
1531:                assertNotNull("dateCreated should NOT be null", routeHeader
1532:                        .getDateCreated());
1533:                assertEquals(TEST_USER, routeHeader.getInitiator()
1534:                        .getNetworkId());
1535:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
1536:                        .getDisplayName());
1537:                assertNull("We aren't using appDocId so it should be null",
1538:                        routeHeader.getAppDocId());
1539:                assertTrue("dateLastModified should be after createDate",
1540:                        routeHeader.getDateLastModified().after(
1541:                                routeHeader.getDateCreated()));
1542:
1543:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
1544:                WorkflowDocument workflowDocument = new WorkflowDocument(
1545:                        userIdVO, docId);
1546:                ActionRequestVO[] actionRequests = workflowDocument
1547:                        .getActionRequests();
1548:                assertNotNull("We should have some action requests",
1549:                        actionRequests);
1550:
1551:                assertEquals(2, actionRequests.length);
1552:                ActionRequestVO actionRequest = actionRequests[0];
1553:                assertEquals("F", actionRequest.getActionRequested());
1554:                assertEquals("requesting adhoc fyi for " + TEST_ADHOC_GROUP,
1555:                        actionRequest.getAnnotation());
1556:                assertEquals(TEST_ADHOC_GROUP, actionRequest.getWorkgroupVO()
1557:                        .getWorkgroupName());
1558:                assertTrue("Should be an AdHoc request", actionRequest
1559:                        .isAdHocRequest());
1560:                assertFalse("Should NOT be Done", actionRequest.isDone());
1561:                actionRequest = actionRequests[1];
1562:                assertEquals("A", actionRequest.getActionRequested());
1563:                assertNull("Annotation should be null since we didn't set it",
1564:                        actionRequest.getAnnotation());
1565:                assertEquals(TEST_USER, actionRequest.getUserVO()
1566:                        .getNetworkId());
1567:                assertTrue("Should be an Approval request", actionRequest
1568:                        .isApprovalRequest());
1569:                assertFalse("Should NOT be Done", actionRequest.isDone());
1570:
1571:                // let's cleanup shall we
1572:                deleteTestDoc(docId.longValue());
1573:            }
1574:
1575:            /**
1576:             * Test method for
1577:             * {@link edu.cornell.kew.service.impl.serviceImpl#requestAdHocFyiToUser(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
1578:             *
1579:             * @throws WorkflowException
1580:             * @throws InterruptedException
1581:             */
1582:            public void testRequestAdHocFyiUser() throws WorkflowException,
1583:                    InterruptedException {
1584:
1585:                RouteHeaderVO routeHeader = createTestDoc();
1586:                // routeTestDoc(routeHeader.getRouteHeaderId(), "test route");
1587:
1588:                service.requestAdHocFyiToUser(routeHeader.getRouteHeaderId()
1589:                        .toString(), TEST_USER, TEST_ADHOC_USER,
1590:                        "requesting adhoc fyi for " + TEST_ADHOC_USER);
1591:                StandardResponse results = service.route(String
1592:                        .valueOf(routeHeader.getRouteHeaderId()), TEST_USER,
1593:                        null, null, "adhoc route - fyi for " + TEST_ADHOC_USER);
1594:
1595:                //assertEquals(6, results.size());
1596:                assertEquals(
1597:                        "There shouldn't be an error message if things went well.",
1598:                        "", (String) results.getErrorMessage());
1599:                assertEquals("ENROUTE", (String) results.getDocStatus());
1600:                // TODO: better date test
1601:                assertTrue("createDate should not be empty", StringUtils
1602:                        .isNotEmpty((String) results.getCreateDate()));
1603:                assertEquals(TEST_USER, (String) results.getInitiatorId());
1604:                assertEquals("", (String) results.getAppDocId());
1605:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
1606:                        .getInitiatorName());
1607:
1608:                // sleep for two seconds to allow that status to change
1609:                Thread.sleep(2000);
1610:
1611:                Long docId = routeHeader.getRouteHeaderId();
1612:                routeHeader = getTestDoc(docId.longValue());
1613:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
1614:                assertEquals("R", routeHeader.getDocRouteStatus());
1615:                // TODO: better date test
1616:                assertNotNull("dateCreated should NOT be null", routeHeader
1617:                        .getDateCreated());
1618:                assertEquals(TEST_USER, routeHeader.getInitiator()
1619:                        .getNetworkId());
1620:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
1621:                        .getDisplayName());
1622:                assertNull("We aren't using appDocId so it should be null",
1623:                        routeHeader.getAppDocId());
1624:                assertTrue("dateLastModified should be after createDate",
1625:                        routeHeader.getDateLastModified().after(
1626:                                routeHeader.getDateCreated()));
1627:
1628:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
1629:                WorkflowDocument workflowDocument = new WorkflowDocument(
1630:                        userIdVO, docId);
1631:                ActionRequestVO[] actionRequests = workflowDocument
1632:                        .getActionRequests();
1633:                assertNotNull("We should have some action requests",
1634:                        actionRequests);
1635:
1636:                assertEquals(2, actionRequests.length);
1637:                ActionRequestVO actionRequest = actionRequests[0];
1638:                assertEquals("F", actionRequest.getActionRequested());
1639:                assertEquals("requesting adhoc fyi for " + TEST_ADHOC_USER,
1640:                        actionRequest.getAnnotation());
1641:                assertEquals(TEST_ADHOC_USER, actionRequest.getUserVO()
1642:                        .getNetworkId());
1643:                assertTrue("Should be an AdHoc request", actionRequest
1644:                        .isAdHocRequest());
1645:                assertFalse("Should NOT be Done", actionRequest.isDone());
1646:                actionRequest = actionRequests[1];
1647:                assertEquals("A", actionRequest.getActionRequested());
1648:                assertNull("Annotation should be null since we didn't set it",
1649:                        actionRequest.getAnnotation());
1650:                assertEquals(TEST_USER, actionRequest.getUserVO()
1651:                        .getNetworkId());
1652:                assertTrue("Should be an Approval request", actionRequest
1653:                        .isApprovalRequest());
1654:                assertFalse("Should NOT be Done", actionRequest.isDone());
1655:
1656:                // let's cleanup shall we
1657:                deleteTestDoc(docId.longValue());
1658:            }
1659:
1660:            /**
1661:             * Test method for
1662:             * {@link edu.cornell.kew.service.impl.serviceImpl#route(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
1663:             *
1664:             * @throws WorkflowException
1665:             * @throws InterruptedException
1666:             */
1667:            public void testRoute() throws WorkflowException,
1668:                    InterruptedException {
1669:
1670:                RouteHeaderVO routeHeader = createTestDoc();
1671:
1672:                StandardResponse results = service.route(routeHeader
1673:                        .getRouteHeaderId().toString(), TEST_USER, TEST_TITLE,
1674:                        "<key>value</key>", "routing document");
1675:
1676:                //assertEquals(6, results.size());
1677:                assertEquals("ENROUTE", (String) results.getDocStatus());
1678:                // TODO: better date test
1679:                assertTrue("createDate should not be empty", StringUtils
1680:                        .isNotEmpty((String) results.getCreateDate()));
1681:                assertEquals(TEST_USER, (String) results.getInitiatorId());
1682:                assertEquals("", (String) results.getAppDocId());
1683:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
1684:                        .getInitiatorName());
1685:                assertEquals(
1686:                        "There shouldn't be an error message if things went well.",
1687:                        "", (String) results.getErrorMessage());
1688:
1689:                // sleep for two seconds to allow that status to change
1690:                Thread.sleep(2000);
1691:
1692:                Long docId = routeHeader.getRouteHeaderId();
1693:                routeHeader = getTestDoc(docId.longValue());
1694:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
1695:                assertEquals("R", routeHeader.getDocRouteStatus());
1696:                // TODO: better date test
1697:                assertNotNull("dateCreated should NOT be null", routeHeader
1698:                        .getDateCreated());
1699:                assertEquals(TEST_USER, routeHeader.getInitiator()
1700:                        .getNetworkId());
1701:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
1702:                        .getDisplayName());
1703:                assertNull("We aren't using appDocId so it should be null",
1704:                        routeHeader.getAppDocId());
1705:                System.err.println("date lastmodified: "
1706:                        + routeHeader.getDateLastModified());
1707:                System.err.println("date created: "
1708:                        + routeHeader.getDateCreated());
1709:                assertTrue("dateLastModified should be after createDate",
1710:                        routeHeader.getDateLastModified().after(
1711:                                routeHeader.getDateCreated()));
1712:
1713:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
1714:                WorkflowDocument workflowDocument = new WorkflowDocument(
1715:                        userIdVO, docId);
1716:                ActionRequestVO[] actionRequests = workflowDocument
1717:                        .getActionRequests();
1718:                assertNotNull("We should have some action requests",
1719:                        actionRequests);
1720:
1721:                // TODO: why is this 1 not 3?
1722:                assertEquals(1, actionRequests.length);
1723:                ActionRequestVO actionRequest = actionRequests[0];
1724:                assertEquals("A", actionRequest.getActionRequested());
1725:                assertNull("Annotation should be null since we didn't set it",
1726:                        actionRequest.getAnnotation());
1727:                assertEquals(TEST_USER, actionRequest.getUserVO()
1728:                        .getNetworkId());
1729:                assertTrue("Should be an Approval request", actionRequest
1730:                        .isApprovalRequest());
1731:                assertFalse("Should NOT be Done", actionRequest.isDone());
1732:
1733:                // let's cleanup shall we
1734:                deleteTestDoc(docId.longValue());
1735:            }
1736:
1737:            /**
1738:             * Test method for
1739:             * {@link edu.cornell.kew.service.impl.serviceImpl#save(java.lang.String, java.lang.String, java.lang.String)}.
1740:             *
1741:             * @throws WorkflowException
1742:             */
1743:            public void testSave() throws WorkflowException {
1744:
1745:                RouteHeaderVO routeHeader = createTestDoc();
1746:
1747:                StandardResponse results = service.save(routeHeader
1748:                        .getRouteHeaderId().toString(), TEST_USER, TEST_TITLE,
1749:                        "saving document");
1750:                //assertEquals(6, results.size());
1751:
1752:                assertEquals("SAVED", (String) results.getDocStatus());
1753:                // TODO: better date test
1754:                assertTrue("createDate should not be empty", StringUtils
1755:                        .isNotEmpty((String) results.getCreateDate()));
1756:                assertEquals(TEST_USER, (String) results.getInitiatorId());
1757:                assertEquals("", (String) results.getAppDocId());
1758:                assertEquals(TEST_USER_DISPLAY_NAME, (String) results
1759:                        .getInitiatorName());
1760:                assertEquals(
1761:                        "There shouldn't be an error message if things went well.",
1762:                        "", (String) results.getErrorMessage());
1763:
1764:                Long docId = routeHeader.getRouteHeaderId();
1765:                routeHeader = getTestDoc(docId.longValue());
1766:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
1767:                assertEquals("S", routeHeader.getDocRouteStatus());
1768:                // TODO: better date test
1769:                assertNotNull("dateCreated should NOT be null", routeHeader
1770:                        .getDateCreated());
1771:                assertEquals(TEST_USER, routeHeader.getInitiator()
1772:                        .getNetworkId());
1773:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
1774:                        .getDisplayName());
1775:                assertNull("We aren't using appDocId so it should be null",
1776:                        routeHeader.getAppDocId());
1777:                assertTrue("dateLastModified should be after createDate",
1778:                        routeHeader.getDateLastModified().after(
1779:                                routeHeader.getDateCreated()));
1780:
1781:                // let's cleanup shall we
1782:                deleteTestDoc(docId.longValue());
1783:            }
1784:
1785:            /**
1786:             * Test method for
1787:             * {@link edu.cornell.kew.service.impl.serviceImpl#addNote(java.lang.String, java.lang.String, java.lang.String, byte[])}.
1788:             *
1789:             * @throws WorkflowException
1790:             */
1791:            @Test
1792:            public void testAddNote() throws WorkflowException {
1793:                RouteHeaderVO routeHeader = createTestDoc();
1794:                Long docId = routeHeader.getRouteHeaderId();
1795:
1796:                NoteResponse results = service.addNote(docId.toString(),
1797:                        TEST_USER, TEST_NOTE_TEXT);
1798:                assertEquals(TEST_USER_DISPLAY_NAME, results.getAuthor());
1799:                assertNotNull(results.getNoteId());
1800:                assertNotNull(results.getTimestamp());
1801:                assertEquals(TEST_NOTE_TEXT, results.getNoteText());
1802:                assertEquals("", results.getErrorMessage());
1803:            }
1804:
1805:            /**
1806:             * Test method for
1807:             * {@link edu.cornell.kew.service.impl.serviceImpl#updateNote(java.lang.String, java.lang.String, java.lang.String, byte[])}.
1808:             *
1809:             * @throws WorkflowException
1810:             */
1811:            @Test
1812:            public void testUpdateNote() throws WorkflowException {
1813:                RouteHeaderVO routeHeader = createTestDoc();
1814:                Long docId = routeHeader.getRouteHeaderId();
1815:
1816:                NoteResponse results = service.addNote(docId.toString(),
1817:                        TEST_USER, TEST_NOTE_TEXT);
1818:                String noteId = (String) results.getNoteId();
1819:                String timestamp = (String) results.getTimestamp();
1820:                assertEquals(TEST_USER_DISPLAY_NAME, results.getAuthor());
1821:                assertNotNull(noteId);
1822:                assertNotNull(timestamp);
1823:                assertEquals(TEST_NOTE_TEXT, results.getNoteText());
1824:                assertEquals(
1825:                        "There shouldn't be an error message if things went well.",
1826:                        "", results.getErrorMessage());
1827:
1828:                results = service.updateNote(docId.toString(), noteId,
1829:                        TEST_FYI_USER, TEST_NOTE_TEXT2);
1830:                assertEquals(TEST_USER_DISPLAY_NAME, results.getAuthor());
1831:                assertEquals(noteId, results.getNoteId());
1832:                assertEquals(timestamp, results.getTimestamp());
1833:                assertEquals(TEST_NOTE_TEXT2, results.getNoteText());
1834:                assertEquals(
1835:                        "There shouldn't be an error message if things went well.",
1836:                        "", results.getErrorMessage());
1837:            }
1838:
1839:            /**
1840:             * Test method for
1841:             * {@link edu.cornell.kew.service.impl.serviceImpl#deleteNote(java.lang.String)}.
1842:             *
1843:             * @throws WorkflowException
1844:             */
1845:            @Test
1846:            public void testDeleteNote() throws WorkflowException {
1847:                RouteHeaderVO routeHeader = createTestDoc();
1848:                Long docId = routeHeader.getRouteHeaderId();
1849:
1850:                NoteResponse results = service.addNote(docId.toString(),
1851:                        TEST_USER, TEST_NOTE_TEXT);
1852:                String noteId = (String) results.getNoteId();
1853:                String timestamp = (String) results.getTimestamp();
1854:                assertEquals("", results.getErrorMessage());
1855:                assertEquals(TEST_USER_DISPLAY_NAME, results.getAuthor());
1856:                assertNotNull(noteId);
1857:                assertNotNull(timestamp);
1858:                assertEquals(TEST_NOTE_TEXT, results.getNoteText());
1859:
1860:                ErrorResponse eresults = service.deleteNote(docId.toString(),
1861:                        noteId, TEST_USER);
1862:                assertEquals(
1863:                        "There shouldn't be an error message if things went well.",
1864:                        "", eresults.getErrorMessage());
1865:                DocumentResponse dresults = service.getDocument(docId
1866:                        .toString(), TEST_USER);
1867:                assertEquals(
1868:                        "There shouldn't be an error message if things went well.",
1869:                        "", dresults.getErrorMessage());
1870:                List<NoteDetail> notes = dresults.getNotes();
1871:                assertNotNull(notes);
1872:                assertEquals(0, notes.size());
1873:            }
1874:
1875:            /**
1876:             * Test method for
1877:             * {@link edu.cornell.kew.service.impl.serviceImpl#returnToPrevious(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}.
1878:             *
1879:             * @throws WorkflowException
1880:             * @throws InterruptedException
1881:             */
1882:            public void testReturnToPrevious() throws WorkflowException,
1883:                    InterruptedException {
1884:
1885:                RouteHeaderVO routeHeader = createTestDoc();
1886:                Long docId = routeHeader.getRouteHeaderId();
1887:                routeTestDoc(docId, "test route");
1888:
1889:                // sleep for three seconds to allow that status to change
1890:                Thread.sleep(3000);
1891:
1892:                DocumentResponse dresults = service.getDocument(String
1893:                        .valueOf(docId), TEST_USER);
1894:                //assertEquals(10, results.size());
1895:                assertEquals(
1896:                        "There shouldn't be an error message if things went well.",
1897:                        "", (String) dresults.getErrorMessage());
1898:                assertEquals("ENROUTE", (String) dresults.getDocStatus());
1899:                // TODO: better date test
1900:                assertTrue("createDate should not be empty", StringUtils
1901:                        .isNotEmpty((String) dresults.getCreateDate()));
1902:                assertEquals(TEST_USER, (String) dresults.getInitiatorId());
1903:                assertEquals("", (String) dresults.getAppDocId());
1904:                assertEquals(TEST_USER_DISPLAY_NAME, (String) dresults
1905:                        .getInitiatorName());
1906:                assertEquals("", (String) dresults.getDocContent());
1907:                assertEquals("APPROVE", (String) dresults.getActionRequested());
1908:                List<NoteDetail> notes = dresults.getNotes();
1909:                assertNotNull(notes);
1910:                assertEquals(0, notes.size());
1911:
1912:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
1913:                WorkflowDocument workflowDocument = new WorkflowDocument(
1914:                        userIdVO, docId);
1915:                ActionRequestVO[] actionRequests = workflowDocument
1916:                        .getActionRequests();
1917:                assertNotNull("We should have some action requests",
1918:                        actionRequests);
1919:
1920:                // TODO: why is this 1 not 3?
1921:                assertEquals(1, actionRequests.length);
1922:                ActionRequestVO actionRequest = actionRequests[0];
1923:                assertEquals("A", actionRequest.getActionRequested());
1924:                assertNull("Annotation should be null since we didn't set it",
1925:                        actionRequest.getAnnotation());
1926:                assertEquals(TEST_USER, actionRequest.getUserVO()
1927:                        .getNetworkId());
1928:                assertTrue("Should be an Approval request", actionRequest
1929:                        .isApprovalRequest());
1930:                assertFalse("Should NOT be Done", actionRequest.isDone());
1931:
1932:                // return to previous and test results
1933:                StandardResponse rresults = service.returnToPreviousNode(
1934:                        routeHeader.getRouteHeaderId().toString(), TEST_USER,
1935:                        "returning to Initiated node", "Initiated");
1936:
1937:                // sleep for three seconds to allow that status to change
1938:                Thread.sleep(3000);
1939:
1940:                //assertEquals(6, results.size());
1941:                assertEquals(
1942:                        "There shouldn't be an error message if things went well.",
1943:                        "", (String) rresults.getErrorMessage());
1944:                assertEquals("ENROUTE", (String) rresults.getDocStatus());
1945:                // TODO: better date test
1946:                assertTrue("createDate should not be emtpy", StringUtils
1947:                        .isNotEmpty((String) rresults.getCreateDate()));
1948:                assertEquals(TEST_USER, (String) rresults.getInitiatorId());
1949:                assertEquals("", (String) rresults.getAppDocId());
1950:                assertEquals(TEST_USER_DISPLAY_NAME, (String) rresults
1951:                        .getInitiatorName());
1952:
1953:                docId = routeHeader.getRouteHeaderId();
1954:                routeHeader = getTestDoc(docId.longValue());
1955:                assertEquals(TEST_TITLE, routeHeader.getDocTitle());
1956:                assertEquals("R", routeHeader.getDocRouteStatus());
1957:                // TODO: better date test
1958:                assertNotNull("dateCreated should NOT be null", routeHeader
1959:                        .getDateCreated());
1960:                assertEquals(TEST_USER, routeHeader.getInitiator()
1961:                        .getNetworkId());
1962:                assertEquals(TEST_USER_DISPLAY_NAME, routeHeader.getInitiator()
1963:                        .getDisplayName());
1964:                assertNull("We aren't using appDocId so it should be null",
1965:                        routeHeader.getAppDocId());
1966:                assertTrue("dateLastModified should be after createDate",
1967:                        routeHeader.getDateLastModified().after(
1968:                                routeHeader.getDateCreated()));
1969:
1970:                userIdVO = new NetworkIdVO(TEST_USER);
1971:                workflowDocument = new WorkflowDocument(userIdVO, docId);
1972:                actionRequests = workflowDocument.getActionRequests();
1973:                assertNotNull("We should have some action requests",
1974:                        actionRequests);
1975:                assertEquals(1, actionRequests.length);
1976:                actionRequest = actionRequests[0];
1977:                assertEquals("A", actionRequest.getActionRequested());
1978:                assertEquals(
1979:                        "Action APPROVE generated by Workflow because Test Student took action RETURNED TO PREVIOUS ROUTE LEVEL",
1980:                        actionRequest.getAnnotation());
1981:                assertEquals(TEST_USER, actionRequest.getUserVO()
1982:                        .getNetworkId());
1983:                assertTrue("Should be an Approval request", actionRequest
1984:                        .isApprovalRequest());
1985:                assertFalse("Should NOT be Done", actionRequest.isDone());
1986:
1987:                // let's cleanup shall we
1988:                deleteTestDoc(docId.longValue());
1989:            }
1990:
1991:            /**
1992:             * Create the RouteHeaderVO for a test doc.
1993:             *
1994:             * @return the populated route header
1995:             * @throws WorkflowException
1996:             *             if something goes wrong
1997:             */
1998:            private RouteHeaderVO createTestDoc() throws WorkflowException {
1999:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
2000:                WorkflowDocument workflowDocument = new WorkflowDocument(
2001:                        userIdVO, TEST_DOC_TYPE);
2002:                workflowDocument.setTitle(TEST_TITLE);
2003:                workflowDocument.saveRoutingData();
2004:                RouteHeaderVO routeHeader = workflowDocument.getRouteHeader();
2005:                return routeHeader;
2006:            }
2007:
2008:            /**
2009:             * Create the RouteHeaderVO for a test adhoc doc.
2010:             *
2011:             * @return the populated route header
2012:             * @throws WorkflowException
2013:             *             if something goes wrong
2014:             */
2015:            private RouteHeaderVO createTestAdhocDoc() throws WorkflowException {
2016:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER2);
2017:                WorkflowDocument workflowDocument = new WorkflowDocument(
2018:                        userIdVO, "GeneralPurposeRequest");
2019:                workflowDocument.setTitle("test adhoc doc");
2020:                workflowDocument.saveRoutingData();
2021:                RouteHeaderVO routeHeader = workflowDocument.getRouteHeader();
2022:                return routeHeader;
2023:            }
2024:
2025:            /**
2026:             * Get the RouteHeaderVO for a test doc based on the docId passed in.
2027:             *
2028:             * @param docId
2029:             *            document id for the document to retrieve
2030:             * @return the populated route header
2031:             * @throws WorkflowException
2032:             *             if something goes wrong
2033:             */
2034:            private RouteHeaderVO getTestDoc(long docId)
2035:                    throws WorkflowException {
2036:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
2037:                WorkflowDocument workflowDocument = new WorkflowDocument(
2038:                        userIdVO, new Long(docId));
2039:                RouteHeaderVO routeHeader = workflowDocument.getRouteHeader();
2040:                return routeHeader;
2041:            }
2042:
2043:            /**
2044:             * Delete the test document.
2045:             *
2046:             * @param docId
2047:             *            document id for the document to delete
2048:             * @throws WorkflowException
2049:             *             if something goes wrong
2050:             */
2051:            private void deleteTestDoc(long docId) throws WorkflowException {
2052:                // UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
2053:                // WorkflowDocument workflowDocument = new WorkflowDocument(userIdVO,
2054:                // new
2055:                // Long(docId));
2056:                // //workflowDocument.delete();
2057:                // workflowDocument.cancel("Canceling test doc");
2058:            }
2059:
2060:            /**
2061:             * Route a test document with this document id and annotation.
2062:             *
2063:             * @param docId
2064:             *            document id for the document to route
2065:             * @param annotation
2066:             *            message associated with this request
2067:             * @throws WorkflowException
2068:             *             if something goes wrong
2069:             */
2070:            private void routeTestDoc(long docId, String annotation)
2071:                    throws WorkflowException {
2072:                routeTestDoc(docId, null, null, annotation);
2073:            }
2074:
2075:            /**
2076:             * Route a test document with this document id, content, title and
2077:             * annotation.
2078:             *
2079:             * @param docId
2080:             *            document id for the document to route
2081:             * @param docContent
2082:             *            xml document content
2083:             * @param docTitle
2084:             *            title for the document
2085:             * @param annotation
2086:             *            message associated with this request
2087:             * @throws WorkflowException
2088:             *             if something goes wrong
2089:             */
2090:            private void routeTestDoc(long docId, String docContent,
2091:                    String docTitle, String annotation)
2092:                    throws WorkflowException {
2093:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
2094:                WorkflowDocument workflowDocument = new WorkflowDocument(
2095:                        userIdVO, new Long(docId));
2096:                if (StringUtils.isNotEmpty(docContent)) {
2097:                    workflowDocument.setApplicationContent(docContent);
2098:                }
2099:                if (StringUtils.isNotEmpty(docTitle)) {
2100:                    workflowDocument.setTitle(docTitle);
2101:                }
2102:                workflowDocument.routeDocument(annotation);
2103:            }
2104:
2105:            /**
2106:             * Approve a test document with this document id and annotation.
2107:             *
2108:             * @param docId
2109:             *            document id for the document to approve
2110:             * @param annotation
2111:             *            message associated with this request
2112:             * @throws WorkflowException
2113:             *             if something goes wrong
2114:             */
2115:            private void approveTestDoc(long docId, String annotation)
2116:                    throws WorkflowException {
2117:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
2118:                WorkflowDocument workflowDocument = new WorkflowDocument(
2119:                        userIdVO, new Long(docId));
2120:                workflowDocument.approve(annotation);
2121:            }
2122:
2123:            /**
2124:             * Acknowledge a test document with this document id and annotation.
2125:             *
2126:             * @param docId
2127:             *            document id for the document to acknowlege
2128:             * @param annotation
2129:             *            message associated with this request
2130:             * @throws WorkflowException
2131:             *             if something goes wrong
2132:             */
2133:            private void acknowledgeTestDoc(long docId, String annotation)
2134:                    throws WorkflowException {
2135:                UserIdVO userIdVO = new NetworkIdVO(TEST_USER);
2136:                WorkflowDocument workflowDocument = new WorkflowDocument(
2137:                        userIdVO, new Long(docId));
2138:                workflowDocument.acknowledge(annotation);
2139:            }
2140:
2141:            private SimpleDocumentActionsWebService createStaticBindingService()
2142:                    throws Exception {
2143:                ObjectServiceFactory serviceFactory = new ObjectServiceFactory(
2144:                        new AegisBindingProvider());
2145:                XFireProxyFactory proxyFactory = new XFireProxyFactory();
2146:                Service serviceModel = serviceFactory
2147:                        .create(SimpleDocumentActionsWebService.class);
2148:                return (SimpleDocumentActionsWebService) proxyFactory.create(
2149:                        serviceModel, new URI(ENDPOINT_URL, false).toString());
2150:            }
2151:
2152:            public static class EncodedCommonsHttpMessageSender extends
2153:                    CommonsHttpMessageSender {
2154:
2155:                public EncodedCommonsHttpMessageSender(OutMessage message,
2156:                        MessageContext context) {
2157:                    super (message, context);
2158:                }
2159:
2160:                @Override
2161:                public String getUri() {
2162:                    System.err.println("super.getUri(): " + super .getUri());
2163:                    try {
2164:                        return new URI(super .getUri(), false).toString();
2165:                    } catch (URIException e) {
2166:                        throw new RuntimeException(e);
2167:                    }
2168:                }
2169:
2170:            }
2171:
2172:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.