ECSchedulingService { public void reportReferralFollowup(FPProductInformation fpInfo) { updateFPFollowupSchedule(fpInfo); updateFPReferralFollowupSchedule(fpInfo); } @Autowired  ECSchedulingService(FPMethodStrategyFactory fpMethodStrategyFactory, ScheduleTrackingService scheduleTrackingService,
                               ActionService actionService, ScheduleService scheduleService); void registerEC(FPProductInformation fpInfo); void fpChange(FPProductInformation fpInfo); void renewFPProduct(FPProductInformation fpInfo); void fpFollowup(FPProductInformation fpInfo); void reportFPComplications(FPProductInformation fpInfo); void reportReferralFollowup(FPProductInformation fpInfo);  }
@Test public void shouldFulfillFollowupScheduleWhenReferralFollowupIsReportedAndECDoesNotNeedFollowup() { when(scheduleTrackingService.getEnrollment("entity id 1", "FP Followup")).thenReturn(enrollmentRecord); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", null, null, null, null, null, null, "2011-01-12", null, null, null, null)); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", null, null, null, null, null, null, "2011-01-12", null, null, "", null)); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", "fp_method", null, null, null, null, null, "2011-01-12", null, null, "no", null)); verify(scheduleTrackingService, times(3)).getEnrollment("entity id 1", "FP Followup"); verify(scheduleTrackingService, times(3)).fulfillCurrentMilestone("entity id 1", "FP Followup", parse("2011-01-12")); verify(actionService, times(3)).markAlertAsClosed("entity id 1", "anm id 1", "FP Followup", "2011-01-12"); }
@Test public void shouldNotFulfillFollowupScheduleWhenReferralFollowupIsReportedAndECIsNotEnrolledToSchedule() { when(scheduleTrackingService.getEnrollment("entity id 1", "FP Followup")).thenReturn(null); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", null, null, null, null, null, null, "2011-01-12", null, null, null, null)); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", null, null, null, null, null, null, "2011-01-12", null, null, "", null)); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", "fp_method", null, null, null, null, null, "2011-01-12", null, null, "no", null)); verify(scheduleTrackingService, times(3)).getEnrollment("entity id 1", "FP Followup"); verify(scheduleTrackingService, times(0)).fulfillCurrentMilestone("entity id 1", "FP Followup", parse("2011-01-12")); verify(actionService, times(0)).markAlertAsClosed("entity id 1", "anm id 1", "FP Followup", "2011-01-12"); }
@Test public void shouldEnrollECToFollowupScheduleWhenReferralFollowupIsReportedAndTheyNeedFollowup() { ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", null, null, null, null, null, null, "2011-01-13", null, "2011-01-12", "yes", null)); verify(scheduleService).enroll("entity id 1", "FP Followup", "2011-01-12"); }
@Test public void shouldFulfillReferralFollowupScheduleWhenReferralFollowupIsReportedAndECDoesNotNeedReferralFollowup() { when(scheduleTrackingService.getEnrollment("entity id 1", "FP Referral Followup")).thenReturn(enrollmentRecord); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", null, null, null, null, null, null, "2011-01-12", null, null, null, null)); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", null, null, null, null, null, null, "2011-01-12", null, null, null, "")); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", "fp_method", null, null, null, null, null, "2011-01-12", null, null, null, "no")); verify(scheduleTrackingService, times(3)).getEnrollment("entity id 1", "FP Referral Followup"); verify(scheduleTrackingService, times(3)).fulfillCurrentMilestone("entity id 1", "FP Referral Followup", parse("2011-01-12")); verify(actionService, times(3)).markAlertAsClosed("entity id 1", "anm id 1", "FP Referral Followup", "2011-01-12"); }
@Test public void shouldNotFulfillReferralFollowupScheduleWhenReferralFollowupIsReportedAndECIsNotEnrolledIntoScheduled() { when(scheduleTrackingService.getEnrollment("entity id 1", "FP Referral Followup")).thenReturn(null); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", null, null, null, null, null, null, "2011-01-12", null, null, null, null)); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", null, null, null, null, null, null, "2011-01-12", null, null, null, "")); ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", "fp_method", null, null, null, null, null, "2011-01-12", null, null, null, "no")); verify(scheduleTrackingService, times(3)).getEnrollment("entity id 1", "FP Referral Followup"); verify(scheduleTrackingService, times(0)).fulfillCurrentMilestone("entity id 1", "FP Referral Followup", parse("2011-01-12")); verify(actionService, times(0)).markAlertAsClosed("entity id 1", "anm id 1", "FP Referral Followup", "2011-01-12"); }
@Test public void shouldEnrollECToReferralFollowupScheduleWhenReferralFollowupIsReportedAndTheyNeedReferralFollowup() { ecSchedulingService.reportReferralFollowup(new FPProductInformation("entity id 1", "anm id 1", null, null, null, null, null, null, "2011-01-13", null, "2011-01-12", null, "yes")); verify(scheduleService).enroll("entity id 1", "FP Referral Followup", "2011-01-12"); }