ChildReporter implements IReporter { @Override public void report(String entityId, String reportIndicator, Location location, String serviceProvidedDate, SafeMap reportData) { Child child = allChildren.findByCaseId(entityId); childReportingService.reportToBoth(child, Indicator.from(reportIndicator), serviceProvidedDate, reportData.get(SUBMISSION_DATE_FIELD_NAME), location); } @Autowired  ChildReporter(ChildReportingService childReportingService, AllChildren allChildren); @Override void report(String entityId, String reportIndicator, Location location, String serviceProvidedDate, SafeMap reportData);  }
@Test public void shouldCallChildReportingService() { FormSubmission submission = create() .withEntityId("child id 1") .addFormField("submissionDate", "2012-03-01") .build(); Location location = new Location("village", "sc", "phc"); when(allChildren.findByCaseId("child id 1")).thenReturn(child); SafeMap safeMap = new SafeMap().put("submissionDate", "2012-03-01"); reporter.report(submission.entityId(), "INFANT_LEFT", location, "2012-03-01", safeMap); verify(childReportingService).reportToBoth(child, Indicator.from("INFANT_LEFT"), submission.getField("submissionDate"), submission.getField("submissionDate"), location); }