MotherService { public void deliveryPlan(FormSubmission submission) { allTimelines.add( forDeliveryPlan( submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submission.getFieldValue(PHONE_NUMBER), submission.getFieldValue(REVIEWED_HRP_STATUS), submission.getFieldValue(SUBMISSION_DATE))); serviceProvidedService.add( ServiceProvided.forDeliveryPlan( submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submission.getFieldValue(PHONE_NUMBER), submission.getFieldValue(REVIEWED_HRP_STATUS), submission.getFieldValue(SUBMISSION_DATE) )); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples allEligibleCouples,
                         AllTimelineEvents allTimelineEvents, ServiceProvidedService serviceProvidedService); void registerANC(FormSubmission submission); void registerOutOfAreaANC(FormSubmission submission); void ancVisit(FormSubmission submission); void close(FormSubmission submission); void close(String entityId, String reason); void ttProvided(FormSubmission submission); void ifaTabletsGiven(FormSubmission submission); void hbTest(FormSubmission submission); void deliveryOutcome(FormSubmission submission); void pncVisitHappened(FormSubmission submission); void deliveryPlan(FormSubmission submission); static final String MOTHER_ID; static String submissionDate; }
@Test public void shouldAddTimelineEventWhenDeliveryPlanHappens() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("deliveryFacilityName")).thenReturn("Delivery Facility Name"); when(submission.getFieldValue("transportationPlan")).thenReturn("Transportation Plan"); when(submission.getFieldValue("birthCompanion")).thenReturn("Birth Companion"); when(submission.getFieldValue("ashaPhoneNumber")).thenReturn("Asha Phone"); when(submission.getFieldValue("phoneNumber")).thenReturn("1234567890"); when(submission.getFieldValue("reviewedHRPStatus")).thenReturn("HRP Status"); when(submission.getFieldValue("submissionDate")).thenReturn("2012-01-01"); service.deliveryPlan(submission); verify(allTimelineEvents).add(forDeliveryPlan("entity id 1", "Delivery Facility Name", "Transportation Plan", "Birth Companion", "Asha Phone", "1234567890", "HRP Status", "2012-01-01")); }
@Test public void shouldAddServiceProvidedWhenDeliveryPlanHappens() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("deliveryFacilityName")).thenReturn("Delivery Facility Name"); when(submission.getFieldValue("transportationPlan")).thenReturn("Transportation Plan"); when(submission.getFieldValue("birthCompanion")).thenReturn("Birth Companion"); when(submission.getFieldValue("ashaPhoneNumber")).thenReturn("Asha Phone"); when(submission.getFieldValue("phoneNumber")).thenReturn("1234567890"); when(submission.getFieldValue("reviewedHRPStatus")).thenReturn("HRP Status"); when(submission.getFieldValue("submissionDate")).thenReturn("2012-01-01"); service.deliveryPlan(submission); verify(serviceProvidedService).add(ServiceProvided.forDeliveryPlan("entity id 1", "Delivery Facility Name", "Transportation Plan", "Birth Companion", "Asha Phone", "1234567890", "HRP Status", "2012-01-01")); }