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()); }