CondomStrategy implements FPMethodStrategy { @Override public void renewFPProduct(FPProductInformation fpInfo) { if (tryParse(fpInfo.numberOfCondomsSupplied(), 0) <= 0) { return; } logger.info(format("Fulfilling Condom Refill schedule as FP product was renewed. entityId: {0}, condomRefillDate: {1}, numberOfCondomsSupplied: {2}", fpInfo.entityId(), fpInfo.submissionDate(), fpInfo.numberOfCondomsSupplied())); scheduleTrackingService.fulfillCurrentMilestone(fpInfo.entityId(), condomRefillSchedule.name(), parse(fpInfo.submissionDate())); actionService.markAlertAsClosed(fpInfo.entityId(), fpInfo.anmId(), condomRefillSchedule.name(), fpInfo.submissionDate()); enrollECToCondomRefillSchedule(fpInfo.entityId()); } @Autowired  CondomStrategy(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);  }
@Test public void shouldUpdateECFromCondomRefillScheduleWhenCondomsAreResupplied() { fakeIt(parse("2011-01-15")); strategy.renewFPProduct(new FPProductInformation("entity id 1", "anm id 1", "condom", null, null, null, null, "20", "2011-01-12", "", null, null, null)); InOrder inOrder = inOrder(scheduleTrackingService, scheduleService, actionService); inOrder.verify(scheduleTrackingService).fulfillCurrentMilestone("entity id 1", "Condom Refill", parse("2011-01-12")); inOrder.verify(actionService).markAlertAsClosed("entity id 1", "anm id 1", "Condom Refill", "2011-01-12"); inOrder.verify(scheduleService).enroll("entity id 1", "Condom Refill", "2011-02-01"); inOrder.verify(actionService).alertForBeneficiary(ec, "entity id 1", "Condom Refill", "Condom Refill", upcoming, dateTime("2011-02-01"), dateTime("2011-02-08")); }
@Test public void shouldDoNothingWhenCondomsAreNotResupplied() { strategy.renewFPProduct(new FPProductInformation("entity id 1", "anm id 1", "condom", null, null, null, null, "", "2011-01-012", "", null, null, null)); verifyZeroInteractions(scheduleTrackingService); verifyZeroInteractions(actionService); }