MotherService { public void ancVisit(FormSubmission submission) { allTimelines.add( forANCCareProvided( submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), create(BP_SYSTOLIC, submission.getFieldValue(BP_SYSTOLIC)) .put(BP_DIASTOLIC, submission.getFieldValue(BP_DIASTOLIC)) .put(TEMPERATURE, submission.getFieldValue(TEMPERATURE)) .put(WEIGHT, submission.getFieldValue(WEIGHT)) .map())); serviceProvidedService.add( ServiceProvided.forANCCareProvided( submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), submission.getFieldValue(BP_SYSTOLIC), submission.getFieldValue(BP_DIASTOLIC), submission.getFieldValue(WEIGHT))); } 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 shouldCreateTimelineEventsWhenANCVisitHappens() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("ancVisitDate")).thenReturn("2013-01-01"); when(submission.getFieldValue("ancVisitNumber")).thenReturn("2"); when(submission.getFieldValue("weight")).thenReturn("21"); when(submission.getFieldValue("bpDiastolic")).thenReturn("80"); when(submission.getFieldValue("bpSystolic")).thenReturn("90"); when(submission.getFieldValue("temperature")).thenReturn("98.5"); service.ancVisit(submission); verify(allTimelineEvents).add(TimelineEvent.forANCCareProvided("entity id 1", "2", "2013-01-01", create("bpDiastolic", "80").put("bpSystolic", "90").put("temperature", "98.5").put("weight", "21").map())); }
@Test public void shouldAddServiceProvidedWhenANCVisitHappens() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("ancVisitDate")).thenReturn("2013-01-01"); when(submission.getFieldValue("ancVisitNumber")).thenReturn("1"); when(submission.getFieldValue("weight")).thenReturn("21"); when(submission.getFieldValue("bpDiastolic")).thenReturn("80"); when(submission.getFieldValue("bpSystolic")).thenReturn("90"); service.ancVisit(submission); verify(serviceProvidedService).add( new ServiceProvided("entity id 1", "ANC 1", "2013-01-01", create("bpDiastolic", "80").put("bpSystolic", "90").put("weight", "21").map())); }