ChildService { public void sickVisitHappened(FormSubmission submission) { Map<String, String> reportFieldsMap = submission.getFields(reportFieldsDefinition.get(submission.formName())); childReportingService.sickVisitHappened(new SafeMap(reportFieldsMap)); } @Autowired  ChildService(ChildSchedulesService childSchedulesService,
                        AllMothers allMothers,
                        AllChildren allChildren,
                        ChildReportingService childReportingService, ActionService actionService, ReportFieldsDefinition reportFieldsDefinition); void registerChildren(FormSubmission submission); void registerChildrenForEC(FormSubmission submission); void registerChildrenForOA(FormSubmission submission); void updateChildImmunization(FormSubmission submission); void vitaminAProvided(FormSubmission submission); void closeChild(FormSubmission submission); void pncOAChildRegistration(FormSubmission submission); void pncVisitHappened(FormSubmission submission); void sickVisitHappened(FormSubmission submission); static final String IMMUNIZATIONS_SEPARATOR; }
@Test public void shouldReportWhenSickVisitHappened() { FormSubmission submission = create() .withFormName("child_illness") .withANMId("anm id 1") .withEntityId("child id 1") .addFormField("some-field", "some-value") .build(); when(reportFieldsDefinition.get("child_illness")).thenReturn(asList("some-field")); service.sickVisitHappened(submission); verify(childReportingService).sickVisitHappened(new SafeMap( mapOf("some-field", "some-value"))); }