ANCSchedulesService { public void forceFulfillMilestone(String externalId, String scheduleName) { if (isNotEnrolled(externalId, scheduleName)) { logger.info(format("Tried to fulfill a milestone of {0} for entity id: {1}. But {0} not enrolled.", scheduleName, externalId)); return; } trackingService.fulfillCurrentMilestone(externalId, scheduleName, today(), new Time(now())); logger.info(format("Fulfilled milestone of {0} for entity id: {1}", scheduleName, externalId)); } @Autowired  ANCSchedulesService(ScheduleTrackingService trackingService, ActionService actionService, ScheduleService scheduleService); void enrollMother(String caseId, LocalDate referenceDateForSchedule); void ancVisitHasHappened(String entityId, String anmId, int visitNumberToFulfill, String visitDate); void deliveryHasBeenPlanned(String entityId, String anmId, String deliveryPlanDate); void ttVisitHasHappened(String entityId, String anmId, String ttDose, String ttDate); void ifaTabletsGiven(String entityId, String anmId, String numberOfIFATabletsGiven, String ifaGivenDate); void hbTestDone(String entityId, String anmId, String date, String anaemicStatus, LocalDate lmp); void forceFulfillMilestone(String externalId, String scheduleName); void unEnrollFromAllSchedules(String entityId); static final int NUMBER_OF_WEEKS_BEFORE_HB_TEST_2_BECOMES_DUE; }
@Test public void shouldNotFulfillCurrentMilestoneForGivenExternalIdWhenVisitHasBeenMissed() { fakeIt(parse("2012-01-01")); when(trackingService.getEnrollment("Case X", "Schedule 1")) .thenReturn(null); ancSchedulesService.forceFulfillMilestone("Case X", "Schedule 1"); verify(trackingService).getEnrollment("Case X", "Schedule 1"); verifyNoMoreInteractions(trackingService); }
@Test public void shouldFulfillCurrentMilestoneForGivenExternalIdWhenVisitHasNotBeenMissed() { fakeIt(parse("2012-01-01")); when(trackingService.getEnrollment("Case X", "Schedule 1")) .thenReturn(new EnrollmentRecord("Case X", "Lab Reminders", "Lab Reminders", null, null, null, null, null, null, null)); ancSchedulesService.forceFulfillMilestone("Case X", "Schedule 1"); verify(trackingService).fulfillCurrentMilestone(eq("Case X"), eq("Schedule 1"), eq(today()), any(Time.class)); }