/**
   * Test the approval of a protocol. The protocol status and its corresponding action should be set
   * to approved.
   */
  @Test
  public void runApprovedTest() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument();

    protocolSubmitActionService.submitToIrbForReview(
        protocolDocument.getProtocol(), getMockSubmitAction());

    documentService.routeDocument(protocolDocument, null, null);
    documentService.blanketApproveDocument(protocolDocument, null, null);
    WorkflowDocument workflowDoc = getWorkflowDocument(protocolDocument);
    WorkflowDocumentActionsService info =
        GlobalResourceLoader.getService("rice.kew.workflowDocumentActionsService");
    RoutingReportCriteria.Builder reportCriteriaBuilder =
        RoutingReportCriteria.Builder.createByDocumentId(workflowDoc.getDocumentId());
    DocumentDetail results1 = info.executeSimulation(reportCriteriaBuilder.build());

    assertTrue(workflowDoc.isFinal());

    // the status update is not happening within doRouteStatusChange anymore
    // assertEquals(protocolDocument.getProtocol().getProtocolStatusCode(),
    // ProtocolStatus.ACTIVE_OPEN_TO_ENROLLMENT);
    assertTrue(protocolDocument.getProtocol().isActive());
    // verifyProtocolAction(protocolDocument.getProtocol().getProtocolId(),
    // ProtocolActionType.APPROVED);
  }
  /**
   * Test the approval of an amendment. Verify that the sequence number has been incremented for the
   * protocol version and that it's status has been set to approved.
   *
   * @throws Exception
   */
  @Test
  public void runAmendmentTest() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument("0906000003");
    ProtocolSubmitAction submitAction = getMockSubmitAction();

    protocolSubmitActionService.submitToIrbForReview(protocolDocument.getProtocol(), submitAction);

    documentService.routeDocument(protocolDocument, null, null);
    documentService.blanketApproveDocument(protocolDocument, null, null);

    String docNbr =
        protocolAmendRenewService.createAmendment(protocolDocument, getMockProtocolAmendmentBean());

    ProtocolDocument amendmentDocument =
        (ProtocolDocument) KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(docNbr);
    protocolSubmitActionService.submitToIrbForReview(amendmentDocument.getProtocol(), submitAction);

    documentService.routeDocument(amendmentDocument, null, null);
    // temporarily disable unit test
    //        documentService.blanketApproveDocument(amendmentDocument, null, null);
    //
    //        assertTrue(getWorkflowDocument(amendmentDocument).isFinal());
    //
    //        Protocol newProtocol =
    // protocolFinder.findCurrentProtocolByNumber(protocolDocument.getProtocol().getProtocolNumber());
    //        assertTrue(newProtocol.getSequenceNumber() ==
    // protocolDocument.getProtocol().getSequenceNumber() + 1);
    //
    //        /*
    //         * Must read the protocol document again in order to obtain the most recent changes.
    //         */
    //        protocolDocument = (ProtocolDocument)
    // documentService.getByDocumentHeaderId(protocolDocument.getDocumentNumber());
    //
    //        assertFalse(protocolDocument.getProtocol().isActive());
    //        assertFalse(amendmentDocument.getProtocol().isActive());
    //        assertTrue(newProtocol.isActive());
    //
    //        // TODO: This test can be re-added once we can route the new protocol through
    // workflow.
    //        //assertEquals(getWorkflowDocument(newProtocol.getProtocolDocument).isFinal());
    //
    //        verifyProtocolAction(newProtocol, ProtocolActionType.APPROVED);
  }
  private Protocol getProtocolAssignedToAgenda() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument();

    protocolSubmitActionService.submitToIrbForReview(protocolDocument, getMockSubmitAction(), null);
    assertEquals(
        ProtocolStatus.SUBMITTED_TO_IRB, protocolDocument.getProtocol().getProtocolStatusCode());

    protocolAssignCmtSchedService.assignToCommitteeAndSchedule(
        protocolDocument.getProtocol(), getMockAssignCmtSchedBean());
    assertEquals(
        ProtocolSubmissionStatus.SUBMITTED_TO_COMMITTEE,
        protocolDocument.getProtocol().getProtocolSubmission().getSubmissionStatusCode());

    return protocolDocument.getProtocol();
  }
  /**
   * Test the disapproval of a protocol. The protocol status and its corresponding action should be
   * set to disapproved.
   */
  @Test
  public void runDisapprovedTest() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument("0906000002");

    protocolSubmitActionService.submitToIrbForReview(
        protocolDocument.getProtocol(), getMockSubmitAction());

    documentService.routeDocument(protocolDocument, null, null);
    documentService.disapproveDocument(protocolDocument, null);

    assertTrue(getWorkflowDocument(protocolDocument).isDisapproved());
    // assertEquals(protocolDocument.getProtocol().getProtocolStatusCode(),
    // ProtocolStatus.DISAPPROVED);

    // assertTrue(protocolDocument.getProtocol().isActive());

    // verifyProtocolAction(protocolDocument.getProtocol().getProtocolId(),
    // ProtocolActionType.DISAPPROVED);
  }