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.util.Iterator;
0020: import java.util.List;
0021:
0022: import org.junit.Test;
0023: import org.kuali.workflow.test.WorkflowTestCase;
0024:
0025: import edu.iu.uis.eden.EdenConstants;
0026: import edu.iu.uis.eden.KEWServiceLocator;
0027: import edu.iu.uis.eden.actionrequests.ActionRequestValue;
0028: import edu.iu.uis.eden.applicationconstants.ApplicationConstant;
0029: import edu.iu.uis.eden.clientapp.WorkflowDocument;
0030: import edu.iu.uis.eden.clientapp.WorkflowInfo;
0031: import edu.iu.uis.eden.clientapp.vo.ActionRequestVO;
0032: import edu.iu.uis.eden.clientapp.vo.DocumentDetailVO;
0033: import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
0034: import edu.iu.uis.eden.clientapp.vo.ReportActionToTakeVO;
0035: import edu.iu.uis.eden.clientapp.vo.ReportCriteriaVO;
0036: import edu.iu.uis.eden.clientapp.vo.RuleExtensionVO;
0037: import edu.iu.uis.eden.clientapp.vo.RuleReportCriteriaVO;
0038: import edu.iu.uis.eden.clientapp.vo.RuleResponsibilityVO;
0039: import edu.iu.uis.eden.clientapp.vo.RuleVO;
0040: import edu.iu.uis.eden.clientapp.vo.UserIdVO;
0041: import edu.iu.uis.eden.clientapp.vo.WorkgroupNameIdVO;
0042: import edu.iu.uis.eden.util.Utilities;
0043:
0044: public class WorkflowUtilityTest extends WorkflowTestCase {
0045:
0046: private WorkflowUtility utility;
0047:
0048: protected void loadTestData() throws Exception {
0049: loadXmlFile("WorkflowUtilityConfig.xml");
0050: }
0051:
0052: protected void setUpTransaction() throws Exception {
0053: super .setUpTransaction();
0054: utility = KEWServiceLocator.getWorkflowUtilityService();
0055: }
0056:
0057: @Test
0058: public void testIsUserInRouteLog() throws Exception {
0059: WorkflowDocument document = new WorkflowDocument(
0060: new NetworkIdVO("ewestfal"),
0061: SeqSetup.DOCUMENT_TYPE_NAME);
0062: document.routeDocument("");
0063: assertTrue(document.stateIsEnroute());
0064: assertTrue("User should be authenticated.", utility
0065: .isUserInRouteLog(document.getRouteHeaderId(),
0066: new NetworkIdVO("ewestfal"), false));
0067: assertTrue("User should be authenticated.", utility
0068: .isUserInRouteLog(document.getRouteHeaderId(),
0069: new NetworkIdVO("bmcgough"), false));
0070: assertTrue("User should be authenticated.", utility
0071: .isUserInRouteLog(document.getRouteHeaderId(),
0072: new NetworkIdVO("rkirkend"), false));
0073: assertFalse("User should not be authenticated.", utility
0074: .isUserInRouteLog(document.getRouteHeaderId(),
0075: new NetworkIdVO("pmckown"), false));
0076: assertFalse("User should not be authenticated.", utility
0077: .isUserInRouteLog(document.getRouteHeaderId(),
0078: new NetworkIdVO("temay"), false));
0079: assertFalse("User should not be authenticated.", utility
0080: .isUserInRouteLog(document.getRouteHeaderId(),
0081: new NetworkIdVO("jhopf"), false));
0082: assertTrue("User should be authenticated.", utility
0083: .isUserInRouteLog(document.getRouteHeaderId(),
0084: new NetworkIdVO("pmckown"), true));
0085: assertTrue("User should be authenticated.", utility
0086: .isUserInRouteLog(document.getRouteHeaderId(),
0087: new NetworkIdVO("temay"), true));
0088: assertTrue("User should be authenticated.", utility
0089: .isUserInRouteLog(document.getRouteHeaderId(),
0090: new NetworkIdVO("jhopf"), true));
0091:
0092: // test that we can run isUserInRouteLog on a SAVED document
0093: document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
0094: SeqSetup.DOCUMENT_TYPE_NAME);
0095: document.saveDocument("");
0096: assertTrue(document.stateIsSaved());
0097: assertTrue("User should be authenticated.", utility
0098: .isUserInRouteLog(document.getRouteHeaderId(),
0099: new NetworkIdVO("ewestfal"), false));
0100: assertFalse("User should not be authenticated.", utility
0101: .isUserInRouteLog(document.getRouteHeaderId(),
0102: new NetworkIdVO("bmcgough"), false));
0103: assertFalse("User should not be authenticated.", utility
0104: .isUserInRouteLog(document.getRouteHeaderId(),
0105: new NetworkIdVO("rkirkend"), false));
0106: assertFalse("User should not be authenticated.", utility
0107: .isUserInRouteLog(document.getRouteHeaderId(),
0108: new NetworkIdVO("pmckown"), false));
0109: assertFalse("User should not be authenticated.", utility
0110: .isUserInRouteLog(document.getRouteHeaderId(),
0111: new NetworkIdVO("temay"), false));
0112: assertFalse("User should not be authenticated.", utility
0113: .isUserInRouteLog(document.getRouteHeaderId(),
0114: new NetworkIdVO("jhopf"), false));
0115:
0116: // now look all up in the future of this saved document
0117: assertTrue("User should be authenticated.", utility
0118: .isUserInRouteLog(document.getRouteHeaderId(),
0119: new NetworkIdVO("bmcgough"), true));
0120: assertTrue("User should be authenticated.", utility
0121: .isUserInRouteLog(document.getRouteHeaderId(),
0122: new NetworkIdVO("rkirkend"), true));
0123: assertTrue("User should be authenticated.", utility
0124: .isUserInRouteLog(document.getRouteHeaderId(),
0125: new NetworkIdVO("pmckown"), true));
0126: assertTrue("User should be authenticated.", utility
0127: .isUserInRouteLog(document.getRouteHeaderId(),
0128: new NetworkIdVO("temay"), true));
0129: assertTrue("User should be authenticated.", utility
0130: .isUserInRouteLog(document.getRouteHeaderId(),
0131: new NetworkIdVO("jhopf"), true));
0132: }
0133:
0134: public abstract interface ReportCriteriaGenerator {
0135: public abstract ReportCriteriaVO buildCriteria(
0136: WorkflowDocument workflowDoc) throws Exception;
0137: }
0138:
0139: @Test
0140: public void testDocumentWillHaveApproveOrCompleteRequestAtNode_RouteHeaderId()
0141: throws Exception {
0142: ReportCriteriaGenerator generator = new ReportCriteriaGenerator() {
0143: public ReportCriteriaVO buildCriteria(
0144: WorkflowDocument workflowDoc) throws Exception {
0145: ReportCriteriaVO criteria = new ReportCriteriaVO(
0146: workflowDoc.getRouteHeaderId());
0147: return criteria;
0148: }
0149: };
0150: runDocumentWillHaveApproveOrCompleteRequestAtNode(generator);
0151: }
0152:
0153: @Test
0154: public void testDocumentWillHaveApproveOrCompleteRequestAtNode_XmlContent()
0155: throws Exception {
0156: ReportCriteriaGenerator generator = new ReportCriteriaGenerator() {
0157: public ReportCriteriaVO buildCriteria(
0158: WorkflowDocument workflowDoc) throws Exception {
0159: ReportCriteriaVO criteria = new ReportCriteriaVO(
0160: workflowDoc.getDocumentType());
0161: criteria.setXmlContent(workflowDoc.getDocumentContent()
0162: .getApplicationContent());
0163: return criteria;
0164: }
0165: };
0166: runDocumentWillHaveApproveOrCompleteRequestAtNode(generator);
0167: }
0168:
0169: private void runDocumentWillHaveApproveOrCompleteRequestAtNode(
0170: ReportCriteriaGenerator generator) throws Exception {
0171: /*
0172: name="WorkflowDocument"
0173: - bmcgough - Approve - false
0174: - rkirkend - Approve - false
0175: name="WorkflowDocument2"
0176: - pmckown - Approve - false
0177: name="Acknowledge1"
0178: - temay - Ack - false
0179: name="Acknowledge2"
0180: - jhopf - Ack - false
0181: */
0182: WorkflowDocument document = new WorkflowDocument(
0183: new NetworkIdVO("ewestfal"),
0184: SeqSetup.DOCUMENT_TYPE_NAME);
0185:
0186: ReportCriteriaVO reportCriteriaVO = generator
0187: .buildCriteria(document);
0188: // ReportCriteriaVO reportCriteriaVO = new ReportCriteriaVO(document.getRouteHeaderId());
0189: reportCriteriaVO.setTargetNodeName("WorkflowDocument2");
0190: reportCriteriaVO.setRoutingUser(new NetworkIdVO("bmcgough"));
0191: assertTrue(
0192: "Document should have one unfulfilled approve/complete request",
0193: utility
0194: .documentWillHaveAtLeastOneActionRequest(
0195: reportCriteriaVO,
0196: new String[] {
0197: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0198: EdenConstants.ACTION_REQUEST_COMPLETE_REQ }));
0199: reportCriteriaVO
0200: .setTargetUsers(new UserIdVO[] { new NetworkIdVO(
0201: "bmcgough") });
0202: assertFalse(
0203: "Document should not have any unfulfilled approve/complete requests",
0204: utility
0205: .documentWillHaveAtLeastOneActionRequest(
0206: reportCriteriaVO,
0207: new String[] {
0208: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0209: EdenConstants.ACTION_REQUEST_COMPLETE_REQ }));
0210:
0211: reportCriteriaVO = new ReportCriteriaVO(document
0212: .getRouteHeaderId());
0213: reportCriteriaVO.setTargetNodeName("WorkflowDocument2");
0214: reportCriteriaVO.setRoutingUser(new NetworkIdVO("bmcgough"));
0215: ReportActionToTakeVO[] actionsToTake = new ReportActionToTakeVO[1];
0216: actionsToTake[0] = new ReportActionToTakeVO(
0217: EdenConstants.ACTION_TAKEN_APPROVED_CD,
0218: new NetworkIdVO("rkirkend"), "WorkflowDocument");
0219: reportCriteriaVO.setActionsToTake(actionsToTake);
0220: assertFalse(
0221: "Document should not have any unfulfilled approve/complete requests",
0222: utility
0223: .documentWillHaveAtLeastOneActionRequest(
0224: reportCriteriaVO,
0225: new String[] {
0226: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0227: EdenConstants.ACTION_REQUEST_COMPLETE_REQ }));
0228:
0229: reportCriteriaVO = new ReportCriteriaVO(document
0230: .getRouteHeaderId());
0231: reportCriteriaVO.setTargetNodeName("WorkflowDocument2");
0232: actionsToTake = new ReportActionToTakeVO[2];
0233: actionsToTake[0] = new ReportActionToTakeVO(
0234: EdenConstants.ACTION_TAKEN_APPROVED_CD,
0235: new NetworkIdVO("bmcgough"), "WorkflowDocument");
0236: actionsToTake[1] = new ReportActionToTakeVO(
0237: EdenConstants.ACTION_TAKEN_APPROVED_CD,
0238: new NetworkIdVO("rkirkend"), "WorkflowDocument");
0239: reportCriteriaVO.setActionsToTake(actionsToTake);
0240: reportCriteriaVO.setRoutingUser(new NetworkIdVO("pmckown"));
0241: assertFalse(
0242: "Document should not have any unfulfilled approve/complete requests",
0243: utility
0244: .documentWillHaveAtLeastOneActionRequest(
0245: reportCriteriaVO,
0246: new String[] {
0247: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0248: EdenConstants.ACTION_REQUEST_COMPLETE_REQ }));
0249:
0250: document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
0251: SeqSetup.DOCUMENT_TYPE_NAME);
0252: document.routeDocument("");
0253: assertTrue(document.stateIsEnroute());
0254:
0255: document = new WorkflowDocument(new NetworkIdVO("bmcgough"),
0256: document.getRouteHeaderId());
0257: document.approve("");
0258:
0259: document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
0260: document.getRouteHeaderId());
0261: document.approve("");
0262:
0263: reportCriteriaVO = new ReportCriteriaVO(document
0264: .getRouteHeaderId());
0265: reportCriteriaVO.setTargetNodeName("WorkflowDocument2");
0266: assertTrue(
0267: "Document should have one unfulfilled approve/complete request",
0268: utility
0269: .documentWillHaveAtLeastOneActionRequest(
0270: reportCriteriaVO,
0271: new String[] {
0272: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0273: EdenConstants.ACTION_REQUEST_COMPLETE_REQ }));
0274:
0275: document = new WorkflowDocument(new NetworkIdVO("pmckown"),
0276: document.getRouteHeaderId());
0277: document.approve("");
0278: assertTrue(document.stateIsProcessed());
0279:
0280: reportCriteriaVO = new ReportCriteriaVO(document
0281: .getRouteHeaderId());
0282: reportCriteriaVO.setTargetNodeName("Acknowledge1");
0283: assertFalse(
0284: "Document should not have any unfulfilled approve/complete requests when in processed status",
0285: utility
0286: .documentWillHaveAtLeastOneActionRequest(
0287: reportCriteriaVO,
0288: new String[] {
0289: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0290: EdenConstants.ACTION_REQUEST_COMPLETE_REQ }));
0291:
0292: reportCriteriaVO = new ReportCriteriaVO(document
0293: .getRouteHeaderId());
0294: reportCriteriaVO.setTargetNodeName("Acknowledge1");
0295: assertTrue(
0296: "Document should have one unfulfilled Ack request when in final status",
0297: utility
0298: .documentWillHaveAtLeastOneActionRequest(
0299: reportCriteriaVO,
0300: new String[] { EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ }));
0301:
0302: document = new WorkflowDocument(new NetworkIdVO("temay"),
0303: document.getRouteHeaderId());
0304: document.acknowledge("");
0305: assertTrue(document.stateIsProcessed());
0306:
0307: reportCriteriaVO = new ReportCriteriaVO(document
0308: .getRouteHeaderId());
0309: reportCriteriaVO.setTargetNodeName("Acknowledge1");
0310: assertFalse(
0311: "Document should not have any unfulfilled Ack requests as node 'Acknowledge1' at this time",
0312: utility
0313: .documentWillHaveAtLeastOneActionRequest(
0314: reportCriteriaVO,
0315: new String[] { EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ }));
0316:
0317: document = new WorkflowDocument(new NetworkIdVO("jhopf"),
0318: document.getRouteHeaderId());
0319: document.acknowledge("");
0320:
0321: reportCriteriaVO = new ReportCriteriaVO(document
0322: .getRouteHeaderId());
0323: reportCriteriaVO.setTargetNodeName("Acknowledge2");
0324: assertFalse(
0325: "Document should not have any unfulfilled approve/complete requests when in final status",
0326: utility
0327: .documentWillHaveAtLeastOneActionRequest(
0328: reportCriteriaVO,
0329: new String[] {
0330: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0331: EdenConstants.ACTION_REQUEST_COMPLETE_REQ }));
0332:
0333: reportCriteriaVO = new ReportCriteriaVO(document
0334: .getRouteHeaderId());
0335: reportCriteriaVO.setTargetNodeName("Acknowledge2");
0336: assertFalse(
0337: "Document should not have any unfulfilled FYI requests when in final status",
0338: utility
0339: .documentWillHaveAtLeastOneActionRequest(
0340: reportCriteriaVO,
0341: new String[] { EdenConstants.ACTION_REQUEST_FYI_REQ }));
0342:
0343: }
0344:
0345: @Test
0346: public void testIsLastApprover() throws Exception {
0347: // test the is last approver in route level against our sequential document type
0348: WorkflowDocument document = new WorkflowDocument(
0349: new NetworkIdVO("ewestfal"),
0350: SeqSetup.DOCUMENT_TYPE_NAME);
0351: document.saveRoutingData();
0352:
0353: // the initial "route level" should have no requests initially so it should return false
0354: assertFalse("Should not be last approver.", utility
0355: .isLastApproverInRouteLevel(
0356: document.getRouteHeaderId(), new NetworkIdVO(
0357: "ewestfal"), new Integer(0)));
0358: assertFalse("Should not be last approver.", utility
0359: .isLastApproverAtNode(document.getRouteHeaderId(),
0360: new NetworkIdVO("ewestfal"),
0361: SeqSetup.ADHOC_NODE));
0362:
0363: // app specific route a request to a workgroup at the initial node (TestWorkgroup)
0364: document.appSpecificRouteDocumentToWorkgroup(
0365: EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc", "",
0366: new WorkgroupNameIdVO("TestWorkgroup"), "", false);
0367: assertTrue("Should be last approver.", utility
0368: .isLastApproverInRouteLevel(
0369: document.getRouteHeaderId(), new NetworkIdVO(
0370: "ewestfal"), new Integer(0)));
0371: assertTrue("Should be last approver.", utility
0372: .isLastApproverAtNode(document.getRouteHeaderId(),
0373: new NetworkIdVO("ewestfal"),
0374: SeqSetup.ADHOC_NODE));
0375:
0376: // app specific route a request to a member of the workgroup (jitrue)
0377: document.appSpecificRouteDocumentToUser(
0378: EdenConstants.ACTION_REQUEST_APPROVE_REQ, "AdHoc", "",
0379: new NetworkIdVO("jitrue"), "", false);
0380: // member of the workgroup with the user request should be last approver
0381: assertTrue("Should be last approver.", utility
0382: .isLastApproverInRouteLevel(
0383: document.getRouteHeaderId(), new NetworkIdVO(
0384: "jitrue"), new Integer(0)));
0385: assertTrue("Should be last approver.", utility
0386: .isLastApproverAtNode(document.getRouteHeaderId(),
0387: new NetworkIdVO("jitrue"), SeqSetup.ADHOC_NODE));
0388: // other members of the workgroup will not be last approvers because they don't satisfy the individuals request (ewestfal)
0389: assertFalse("Should not be last approver.", utility
0390: .isLastApproverAtNode(document.getRouteHeaderId(),
0391: new NetworkIdVO("ewestfal"),
0392: SeqSetup.ADHOC_NODE));
0393:
0394: // route the document, should stay at the adhoc node until those requests have been completed
0395: document.routeDocument("");
0396: document = new WorkflowDocument(new NetworkIdVO("jitrue"),
0397: document.getRouteHeaderId());
0398: assertEquals("Document should be at adhoc node.",
0399: SeqSetup.ADHOC_NODE, document.getNodeNames()[0]);
0400: assertTrue("Approve should be requested.", document
0401: .isApprovalRequested());
0402: document.approve("");
0403:
0404: // document should now be at the WorkflowDocument node with a request to bmcgough and rkirkend
0405: document = new WorkflowDocument(new NetworkIdVO("bmcgough"),
0406: document.getRouteHeaderId());
0407: assertTrue("Approve should be requested.", document
0408: .isApprovalRequested());
0409: document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
0410: document.getRouteHeaderId());
0411: assertTrue("Approve should be requested.", document
0412: .isApprovalRequested());
0413: // since there are two requests, neither should be last approver
0414: assertFalse("Should not be last approver.", utility
0415: .isLastApproverAtNode(document.getRouteHeaderId(),
0416: new NetworkIdVO("bmcgough"),
0417: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0418: assertFalse("Should not be last approver.", utility
0419: .isLastApproverAtNode(document.getRouteHeaderId(),
0420: new NetworkIdVO("rkirkend"),
0421: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0422: document.approve("");
0423:
0424: // request to rirkend has been satisfied, now request to bmcgough is only request remaining at level so he should be last approver
0425: document = new WorkflowDocument(new NetworkIdVO("bmcgough"),
0426: document.getRouteHeaderId());
0427: assertTrue("Approve should be requested.", document
0428: .isApprovalRequested());
0429: assertTrue("Should be last approver.", utility
0430: .isLastApproverAtNode(document.getRouteHeaderId(),
0431: new NetworkIdVO("bmcgough"),
0432: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0433: document.approve("");
0434:
0435: }
0436:
0437: /**
0438: * This method tests how the isLastApproverAtNode method deals with ignore previous requests, there is an app constant
0439: * with the value specified in EdenConstants.IS_LAST_APPROVER_ACTIVATE_FIRST which dictates whether or not to simulate
0440: * activation of initialized requests before running the method.
0441: *
0442: * Tests the fix to issue http://fms.dfa.cornell.edu:8080/browse/KULWF-366
0443: */
0444: @Test
0445: public void testIsLastApproverActivation() throws Exception {
0446: // first test without the constant set
0447: ApplicationConstant appConstant = KEWServiceLocator
0448: .getApplicationConstantsService().findByName(
0449: EdenConstants.IS_LAST_APPROVER_ACTIVATE_FIRST);
0450: assertNull(
0451: "The IS_LAST_APPROVER_ACTIVATE_FIRST constant should not be set.",
0452: appConstant);
0453: WorkflowDocument document = new WorkflowDocument(
0454: new NetworkIdVO("ewestfal"),
0455: SeqSetup.LAST_APPROVER_DOCUMENT_TYPE_NAME);
0456: document.routeDocument("");
0457:
0458: // at the first node (WorkflowDocument) we should have a request to rkirkend, bmcgough and to ewestfal with ignorePrevious=true,
0459: assertEquals("We should be at the WorkflowDocument node.",
0460: SeqSetup.WORKFLOW_DOCUMENT_NODE, document
0461: .getNodeNames()[0]);
0462: assertFalse(
0463: "ewestfal should have not have approve because it's initiated",
0464: document.isApprovalRequested());
0465: document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
0466: document.getRouteHeaderId());
0467: assertFalse(
0468: "rkirkend should not have approve because it's initiated",
0469: document.isApprovalRequested());
0470: document = new WorkflowDocument(new NetworkIdVO("bmcgough"),
0471: document.getRouteHeaderId());
0472: assertTrue("bmcgough should have approve", document
0473: .isApprovalRequested());
0474: List actionRequests = KEWServiceLocator
0475: .getActionRequestService().findPendingByDoc(
0476: document.getRouteHeaderId());
0477: assertEquals("Should be 3 pending requests.", 3, actionRequests
0478: .size());
0479: // the requests to bmcgough should be activated, the request to rkirkend should be initialized,
0480: // and the request to ewestfal should be initialized and ignorePrevious=true
0481: boolean foundBmcgoughRequest = false;
0482: boolean foundRkirkendRequest = false;
0483: boolean foundEwestfalRequest = false;
0484: for (Iterator iterator = actionRequests.iterator(); iterator
0485: .hasNext();) {
0486: ActionRequestValue actionRequest = (ActionRequestValue) iterator
0487: .next();
0488: String netId = actionRequest.getWorkflowUser()
0489: .getAuthenticationUserId().getId();
0490: if ("bmcgough".equals(netId)) {
0491: assertTrue("Request to bmcgough should be activated.",
0492: actionRequest.isActive());
0493: foundBmcgoughRequest = true;
0494: } else if ("rkirkend".equals(netId)) {
0495: assertTrue(
0496: "Request to rkirkend should be initialized.",
0497: actionRequest.isInitialized());
0498: foundRkirkendRequest = true;
0499: } else if ("ewestfal".equals(netId)) {
0500: assertTrue(
0501: "Request to ewestfal should be initialized.",
0502: actionRequest.isInitialized());
0503: assertTrue(
0504: "Request to ewestfal should be ignorePrevious.",
0505: actionRequest.getIgnorePrevAction()
0506: .booleanValue());
0507: foundEwestfalRequest = true;
0508: }
0509: }
0510: assertTrue("Did not find request to bmcgough.",
0511: foundBmcgoughRequest);
0512: assertTrue("Did not find request to rkirkend.",
0513: foundRkirkendRequest);
0514: assertTrue("Did not find request to ewestfal.",
0515: foundEwestfalRequest);
0516:
0517: // at this point, neither bmcgough, rkirkend nor ewestfal should be the last approver
0518: assertFalse("Bmcgough should not be the final approver.",
0519: utility.isLastApproverAtNode(document
0520: .getRouteHeaderId(),
0521: new NetworkIdVO("bmcgough"),
0522: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0523: assertFalse("Rkirkend should not be the final approver.",
0524: utility.isLastApproverAtNode(document
0525: .getRouteHeaderId(),
0526: new NetworkIdVO("rkirkend"),
0527: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0528: assertFalse("Ewestfal should not be the final approver.",
0529: utility.isLastApproverAtNode(document
0530: .getRouteHeaderId(),
0531: new NetworkIdVO("ewestfal"),
0532: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0533:
0534: // approve as bmcgough
0535: document = new WorkflowDocument(new NetworkIdVO("bmcgough"),
0536: document.getRouteHeaderId());
0537: document.approve("");
0538:
0539: // still, neither rkirkend nor ewestfal should be "final approver"
0540: // at this point, neither bmcgough, rkirkend nor ewestfal should be the last approver
0541: assertFalse("Rkirkend should not be the final approver.",
0542: utility.isLastApproverAtNode(document
0543: .getRouteHeaderId(),
0544: new NetworkIdVO("rkirkend"),
0545: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0546: assertFalse("Ewestfal should not be the final approver.",
0547: utility.isLastApproverAtNode(document
0548: .getRouteHeaderId(),
0549: new NetworkIdVO("ewestfal"),
0550: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0551:
0552: // approve as rkirkend
0553: document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
0554: document.getRouteHeaderId());
0555: document.approve("");
0556:
0557: // should be one pending activated to ewestfal now
0558: actionRequests = KEWServiceLocator.getActionRequestService()
0559: .findPendingByDoc(document.getRouteHeaderId());
0560: assertEquals("Should be 1 pending requests.", 1, actionRequests
0561: .size());
0562: ActionRequestValue actionRequest = (ActionRequestValue) actionRequests
0563: .get(0);
0564: assertTrue("Should be activated.", actionRequest.isActive());
0565:
0566: // ewestfal should now be the final approver
0567: assertTrue("Ewestfal should be the final approver.", utility
0568: .isLastApproverAtNode(document.getRouteHeaderId(),
0569: new NetworkIdVO("ewestfal"),
0570: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0571:
0572: // approve as ewestfal to send to next node
0573: document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
0574: document.getRouteHeaderId());
0575: assertTrue("ewestfal should have approve request", document
0576: .isApprovalRequested());
0577: document.approve("");
0578:
0579: // should be at the workflow document 2 node
0580: assertEquals("Should be at the WorkflowDocument2 Node.",
0581: SeqSetup.WORKFLOW_DOCUMENT_2_NODE, document
0582: .getNodeNames()[0]);
0583: // at this node there should be two requests, one to ewestfal with ignorePrevious=false and one to pmckown,
0584: // since we haven't set the application constant, the non-ignore previous request won't be activated first so pmckown
0585: // will not be the final approver
0586: assertFalse("Pmckown should not be the final approver.",
0587: utility.isLastApproverAtNode(document
0588: .getRouteHeaderId(),
0589: new NetworkIdVO("pmckown"),
0590: SeqSetup.WORKFLOW_DOCUMENT_2_NODE));
0591: assertFalse("Ewestfal should not be the final approver.",
0592: utility.isLastApproverAtNode(document
0593: .getRouteHeaderId(),
0594: new NetworkIdVO("ewestfal"),
0595: SeqSetup.WORKFLOW_DOCUMENT_2_NODE));
0596: actionRequests = KEWServiceLocator.getActionRequestService()
0597: .findPendingByDoc(document.getRouteHeaderId());
0598: assertEquals("Should be 2 action requests.", 2, actionRequests
0599: .size());
0600:
0601: // Now set up the app constant that checks ignore previous properly and try a new document
0602: appConstant = new ApplicationConstant();
0603: appConstant
0604: .setApplicationConstantName(EdenConstants.IS_LAST_APPROVER_ACTIVATE_FIRST);
0605: appConstant.setApplicationConstantValue("true");
0606: // TODO FIX this when we figure out what's up with the flusing problem in the tests
0607: KEWServiceLocator.getApplicationConstantsService().save(
0608: appConstant);
0609:
0610: appConstant = KEWServiceLocator
0611: .getApplicationConstantsService().findByName(
0612: EdenConstants.IS_LAST_APPROVER_ACTIVATE_FIRST);
0613: assertNotNull("AppConstant should not be null.", appConstant);
0614: assertEquals("AppConstant should be true.", "true", appConstant
0615: .getApplicationConstantValue());
0616: // check Utilities class
0617: String appConstantValue = Utilities
0618: .getApplicationConstant(EdenConstants.IS_LAST_APPROVER_ACTIVATE_FIRST);
0619: assertEquals("AppConstant should be true.", "true",
0620: appConstantValue);
0621:
0622: document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
0623: SeqSetup.LAST_APPROVER_DOCUMENT_TYPE_NAME);
0624: document.routeDocument("");
0625:
0626: // at this point, neither bmcgough, rkirkend nor ewestfal should be the last approver
0627: assertFalse("Bmcgough should not be the final approver.",
0628: utility.isLastApproverAtNode(document
0629: .getRouteHeaderId(),
0630: new NetworkIdVO("bmcgough"),
0631: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0632: assertFalse("Rkirkend should not be the final approver.",
0633: utility.isLastApproverAtNode(document
0634: .getRouteHeaderId(),
0635: new NetworkIdVO("rkirkend"),
0636: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0637: assertFalse("Ewestfal should not be the final approver.",
0638: utility.isLastApproverAtNode(document
0639: .getRouteHeaderId(),
0640: new NetworkIdVO("ewestfal"),
0641: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0642:
0643: // approve as bmcgough
0644: document = new WorkflowDocument(new NetworkIdVO("bmcgough"),
0645: document.getRouteHeaderId());
0646: document.approve("");
0647:
0648: // now there is just a request to rkirkend and ewestfal, since ewestfal is ignore previous true, neither should be final approver
0649: assertFalse("Rkirkend should not be the final approver.",
0650: utility.isLastApproverAtNode(document
0651: .getRouteHeaderId(),
0652: new NetworkIdVO("rkirkend"),
0653: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0654: assertFalse("Ewestfal should not be the final approver.",
0655: utility.isLastApproverAtNode(document
0656: .getRouteHeaderId(),
0657: new NetworkIdVO("ewestfal"),
0658: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0659:
0660: // approve as ewestfal
0661: document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
0662: document.getRouteHeaderId());
0663: document.approve("");
0664:
0665: // rkirkend should now be the final approver
0666: assertTrue("Rkirkend should now be the final approver.",
0667: utility.isLastApproverAtNode(document
0668: .getRouteHeaderId(),
0669: new NetworkIdVO("rkirkend"),
0670: SeqSetup.WORKFLOW_DOCUMENT_NODE));
0671:
0672: // approve as rkirkend to send it to the next node
0673: document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
0674: document.getRouteHeaderId());
0675: document.approve("");
0676:
0677: // now, there are requests to pmckown and ewestfal here, the request to ewestfal is ingorePrevious=false and since ewestfal
0678: // routed the document, this request should be auto-approved. However, it's priority is 2 so it is activated after the
0679: // request to pmckown which is the situation we are testing
0680: assertTrue("Pmckown should be the final approver.", utility
0681: .isLastApproverAtNode(document.getRouteHeaderId(),
0682: new NetworkIdVO("pmckown"),
0683: SeqSetup.WORKFLOW_DOCUMENT_2_NODE));
0684: assertFalse("Ewestfal should not be the final approver.",
0685: utility.isLastApproverAtNode(document
0686: .getRouteHeaderId(),
0687: new NetworkIdVO("ewestfal"),
0688: SeqSetup.WORKFLOW_DOCUMENT_2_NODE));
0689:
0690: // if we approve as pmckown, the document should go into acknowledgement and become processed
0691: document = new WorkflowDocument(new NetworkIdVO("pmckown"),
0692: document.getRouteHeaderId());
0693: document.approve("");
0694: assertTrue("Document should be processed.", document
0695: .stateIsProcessed());
0696:
0697: }
0698:
0699: @Test
0700: public void testIsFinalApprover() throws Exception {
0701: // for this document, pmckown should be the final approver
0702: WorkflowDocument document = new WorkflowDocument(
0703: new NetworkIdVO("ewestfal"),
0704: SeqSetup.DOCUMENT_TYPE_NAME);
0705: assertFinalApprover(document);
0706: }
0707:
0708: @Test
0709: public void testIsFinalApproverChild() throws Exception {
0710: // 12-13-2005: HR ran into a bug where this method was not correctly locating the final approver node when using a document type whic
0711: // inherits the route from a parent, so we will incorporate this into the unit test to prevent regression
0712: WorkflowDocument childDocument = new WorkflowDocument(
0713: new NetworkIdVO("ewestfal"),
0714: SeqSetup.CHILD_DOCUMENT_TYPE_NAME);
0715: assertFinalApprover(childDocument);
0716: }
0717:
0718: /**
0719: * Factored out so as not to duplicate a bunch of code between testIsFinalApprover and testIsFinalApproverChild.
0720: */
0721: private void assertFinalApprover(WorkflowDocument document)
0722: throws Exception {
0723: document.routeDocument("");
0724:
0725: document = new WorkflowDocument(new NetworkIdVO("bmcgough"),
0726: document.getRouteHeaderId());
0727: assertTrue("Document should be enroute.", document
0728: .stateIsEnroute());
0729: assertTrue("Should have approve request.", document
0730: .isApprovalRequested());
0731:
0732: // bmcgough is not the final approver
0733: assertFalse("Should not be final approver.", utility
0734: .isFinalApprover(document.getRouteHeaderId(),
0735: new NetworkIdVO("bmcgough")));
0736: // approve as bmcgough
0737: document.approve("");
0738:
0739: // should be to Ryan now, who is also not the final approver on the document
0740: document = new WorkflowDocument(new NetworkIdVO("rkirkend"),
0741: document.getRouteHeaderId());
0742: assertTrue("Document should be enroute.", document
0743: .stateIsEnroute());
0744: assertTrue("Should have approve request.", document
0745: .isApprovalRequested());
0746: assertFalse("Should not be final approver.", utility
0747: .isFinalApprover(document.getRouteHeaderId(),
0748: new NetworkIdVO("rkirkend")));
0749: document.approve("");
0750:
0751: // should be to Phil now, who *IS* the final approver on the document
0752: document = new WorkflowDocument(new NetworkIdVO("pmckown"),
0753: document.getRouteHeaderId());
0754: assertTrue("Document should be enroute.", document
0755: .stateIsEnroute());
0756: assertTrue("Should have approve request.", document
0757: .isApprovalRequested());
0758: assertTrue("Should be final approver.", utility
0759: .isFinalApprover(document.getRouteHeaderId(),
0760: new NetworkIdVO("pmckown")));
0761:
0762: // now adhoc an approve to temay, phil should no longer be the final approver
0763: document.appSpecificRouteDocumentToUser(
0764: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0765: SeqSetup.WORKFLOW_DOCUMENT_2_NODE, "", new NetworkIdVO(
0766: "temay"), "", true);
0767: assertFalse("Should not be final approver.", utility
0768: .isFinalApprover(document.getRouteHeaderId(),
0769: new NetworkIdVO("pmckown")));
0770: assertFalse("Should not be final approver.", utility
0771: .isFinalApprover(document.getRouteHeaderId(),
0772: new NetworkIdVO("temay")));
0773:
0774: // now approve as temay and then adhoc an ack to jeremy
0775: document = new WorkflowDocument(new NetworkIdVO("temay"),
0776: document.getRouteHeaderId());
0777: assertTrue("SHould have approve request.", document
0778: .isApprovalRequested());
0779: document.approve("");
0780:
0781: // phil should be final approver again
0782: assertTrue("Should be final approver.", utility
0783: .isFinalApprover(document.getRouteHeaderId(),
0784: new NetworkIdVO("pmckown")));
0785: document.appSpecificRouteDocumentToUser(
0786: EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
0787: SeqSetup.WORKFLOW_DOCUMENT_2_NODE, "", new NetworkIdVO(
0788: "jhopf"), "", true);
0789: document = new WorkflowDocument(new NetworkIdVO("jhopf"),
0790: document.getRouteHeaderId());
0791: assertTrue("Should have acknowledge request.", document
0792: .isAcknowledgeRequested());
0793:
0794: // now there should be an approve to phil and an ack to jeremy, so phil should be the final approver and jeremy should not
0795: assertTrue("Should be final approver.", utility
0796: .isFinalApprover(document.getRouteHeaderId(),
0797: new NetworkIdVO("pmckown")));
0798: assertFalse("Should not be final approver.", utility
0799: .isFinalApprover(document.getRouteHeaderId(),
0800: new NetworkIdVO("jhopf")));
0801:
0802: // after approving as phil, the document should go processed
0803: document = new WorkflowDocument(new NetworkIdVO("pmckown"),
0804: document.getRouteHeaderId());
0805: document.approve("");
0806: assertTrue("Document should be processed.", document
0807: .stateIsProcessed());
0808: }
0809:
0810: @Test
0811: public void testRoutingReportOnDocumentType() throws Exception {
0812: WorkflowInfo info = new WorkflowInfo();
0813: ReportCriteriaVO criteria = new ReportCriteriaVO("SeqDocType");
0814: criteria
0815: .setRuleTemplateNames(new String[] { "WorkflowDocumentTemplate" });
0816: DocumentDetailVO documentDetail = info.routingReport(criteria);
0817: assertNotNull(documentDetail);
0818: assertEquals("Should have been 2 requests generated.", 2,
0819: documentDetail.getActionRequests().length);
0820:
0821: // let's try doing both WorkflowDocumentTemplate and WorkflowDocumentTemplate2 together
0822: criteria
0823: .setRuleTemplateNames(new String[] {
0824: "WorkflowDocumentTemplate",
0825: "WorkflowDocument2Template" });
0826: documentDetail = info.routingReport(criteria);
0827: assertEquals("Should have been 3 requests generated.", 3,
0828: documentDetail.getActionRequests().length);
0829:
0830: boolean foundRkirkend = false;
0831: boolean foundBmcgough = false;
0832: boolean foundPmckown = false;
0833: for (int index = 0; index < documentDetail.getActionRequests().length; index++) {
0834: ActionRequestVO actionRequest = documentDetail
0835: .getActionRequests()[index];
0836: String netId = actionRequest.getUserVO().getNetworkId();
0837: if (netId.equals("rkirkend")) {
0838: foundRkirkend = true;
0839: assertEquals(SeqSetup.WORKFLOW_DOCUMENT_NODE,
0840: actionRequest.getNodeName());
0841: } else if (netId.equals("bmcgough")) {
0842: foundBmcgough = true;
0843: assertEquals(SeqSetup.WORKFLOW_DOCUMENT_NODE,
0844: actionRequest.getNodeName());
0845: } else if (netId.equals("pmckown")) {
0846: foundPmckown = true;
0847: assertEquals(SeqSetup.WORKFLOW_DOCUMENT_2_NODE,
0848: actionRequest.getNodeName());
0849: }
0850: }
0851: assertTrue("Did not find request for rkirkend", foundRkirkend);
0852: assertTrue("Did not find request for bmcgough", foundBmcgough);
0853: assertTrue("Did not find request for pmckown", foundPmckown);
0854:
0855: }
0856:
0857: @Test
0858: public void testRuleReportGeneralFunction() throws Exception {
0859: WorkflowInfo info = new WorkflowInfo();
0860:
0861: RuleReportCriteriaVO ruleReportCriteria = null;
0862: this
0863: .ruleExceptionTest(info, ruleReportCriteria,
0864: "Sending in null RuleReportCriteriaVO should throw Exception");
0865:
0866: ruleReportCriteria = new RuleReportCriteriaVO();
0867: this
0868: .ruleExceptionTest(info, ruleReportCriteria,
0869: "Sending in empty RuleReportCriteriaVO should throw Exception");
0870:
0871: ruleReportCriteria = new RuleReportCriteriaVO();
0872: ruleReportCriteria.setResponsibleUser(new NetworkIdVO(
0873: "hobo_man"));
0874: this
0875: .ruleExceptionTest(info, ruleReportCriteria,
0876: "Sending in an invalid User Network ID should throw Exception");
0877:
0878: ruleReportCriteria = new RuleReportCriteriaVO();
0879: ruleReportCriteria
0880: .setResponsibleWorkgroup(new WorkgroupNameIdVO(
0881: "hobos_united"));
0882: this
0883: .ruleExceptionTest(info, ruleReportCriteria,
0884: "Sending in an invalid Workgroup Name should throw Exception");
0885:
0886: ruleReportCriteria = new RuleReportCriteriaVO();
0887: RuleExtensionVO ruleExtensionVO = new RuleExtensionVO("key",
0888: "value");
0889: ruleReportCriteria
0890: .setRuleExtensionVOs(new RuleExtensionVO[] { ruleExtensionVO });
0891: this
0892: .ruleExceptionTest(
0893: info,
0894: ruleReportCriteria,
0895: "Sending in one or more RuleExtentionVO objects with no Rule Template Name should throw Exception");
0896:
0897: RuleVO[] rules = null;
0898: ruleReportCriteria = new RuleReportCriteriaVO();
0899: ruleReportCriteria
0900: .setConsiderWorkgroupMembership(Boolean.FALSE);
0901: ruleReportCriteria
0902: .setDocumentTypeName(RuleTestGeneralSetup.DOCUMENT_TYPE_NAME);
0903: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
0904: rules = info.ruleReport(ruleReportCriteria);
0905: assertEquals("Number of Rules Returned Should be 3", 3,
0906: rules.length);
0907:
0908: rules = null;
0909: ruleReportCriteria = new RuleReportCriteriaVO();
0910: ruleReportCriteria
0911: .setActionRequestCodes(new String[] { EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ });
0912: ruleReportCriteria
0913: .setConsiderWorkgroupMembership(Boolean.FALSE);
0914: ruleReportCriteria
0915: .setDocumentTypeName(RuleTestGeneralSetup.DOCUMENT_TYPE_NAME);
0916: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
0917: ruleReportCriteria.setResponsibleUser(new NetworkIdVO("temay"));
0918: rules = info.ruleReport(ruleReportCriteria);
0919: assertEquals("Number of Rules Returned Should be 0", 0,
0920: rules.length);
0921:
0922: rules = null;
0923: ruleReportCriteria = new RuleReportCriteriaVO();
0924: ruleReportCriteria
0925: .setActionRequestCodes(new String[] { EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ });
0926: ruleReportCriteria
0927: .setConsiderWorkgroupMembership(Boolean.FALSE);
0928: ruleReportCriteria
0929: .setDocumentTypeName(RuleTestGeneralSetup.DOCUMENT_TYPE_NAME);
0930: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
0931: rules = info.ruleReport(ruleReportCriteria);
0932: assertEquals("Number of Rules Returned Should be 1", 1,
0933: rules.length);
0934: // check the rule returned
0935: RuleVO ruleVO = rules[0];
0936: assertEquals("Rule Document Type is not "
0937: + RuleTestGeneralSetup.DOCUMENT_TYPE_NAME,
0938: RuleTestGeneralSetup.DOCUMENT_TYPE_NAME, ruleVO
0939: .getDocTypeName());
0940: assertEquals("Rule Template Named returned is not "
0941: + RuleTestGeneralSetup.RULE_TEST_TEMPLATE_2,
0942: RuleTestGeneralSetup.RULE_TEST_TEMPLATE_2, ruleVO
0943: .getRuleTemplateName());
0944: assertEquals("Rule did not have ignore previous set to false",
0945: Boolean.FALSE, ruleVO.getIgnorePrevious());
0946: assertEquals(
0947: "Number of Rule Responsibilities returned is incorrect",
0948: 2, ruleVO.getRuleResponsibilities().length);
0949: RuleResponsibilityVO responsibilityVO = null;
0950: for (int i = 0; i < ruleVO.getRuleResponsibilities().length; i++) {
0951: responsibilityVO = ruleVO.getRuleResponsibilities()[i];
0952: if ("temay".equals(responsibilityVO.getUser()
0953: .getNetworkId())) {
0954: assertEquals("Rule user is not correct", "temay",
0955: responsibilityVO.getUser().getNetworkId());
0956: assertEquals("Rule priority is incorrect", Integer
0957: .valueOf(1), responsibilityVO.getPriority());
0958: assertEquals("Rule should be Ack Request",
0959: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
0960: responsibilityVO.getActionRequestedCd());
0961: } else if ("ewestfal".equals(responsibilityVO.getUser()
0962: .getNetworkId())) {
0963: assertEquals("Rule user is not correct", "ewestfal",
0964: responsibilityVO.getUser().getNetworkId());
0965: assertEquals("Rule priority is incorrect", Integer
0966: .valueOf(2), responsibilityVO.getPriority());
0967: assertEquals("Rule should be Ack Request",
0968: EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
0969: responsibilityVO.getActionRequestedCd());
0970: } else {
0971: fail("Network ID of user for this responsibility is neither temay or ewestfal");
0972: }
0973: }
0974:
0975: rules = null;
0976: ruleVO = null;
0977: responsibilityVO = null;
0978: ruleReportCriteria = new RuleReportCriteriaVO();
0979: ruleReportCriteria
0980: .setConsiderWorkgroupMembership(Boolean.FALSE);
0981: ruleReportCriteria
0982: .setDocumentTypeName(RuleTestGeneralSetup.DOCUMENT_TYPE_NAME);
0983: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
0984: ruleReportCriteria.setResponsibleUser(new NetworkIdVO("temay"));
0985: rules = info.ruleReport(ruleReportCriteria);
0986: assertEquals("Number of Rules returned is not correct", 2,
0987: rules.length);
0988: for (int i = 0; i < rules.length; i++) {
0989: ruleVO = rules[i];
0990: if (RuleTestGeneralSetup.RULE_TEST_TEMPLATE_1.equals(ruleVO
0991: .getRuleTemplateName())) {
0992: assertEquals("Rule Document Type is not "
0993: + RuleTestGeneralSetup.DOCUMENT_TYPE_NAME,
0994: RuleTestGeneralSetup.DOCUMENT_TYPE_NAME, ruleVO
0995: .getDocTypeName());
0996: assertEquals("Rule Template Named returned is not "
0997: + RuleTestGeneralSetup.RULE_TEST_TEMPLATE_1,
0998: RuleTestGeneralSetup.RULE_TEST_TEMPLATE_1,
0999: ruleVO.getRuleTemplateName());
1000: assertEquals(
1001: "Rule did not have ignore previous set to true",
1002: Boolean.TRUE, ruleVO.getIgnorePrevious());
1003: assertEquals(
1004: "Number of Rule Responsibilities Returned Should be 1",
1005: 1, ruleVO.getRuleResponsibilities().length);
1006: responsibilityVO = ruleVO.getRuleResponsibilities()[0];
1007: assertEquals("Rule user is incorrect", "temay",
1008: responsibilityVO.getUser().getNetworkId());
1009: assertEquals("Rule priority is incorrect", Integer
1010: .valueOf(3), responsibilityVO.getPriority());
1011: assertEquals("Rule action request is incorrect",
1012: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
1013: responsibilityVO.getActionRequestedCd());
1014: } else if (RuleTestGeneralSetup.RULE_TEST_TEMPLATE_2
1015: .equals(ruleVO.getRuleTemplateName())) {
1016: assertEquals("Rule Document Type is not "
1017: + RuleTestGeneralSetup.DOCUMENT_TYPE_NAME,
1018: RuleTestGeneralSetup.DOCUMENT_TYPE_NAME, ruleVO
1019: .getDocTypeName());
1020: assertEquals("Rule Template Named returned is not "
1021: + RuleTestGeneralSetup.RULE_TEST_TEMPLATE_2,
1022: RuleTestGeneralSetup.RULE_TEST_TEMPLATE_2,
1023: ruleVO.getRuleTemplateName());
1024: assertEquals(
1025: "Rule did not have ignore previous set to false",
1026: Boolean.FALSE, ruleVO.getIgnorePrevious());
1027: assertEquals(
1028: "Number of Rule Responsibilities returned is incorrect",
1029: 2, ruleVO.getRuleResponsibilities().length);
1030: responsibilityVO = null;
1031: for (int l = 0; l < ruleVO.getRuleResponsibilities().length; l++) {
1032: responsibilityVO = ruleVO.getRuleResponsibilities()[l];
1033: if ("temay".equals(responsibilityVO.getUser()
1034: .getNetworkId())) {
1035: assertEquals("Rule user is not correct",
1036: "temay", responsibilityVO.getUser()
1037: .getNetworkId());
1038: assertEquals("Rule priority is incorrect",
1039: Integer.valueOf(1), responsibilityVO
1040: .getPriority());
1041: assertEquals(
1042: "Rule should be Ack Request",
1043: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
1044: responsibilityVO.getActionRequestedCd());
1045: } else if ("ewestfal".equals(responsibilityVO
1046: .getUser().getNetworkId())) {
1047: assertEquals("Rule user is not correct",
1048: "ewestfal", responsibilityVO.getUser()
1049: .getNetworkId());
1050: assertEquals("Rule priority is incorrect",
1051: Integer.valueOf(2), responsibilityVO
1052: .getPriority());
1053: assertEquals(
1054: "Rule should be Ack Request",
1055: EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
1056: responsibilityVO.getActionRequestedCd());
1057: } else {
1058: fail("Network ID of user for this responsibility is neither temay or ewestfal");
1059: }
1060: }
1061: } else {
1062: fail("Rule Template of returned rule is not of type "
1063: + RuleTestGeneralSetup.RULE_TEST_TEMPLATE_1
1064: + " nor "
1065: + RuleTestGeneralSetup.RULE_TEST_TEMPLATE_2);
1066: }
1067: }
1068:
1069: rules = null;
1070: ruleVO = null;
1071: responsibilityVO = null;
1072: ruleReportCriteria = new RuleReportCriteriaVO();
1073: ruleReportCriteria
1074: .setDocumentTypeName(RuleTestGeneralSetup.DOCUMENT_TYPE_NAME);
1075: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
1076: ruleReportCriteria
1077: .setResponsibleWorkgroup(new WorkgroupNameIdVO(
1078: RuleTestGeneralSetup.RULE_TEST_WORKGROUP));
1079: rules = info.ruleReport(ruleReportCriteria);
1080: assertEquals("Number of Rules Returned Should be 1", 1,
1081: rules.length);
1082: ruleVO = rules[0];
1083: assertEquals("Rule Document Type is not "
1084: + RuleTestGeneralSetup.DOCUMENT_TYPE_NAME,
1085: RuleTestGeneralSetup.DOCUMENT_TYPE_NAME, ruleVO
1086: .getDocTypeName());
1087: assertEquals("Rule Template Named returned is not "
1088: + RuleTestGeneralSetup.RULE_TEST_TEMPLATE_3,
1089: RuleTestGeneralSetup.RULE_TEST_TEMPLATE_3, ruleVO
1090: .getRuleTemplateName());
1091: assertEquals("Rule did not have ignore previous set to true",
1092: Boolean.TRUE, ruleVO.getIgnorePrevious());
1093: assertEquals(
1094: "Number of Rule Responsibilities Returned Should be 1",
1095: 1, ruleVO.getRuleResponsibilities().length);
1096: responsibilityVO = ruleVO.getRuleResponsibilities()[0];
1097: assertEquals("Rule workgroup name is incorrect",
1098: RuleTestGeneralSetup.RULE_TEST_WORKGROUP,
1099: responsibilityVO.getWorkgroup().getWorkgroupName());
1100: assertEquals("Rule priority is incorrect", Integer.valueOf(1),
1101: responsibilityVO.getPriority());
1102: assertEquals("Rule action request is incorrect",
1103: EdenConstants.ACTION_REQUEST_FYI_REQ, responsibilityVO
1104: .getActionRequestedCd());
1105:
1106: rules = null;
1107: ruleVO = null;
1108: responsibilityVO = null;
1109: ruleReportCriteria = new RuleReportCriteriaVO();
1110: ruleReportCriteria
1111: .setDocumentTypeName(RuleTestGeneralSetup.DOCUMENT_TYPE_NAME);
1112: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
1113: ruleReportCriteria.setResponsibleUser(new NetworkIdVO("user1"));
1114: rules = info.ruleReport(ruleReportCriteria);
1115: assertEquals("Number of Rules Returned Should be 1", 1,
1116: rules.length);
1117: ruleVO = rules[0];
1118: assertEquals("Rule Document Type is not "
1119: + RuleTestGeneralSetup.DOCUMENT_TYPE_NAME,
1120: RuleTestGeneralSetup.DOCUMENT_TYPE_NAME, ruleVO
1121: .getDocTypeName());
1122: assertEquals("Rule Template Named returned is not "
1123: + RuleTestGeneralSetup.RULE_TEST_TEMPLATE_3,
1124: RuleTestGeneralSetup.RULE_TEST_TEMPLATE_3, ruleVO
1125: .getRuleTemplateName());
1126: assertEquals("Rule did not have ignore previous set to true",
1127: Boolean.TRUE, ruleVO.getIgnorePrevious());
1128: assertEquals(
1129: "Number of Rule Responsibilities Returned Should be 1",
1130: 1, ruleVO.getRuleResponsibilities().length);
1131: responsibilityVO = ruleVO.getRuleResponsibilities()[0];
1132: assertEquals("Rule workgroup name is incorrect",
1133: RuleTestGeneralSetup.RULE_TEST_WORKGROUP,
1134: responsibilityVO.getWorkgroup().getWorkgroupName());
1135: assertEquals("Rule priority is incorrect", Integer.valueOf(1),
1136: responsibilityVO.getPriority());
1137: assertEquals("Rule action request is incorrect",
1138: EdenConstants.ACTION_REQUEST_FYI_REQ, responsibilityVO
1139: .getActionRequestedCd());
1140: }
1141:
1142: /**
1143: * Tests specific rule scenario relating to standard org review routing
1144: *
1145: * @throws Exception
1146: */
1147: @Test
1148: public void testRuleReportOrgReviewTest() throws Exception {
1149: loadXmlFile("WorkflowUtilityRuleReportConfig.xml");
1150: WorkflowInfo info = new WorkflowInfo();
1151: RuleReportCriteriaVO ruleReportCriteria = new RuleReportCriteriaVO();
1152: ruleReportCriteria
1153: .setDocumentTypeName(RuleTestOrgReviewSetup.DOCUMENT_TYPE_NAME);
1154: ruleReportCriteria
1155: .setRuleTemplateName(RuleTestOrgReviewSetup.RULE_TEST_TEMPLATE);
1156: ruleReportCriteria.setResponsibleUser(new NetworkIdVO("user1"));
1157: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
1158: RuleVO[] rules = info.ruleReport(ruleReportCriteria);
1159: assertEquals("Number of rules returned is incorrect", 2,
1160: rules.length);
1161:
1162: ruleReportCriteria = null;
1163: rules = null;
1164: ruleReportCriteria = new RuleReportCriteriaVO();
1165: ruleReportCriteria
1166: .setDocumentTypeName(RuleTestOrgReviewSetup.DOCUMENT_TYPE_NAME);
1167: ruleReportCriteria
1168: .setRuleTemplateName(RuleTestOrgReviewSetup.RULE_TEST_TEMPLATE);
1169: ruleReportCriteria.setResponsibleUser(new NetworkIdVO("user1"));
1170: ruleReportCriteria
1171: .setConsiderWorkgroupMembership(Boolean.FALSE);
1172: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
1173: rules = info.ruleReport(ruleReportCriteria);
1174: assertEquals("Number of rules returned is incorrect", 1,
1175: rules.length);
1176:
1177: ruleReportCriteria = null;
1178: rules = null;
1179: ruleReportCriteria = new RuleReportCriteriaVO();
1180: ruleReportCriteria
1181: .setDocumentTypeName(RuleTestOrgReviewSetup.DOCUMENT_TYPE_NAME);
1182: ruleReportCriteria
1183: .setRuleTemplateName(RuleTestOrgReviewSetup.RULE_TEST_TEMPLATE);
1184: RuleExtensionVO ruleExtensionVO = new RuleExtensionVO(
1185: RuleTestOrgReviewSetup.RULE_TEST_CHART_CODE_NAME, "BA");
1186: RuleExtensionVO ruleExtensionVO2 = new RuleExtensionVO(
1187: RuleTestOrgReviewSetup.RULE_TEST_ORG_CODE_NAME, "FMOP");
1188: RuleExtensionVO[] ruleExtensionVOs = new RuleExtensionVO[] {
1189: ruleExtensionVO, ruleExtensionVO2 };
1190: ruleReportCriteria.setRuleExtensionVOs(ruleExtensionVOs);
1191: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
1192: rules = info.ruleReport(ruleReportCriteria);
1193: assertEquals("Number of rules returned is incorrect", 2,
1194: rules.length);
1195:
1196: ruleReportCriteria = null;
1197: rules = null;
1198: ruleExtensionVO = null;
1199: ruleExtensionVO2 = null;
1200: ruleExtensionVOs = null;
1201: ruleReportCriteria = new RuleReportCriteriaVO();
1202: ruleReportCriteria
1203: .setDocumentTypeName(RuleTestOrgReviewSetup.DOCUMENT_TYPE_NAME);
1204: ruleReportCriteria
1205: .setRuleTemplateName(RuleTestOrgReviewSetup.RULE_TEST_TEMPLATE);
1206: ruleReportCriteria.setResponsibleUser(new NetworkIdVO(
1207: "ewestfal"));
1208: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
1209: rules = info.ruleReport(ruleReportCriteria);
1210: assertEquals("Number of rules returned is incorrect", 1,
1211: rules.length);
1212: RuleVO ruleVO = rules[0];
1213: assertEquals("Rule Document Type is not "
1214: + RuleTestOrgReviewSetup.DOCUMENT_TYPE_NAME,
1215: RuleTestOrgReviewSetup.DOCUMENT_TYPE_NAME, ruleVO
1216: .getDocTypeName());
1217: assertEquals("Rule Template Named returned is not "
1218: + RuleTestOrgReviewSetup.RULE_TEST_TEMPLATE,
1219: RuleTestOrgReviewSetup.RULE_TEST_TEMPLATE, ruleVO
1220: .getRuleTemplateName());
1221: assertEquals("Rule did not have ignore previous set to true",
1222: Boolean.TRUE, ruleVO.getIgnorePrevious());
1223: assertEquals(
1224: "Number of Rule Responsibilities Returned Should be 1",
1225: 1, ruleVO.getRuleResponsibilities().length);
1226: RuleResponsibilityVO responsibilityVO = ruleVO
1227: .getRuleResponsibilities()[0];
1228: assertEquals("Rule workgroup name is incorrect",
1229: RuleTestOrgReviewSetup.RULE_TEST_WORKGROUP2,
1230: responsibilityVO.getWorkgroup().getWorkgroupName());
1231: assertEquals("Rule priority is incorrect", Integer.valueOf(4),
1232: responsibilityVO.getPriority());
1233: assertEquals("Rule action request is incorrect",
1234: EdenConstants.ACTION_REQUEST_FYI_REQ, responsibilityVO
1235: .getActionRequestedCd());
1236: ruleExtensionVOs = ruleVO.getRuleExtensions();
1237: assertEquals("Number of Rule Extensions Returned Should be 2",
1238: 2, ruleExtensionVOs.length);
1239: for (int i = 0; i < ruleExtensionVOs.length; i++) {
1240: RuleExtensionVO extensionVO = ruleExtensionVOs[i];
1241: // if rule key is chartCode.... should equal UA
1242: // else if rule key is orgCode.... should equal VPIT
1243: // otherwise error
1244: if (RuleTestOrgReviewSetup.RULE_TEST_CHART_CODE_NAME
1245: .equals(extensionVO.getKey())) {
1246: assertEquals(
1247: "Rule Extension for key '"
1248: + RuleTestOrgReviewSetup.RULE_TEST_CHART_CODE_NAME
1249: + "' is incorrect", "UA", extensionVO
1250: .getValue());
1251: } else if (RuleTestOrgReviewSetup.RULE_TEST_ORG_CODE_NAME
1252: .equals(extensionVO.getKey())) {
1253: assertEquals(
1254: "Rule Extension for key '"
1255: + RuleTestOrgReviewSetup.RULE_TEST_ORG_CODE_NAME
1256: + "' is incorrect", "VPIT", extensionVO
1257: .getValue());
1258: } else {
1259: fail("Rule Extension has attribute key that is neither '"
1260: + RuleTestOrgReviewSetup.RULE_TEST_CHART_CODE_NAME
1261: + "' nor '"
1262: + RuleTestOrgReviewSetup.RULE_TEST_ORG_CODE_NAME
1263: + "'");
1264: }
1265: }
1266:
1267: ruleReportCriteria = null;
1268: rules = null;
1269: ruleVO = null;
1270: responsibilityVO = null;
1271: ruleReportCriteria = new RuleReportCriteriaVO();
1272: ruleReportCriteria
1273: .setDocumentTypeName(RuleTestOrgReviewSetup.DOCUMENT_TYPE_NAME);
1274: ruleReportCriteria
1275: .setRuleTemplateName(RuleTestOrgReviewSetup.RULE_TEST_TEMPLATE);
1276: ruleReportCriteria.setResponsibleUser(new NetworkIdVO("user1"));
1277: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
1278: rules = info.ruleReport(ruleReportCriteria);
1279: assertEquals("Number of rules returned is incorrect", 2,
1280: rules.length);
1281:
1282: ruleReportCriteria = null;
1283: rules = null;
1284: ruleVO = null;
1285: responsibilityVO = null;
1286: ruleExtensionVO = null;
1287: ruleExtensionVO2 = null;
1288: ruleExtensionVOs = null;
1289: ruleReportCriteria = new RuleReportCriteriaVO();
1290: ruleReportCriteria
1291: .setDocumentTypeName(RuleTestOrgReviewSetup.DOCUMENT_TYPE_NAME);
1292: ruleReportCriteria
1293: .setRuleTemplateName(RuleTestOrgReviewSetup.RULE_TEST_TEMPLATE);
1294: ruleExtensionVO = new RuleExtensionVO(
1295: RuleTestOrgReviewSetup.RULE_TEST_CHART_CODE_NAME, "UA");
1296: ruleExtensionVO2 = new RuleExtensionVO(
1297: RuleTestOrgReviewSetup.RULE_TEST_ORG_CODE_NAME, "FMOP");
1298: ruleExtensionVOs = new RuleExtensionVO[] { ruleExtensionVO,
1299: ruleExtensionVO2 };
1300: ruleReportCriteria.setRuleExtensionVOs(ruleExtensionVOs);
1301: ruleReportCriteria.setIncludeDelegations(Boolean.FALSE);
1302: rules = info.ruleReport(ruleReportCriteria);
1303: assertEquals("Number of rules returned is incorrect", 1,
1304: rules.length);
1305: ruleVO = rules[0];
1306: assertEquals("Rule Document Type is not "
1307: + RuleTestOrgReviewSetup.DOCUMENT_TYPE_NAME,
1308: RuleTestOrgReviewSetup.DOCUMENT_TYPE_NAME, ruleVO
1309: .getDocTypeName());
1310: assertEquals("Rule Template Named returned is not "
1311: + RuleTestOrgReviewSetup.RULE_TEST_TEMPLATE,
1312: RuleTestOrgReviewSetup.RULE_TEST_TEMPLATE, ruleVO
1313: .getRuleTemplateName());
1314: assertEquals("Rule did not have ignore previous set to true",
1315: Boolean.TRUE, ruleVO.getIgnorePrevious());
1316: assertEquals(
1317: "Number of Rule Responsibilities Returned Should be 1",
1318: 1, ruleVO.getRuleResponsibilities().length);
1319: responsibilityVO = ruleVO.getRuleResponsibilities()[0];
1320: assertEquals("Rule workgroup name is incorrect",
1321: RuleTestOrgReviewSetup.RULE_TEST_WORKGROUP,
1322: responsibilityVO.getWorkgroup().getWorkgroupName());
1323: assertEquals("Rule priority is incorrect", Integer.valueOf(1),
1324: responsibilityVO.getPriority());
1325: assertEquals("Rule action request is incorrect",
1326: EdenConstants.ACTION_REQUEST_APPROVE_REQ,
1327: responsibilityVO.getActionRequestedCd());
1328: }
1329:
1330: private void ruleExceptionTest(WorkflowInfo info,
1331: RuleReportCriteriaVO ruleReportCriteria, String message) {
1332: try {
1333: info.ruleReport(ruleReportCriteria);
1334: fail(message);
1335: } catch (Exception e) {
1336: e.printStackTrace();
1337: }
1338: }
1339:
1340: private class RuleTestGeneralSetup {
1341: public static final String DOCUMENT_TYPE_NAME = "RuleTestDocType";
1342: public static final String RULE_TEST_TEMPLATE_1 = "WorkflowDocumentTemplate";
1343: public static final String RULE_TEST_TEMPLATE_2 = "WorkflowDocument2Template";
1344: public static final String RULE_TEST_TEMPLATE_3 = "WorkflowDocument3Template";
1345: public static final String RULE_TEST_WORKGROUP = "NonSIT";
1346: }
1347:
1348: private class RuleTestOrgReviewSetup {
1349: public static final String DOCUMENT_TYPE_NAME = "OrgReviewTestDocType";
1350: public static final String RULE_TEST_TEMPLATE = "OrgReviewTemplate";
1351: public static final String RULE_TEST_WORKGROUP = "Org_Review_Group";
1352: public static final String RULE_TEST_WORKGROUP2 = "Org_Review_Group_2";
1353: public static final String RULE_TEST_CHART_CODE_NAME = "chartCode";
1354: public static final String RULE_TEST_ORG_CODE_NAME = "orgCode";
1355: }
1356:
1357: private class SeqSetup {
1358: public static final String DOCUMENT_TYPE_NAME = "SeqDocType";
1359: public static final String LAST_APPROVER_DOCUMENT_TYPE_NAME = "SeqLastApproverDocType";
1360: public static final String CHILD_DOCUMENT_TYPE_NAME = "SeqChildDocType";
1361: public static final String ADHOC_NODE = "AdHoc";
1362: public static final String WORKFLOW_DOCUMENT_NODE = "WorkflowDocument";
1363: public static final String WORKFLOW_DOCUMENT_2_NODE = "WorkflowDocument2";
1364: public static final String ACKNOWLEDGE_1_NODE = "Acknowledge1";
1365: public static final String ACKNOWLEDGE_2_NODE = "Acknowledge2";
1366: }
1367: }
|