public void testEnactReportingPeriodWorkflow() {
    long processId = 5;
    StudyParticipantAssignment assignment = Fixtures.createAssignment();
    AdverseEventReportingPeriod reportingPeriod = Fixtures.createReportingPeriod();
    reportingPeriod.setId(44);
    WorkflowConfig workflowConfig = Fixtures.createWorkflowConfig("test");
    StudySite site = assignment.getStudySite();
    StudySiteWorkflowConfig ssWfCfg =
        new StudySiteWorkflowConfig("reportingPeriod", site, workflowConfig);
    site.addStudySiteWorkflowConfig(ssWfCfg);
    reportingPeriod.setAssignment(assignment);

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(WorkflowService.VAR_STUDY_ID, site.getStudy().getId());
    variables.put(WorkflowService.VAR_WF_TYPE, AdverseEventReportingPeriod.class.getName());
    variables.put(WorkflowService.VAR_WF_STUDY_NAME, reportingPeriod.getStudy().getDisplayName());
    variables.put(
        WorkflowService.VAR_WF_SUBJECT_NAME, reportingPeriod.getParticipant().getFullName());
    variables.put(WorkflowService.VAR_WF_COURSE_NAME, reportingPeriod.getName());
    variables.put(WorkflowService.VAR_REPORTING_PERIOD_ID, reportingPeriod.getId());

    EasyMock.expect(wfService.createProcessInstance("test", variables)).andReturn(processInstance);
    EasyMock.expect(processInstance.getId()).andReturn(processId).anyTimes();
    rpDao.modifyOrSaveReviewStatusAndComments(reportingPeriod);
    replayMocks();
    impl.enactReportingPeriodWorkflow(reportingPeriod);
    verifyMocks();
  }
  public void testEditReportingPeriodReviewCommentWithId() {
    Integer reportingPeriodId = 5;
    String newComment = "new Comment";
    String userId = "userId";
    Integer commentId = 2;

    AdverseEventReportingPeriod rp = Fixtures.createReportingPeriod();
    ReportingPeriodReviewComment comment =
        Fixtures.createReportingPeriodReviewComment(1, "comment 1");
    ArrayList<ReportingPeriodReviewComment> commentsList =
        new ArrayList<ReportingPeriodReviewComment>();
    commentsList.add(comment);
    comment = Fixtures.createReportingPeriodReviewComment(2, "comment 2");
    commentsList.add(comment);
    rp.setReviewComments(commentsList);
    EasyMock.expect(rpDao.getById(reportingPeriodId)).andReturn(rp);
    rpDao.modifyOrSaveReviewStatusAndComments(rp);
    replayMocks();
    impl.editReportingPeriodReviewComment(reportingPeriodId, newComment, userId, commentId);
    verifyMocks();

    assertEquals(
        "Edit comment isnt working correctly",
        "new Comment",
        rp.getReviewCommentsInternal().get(1).getUserComment());
  }
  public void testAddReportingPeriodReviewCommentWithId() {
    Integer reportingPeriodId = 5;
    String comment = "mycomment";
    String userId = "userId";

    AdverseEventReportingPeriod rp = Fixtures.createReportingPeriod();
    rp.setReviewComments(new ArrayList<ReportingPeriodReviewComment>());
    EasyMock.expect(rpDao.getById(reportingPeriodId)).andReturn(rp);
    rpDao.modifyOrSaveReviewStatusAndComments(rp);
    replayMocks();
    impl.addReportingPeriodReviewComment(reportingPeriodId, comment, userId);
    verifyMocks();
  }
 public void testDeleteReportingPeriodReviewComment() {
   AdverseEventReportingPeriod rp = Fixtures.createReportingPeriod();
   ArrayList<ReportingPeriodReviewComment> commentsList =
       new ArrayList<ReportingPeriodReviewComment>();
   commentsList.add(Fixtures.createReportingPeriodReviewComment(1, "comment 1"));
   commentsList.add(Fixtures.createReportingPeriodReviewComment(2, "comment 2"));
   commentsList.add(Fixtures.createReportingPeriodReviewComment(3, "comment 3"));
   rp.setReviewComments(commentsList);
   rp.setId(1);
   EasyMock.expect(rpDao.getById(1)).andReturn(rp);
   rpDao.modifyOrSaveReviewStatusAndComments(rp);
   replayMocks();
   impl.deleteReportingPeriodReviewComment(1, 2);
   verifyMocks();
   assertEquals(
       "Comment not deleted from comments list", 2, rp.getReviewCommentsInternal().size());
 }
  public void testAdvanceReportingPeriodWorkflow() {
    Integer id = 5;
    Integer wfId = 5;
    String loginId = "SYSTEM_ADMIN";
    String transitionToTake = "abcd";
    List<String> transitions = new ArrayList<String>();
    ReviewStatus rs = ReviewStatus.DRAFT_INCOMPLETE;
    AdverseEventReportingPeriod rp = Fixtures.createReportingPeriod();
    rp.setReviewComments(new ArrayList<ReportingPeriodReviewComment>());
    EasyMock.expect(wfService.advanceWorkflow(wfId, transitionToTake)).andReturn(rs);
    EasyMock.expect(wfService.nextTransitionNames(wfId, loginId)).andReturn(transitions);
    EasyMock.expect(rpDao.getById(id)).andReturn(rp);
    rpDao.modifyOrSaveReviewStatusAndComments(rp);
    replayMocks();
    List<String> transitionNames =
        impl.advanceReportingPeriodWorkflow(wfId, transitionToTake, id, loginId);

    verifyMocks();
    assertEquals(
        "A review comment for the action of advancing workflow was not added",
        1,
        rp.getReviewComments().size());
  }