OCPStrategy implements FPMethodStrategy { @Override public void renewFPProduct(FPProductInformation fpInfo) { if (tryParse(fpInfo.numberOfOCPStripsSupplied(), 0) <= 0) { return; } logger.info(format("Fulfilling OCP Refill schedule as FP product was renewed. entityId: {0}, ocpRefillDate: {1}, numberOfOCPStripsSupplied: {2}", fpInfo.entityId(), fpInfo.ocpRefillDate(), fpInfo.numberOfOCPStripsSupplied())); scheduleTrackingService.fulfillCurrentMilestone(fpInfo.entityId(), ocpRefillSchedule.name(), parse(fpInfo.submissionDate())); actionService.markAlertAsClosed(fpInfo.entityId(), fpInfo.anmId(), ocpRefillSchedule.name(), fpInfo.ocpRefillDate()); enrollECToOCPRefillSchedule(fpInfo.entityId(), fpInfo.numberOfOCPStripsSupplied(), fpInfo.ocpRefillDate()); } @Autowired  OCPStrategy(ScheduleTrackingService scheduleTrackingService, ActionService actionService, ScheduleService scheduleService,
                       @Value("#{drishti['preferred.time']}") int preferredTime); @Override void registerEC(FPProductInformation fpInfo); @Override void unEnrollFromPreviousScheduleAsFPMethodChanged(FPProductInformation fpInfo); @Override void enrollToNewScheduleForNewFPMethod(FPProductInformation fpInfo); @Override void renewFPProduct(FPProductInformation fpInfo); @Override void fpFollowup(FPProductInformation fpInfo); static final int NUMBER_OF_PILLS_IN_ONE_OCP_STRIP; static final int DUE_WINDOW_PERIOD_IN_WEEKS; }
@Test public void shouldUpdateOCPRefillScheduleWhenOCPPillsAreResupplied() { strategy.renewFPProduct(new FPProductInformation("entity id 1", "anm id 1", "ocp", null, null, "1", "2012-01-01", null, "2011-01-12", null, null, null, null)); InOrder inOrder = inOrder(scheduleTrackingService, actionService, scheduleService); inOrder.verify(scheduleTrackingService).fulfillCurrentMilestone("entity id 1", "OCP Refill", parse("2011-01-12")); inOrder.verify(actionService).markAlertAsClosed("entity id 1", "anm id 1", "OCP Refill", "2012-01-01"); inOrder.verify(scheduleService).enroll("entity id 1", "OCP Refill", "2012-01-15"); inOrder.verify(actionService).alertForBeneficiary(ec, "entity id 1", "OCP Refill", "OCP Refill", upcoming, LocalDate.parse("2012-01-15").toDateTime(new LocalTime(14, 0)), LocalDate.parse("2012-01-15").plusWeeks(1).toDateTime(new LocalTime(14, 0))); }
@Test public void shouldDoNothingWhenZeroOCPPillsAreResupplied() { strategy.renewFPProduct(new FPProductInformation("entity id 1", "anm id 1", "ocp", null, null, "0", "2012-01-02", null, "2011-01-12", null, null, null, null)); verifyZeroInteractions(scheduleTrackingService); verifyZeroInteractions(actionService); }