ChildService { public void updateIllnessStatus(FormSubmission submission) { String sickVisitDate = submission.getFieldValue(SICK_VISIT_DATE); String date = sickVisitDate != null ? sickVisitDate : submission.getFieldValue(REPORT_CHILD_DISEASE_DATE); serviceProvidedService.add( ServiceProvided.forChildIllnessVisit(submission.entityId(), date, createChildIllnessMap(submission)) ); } ChildService(AllBeneficiaries allBeneficiaries, MotherRepository motherRepository, ChildRepository childRepository,
                        AllTimelineEvents allTimelineEvents, ServiceProvidedService serviceProvidedService, AllAlerts allAlerts); void register(FormSubmission submission); void registerForEC(FormSubmission submission); void pncRegistrationOA(FormSubmission submission); void updateImmunizations(FormSubmission submission); void pncVisitHappened(FormSubmission submission); void close(FormSubmission submission); void updatePhotoPath(String entityId, String imagePath); void updateIllnessStatus(FormSubmission submission); void updateVitaminAProvided(FormSubmission submission); void registerForOA(FormSubmission submission);  }
@Test public void shouldUpdateIllnessForUpdateIllnessAction() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("child id 1"); when(submission.getFieldValue("submissionDate")).thenReturn("2012-01-02"); when(submission.getFieldValue("sickVisitDate")).thenReturn("2012-01-01"); when(submission.getFieldValue("childSigns")).thenReturn("child signs"); when(submission.getFieldValue("childSignsOther")).thenReturn("child signs other"); when(submission.getFieldValue("reportChildDisease")).thenReturn("report child disease"); when(submission.getFieldValue("reportChildDiseaseOther")).thenReturn("report child disease other"); when(submission.getFieldValue("reportChildDiseaseDate")).thenReturn(null); when(submission.getFieldValue("reportChildDiseasePlace")).thenReturn("report child disease place"); when(submission.getFieldValue("childReferral")).thenReturn("child referral"); service.updateIllnessStatus(submission); Map<String, String> map = EasyMap.create("sickVisitDate", "2012-01-01") .put("childSignsOther", "child signs other") .put("childSigns", "child signs") .put("reportChildDisease", "report child disease") .put("reportChildDiseaseOther", "report child disease other") .put("reportChildDiseaseDate", null) .put("reportChildDiseasePlace", "report child disease place") .put("childReferral", "child referral").map(); verify(serviceProvidedService).add(forChildIllnessVisit("child id 1", "2012-01-01", map)); }