DMPAInjectableStrategy implements FPMethodStrategy { @Override public void renewFPProduct(FPProductInformation fpInfo) { if (tryParse(fpInfo.dmpaInjectionDate(), null) == null) { return; } logger.info(format("Fulfilling DMPA Injectable Refill schedule as FP product was renewed. entityId: {0}, DMPA injection date: {1}", fpInfo.entityId(), fpInfo.dmpaInjectionDate())); scheduleTrackingService.fulfillCurrentMilestone(fpInfo.entityId(), dmpaInjectableRefillSchedule.name(), parse(fpInfo.submissionDate())); actionService.markAlertAsClosed(fpInfo.entityId(), fpInfo.anmId(), dmpaInjectableRefillSchedule.name(), fpInfo.dmpaInjectionDate()); enrollECToDMPAInjectableSchedule(fpInfo.entityId(), fpInfo.dmpaInjectionDate()); } @Autowired  DMPAInjectableStrategy(ScheduleTrackingService scheduleTrackingService, ActionService actionService, ScheduleService scheduleService); @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 shouldUpdateDMPAInjectableRefillScheduleWhenDMPAIsReinjected() { strategy.renewFPProduct(new FPProductInformation("entity id 1", "anm id 1", "dmpa_injectable", null, "2012-01-01", null, null, null, "2011-01-12", "", null, null, null)); InOrder inOrder = inOrder(scheduleTrackingService, actionService, scheduleService); inOrder.verify(scheduleTrackingService).fulfillCurrentMilestone("entity id 1", "DMPA Injectable Refill", parse("2011-01-12")); inOrder.verify(actionService).markAlertAsClosed("entity id 1", "anm id 1", "DMPA Injectable Refill", "2012-01-01"); inOrder.verify(scheduleService).enroll("entity id 1", "DMPA Injectable Refill", "2012-01-01"); }
@Test public void shouldDoNothingWhenDMPANotInjected() { strategy.renewFPProduct(new FPProductInformation("entity id 1", "anm id 1", "dmpa_injectable", null, "", null, null, null, "2011-01-12", "", null, null, null)); verifyZeroInteractions(scheduleTrackingService); verifyZeroInteractions(actionService); strategy.renewFPProduct(new FPProductInformation("entity id 1", "anm id 1", "dmpa_injectable", null, null, null, null, null, "2011-01-12", "", null, null, null)); verifyZeroInteractions(scheduleTrackingService); verifyZeroInteractions(actionService); }