public void testAdvanceReportWorkflow() {
    Integer id = 10;
    Integer wfId = 5;
    String transitionToTake = "abcd";
    String loginId = "SYSTEM_ADMIN";
    ReviewStatus reviewStatus = ReviewStatus.DRAFT_INCOMPLETE;
    Report report = Fixtures.createReport("testReport");
    report.setStatus(ReportStatus.INPROCESS);
    report.setReviewComments(new ArrayList<ReportReviewComment>());
    report.setWorkflowId(wfId);
    List<String> transitions = new ArrayList<String>();

    ReportSubmittability errorMessagesMock = registerMockFor(ReportSubmittability.class);
    EasyMock.expect(errorMessagesMock.isSubmittable()).andReturn(true);
    EasyMock.expect(reportValidationService.isSubmittable(report)).andReturn(errorMessagesMock);
    EasyMock.expect(wfService.nextTransitionNames(wfId, loginId)).andReturn(transitions);
    EasyMock.expect(wfService.advanceWorkflow(wfId, transitionToTake)).andReturn(reviewStatus);
    EasyMock.expect(reportDao.getById(id)).andReturn(report);
    reportDao.save(report);
    replayMocks();
    List<String> transitionsNames = impl.advanceReportWorkflow(wfId, transitionToTake, id, loginId);

    verifyMocks();
    assertEquals(
        "A review comment for the action of advancing workflow was not added",
        1,
        report.getReviewCommentsInternal().size());
  }
  public void testNextTransitionsForAeReportWithCompleteReports() throws Exception {
    Report report = Fixtures.createReport("testReport");
    report.setWorkflowId(1);
    ReportSubmittability errorMessagesMock = registerMockFor(ReportSubmittability.class);
    report.setStatus(ReportStatus.PENDING);
    List<String> transitions = new ArrayList<String>();
    transitions.add("test action");
    transitions.add("Submit to Central Office Report Reviewer");

    EasyMock.expect(wfService.nextTransitionNames(1, "SYSTEM_ADMIN")).andReturn(transitions);
    EasyMock.expect(reportValidationService.isSubmittable(report)).andReturn(errorMessagesMock);
    EasyMock.expect(errorMessagesMock.isSubmittable()).andReturn(true);
    replayMocks();
    List<String> filteredTransitions =
        impl.nextTransitionNamesForReportWorkflow(report, "SYSTEM_ADMIN");
    verifyMocks();
    assertEquals(2, filteredTransitions.size());
  }
  // test the transition, were the physician can login to the system.
  public void testNextTransitionsForAeReportWithAnInvestigatorHavingLogin() throws Exception {
    Report report = Fixtures.createReport("testReport");
    Investigator investigator = Fixtures.createInvestigator("tester");
    investigator.setLoginId("hai");
    report.getPhysician().setPerson(investigator);
    report.setWorkflowId(1);
    ReportSubmittability errorMessagesMock = registerMockFor(ReportSubmittability.class);
    report.setStatus(ReportStatus.PENDING);
    List<String> transitions = new ArrayList<String>();
    transitions.add("test action");
    transitions.add("Send to Physician for Review");

    EasyMock.expect(wfService.nextTransitionNames(1, "SYSTEM_ADMIN")).andReturn(transitions);
    EasyMock.expect(reportValidationService.isSubmittable(report)).andReturn(errorMessagesMock);
    EasyMock.expect(errorMessagesMock.isSubmittable()).andReturn(true);
    replayMocks();
    List<String> filteredTransitions =
        impl.nextTransitionNamesForReportWorkflow(report, "SYSTEM_ADMIN");
    verifyMocks();
    assertEquals(1, filteredTransitions.size());
  }
예제 #4
0
  @SuppressWarnings("unchecked")
  @Override
  protected Map referenceData(
      final HttpServletRequest request, final Object cmd, final Errors errors) throws Exception {
    ReviewAeReportCommand command = (ReviewAeReportCommand) cmd;
    Map<String, Object> refdata = new HashMap<String, Object>();
    Map<Integer, ReportSubmittability> reportMessages =
        new HashMap<Integer, ReportSubmittability>();

    // evaluate business rules.
    ReportSubmittability reportSubmittability = new ReportSubmittability();
    for (ExpeditedReportSection section : ExpeditedReportSection.values()) {

      if (!section.isAssociatedToBusinessRules()) continue;

      ValidationErrors validationErrors =
          evaluationService.validateReportingBusinessRules(command.getAeReport(), section);
      for (ValidationError vError : validationErrors.getErrors()) {
        reportSubmittability.addValidityMessage(
            section,
            messageSource.getMessage(
                vError.getCode(),
                vError.getReplacementVariables(),
                vError.getMessage(),
                Locale.getDefault()));
      }
    }

    reportMessages.put(ExpeditedAdverseEventInputCommand.ZERO, reportSubmittability);

    // -- check the report submittability
    for (Report report : command.getAeReport().getReports()) {
      reportMessages.put(report.getId(), reportValidationService.isSubmittable(report));
    }
    refdata.put("reportMessages", reportMessages);

    // This is to check if the logged in person is SAE-Coordinator.
    // Data coordinator cannot submit a report.
    boolean isReportReviewer =
        SecurityUtils.hasAuthorityOf(UserGroupType.ae_expedited_report_reviewer);

    // boolean canSubmit = false;
    // if(reportMessages.get(command.ZERO).isSubmittable() &&
    // reportMessages.get(command.getReportId()).isSubmittable() && isReportReviewer)
    //	canSubmit = true;

    // refdata.put("canSubmit", canSubmit);
    refdata.put("isUserSAECoordinato", isReportReviewer);

    // additional information documents

    Integer additionalInformationId = command.getAeReport().getAdditionalInformation().getId();
    List<AdditionalInformationDocument> additionalInformationDocuments =
        additionalInformationDocumentService.findByAdditionalInformationId(additionalInformationId);

    Map<String, List<AdditionalInformationDocument>> documents =
        AdditionalInformationDocument.groupDocumentsByDocumentType(additionalInformationDocuments);

    refdata.put("documents", documents);
    refdata.put("additionalInformationId", additionalInformationId);

    return refdata;
  }