EligibleCoupleReporter implements IReporter { @Override public void report(String entityId, String reportIndicator, Location location, String serviceProvidedDate, SafeMap reportData) { EligibleCouple eligibleCouple = allEligibleCouples.findByCaseId(entityId); ecReportingService.reportIndicator(reportData, eligibleCouple, Indicator.from(reportIndicator), serviceProvidedDate, reportData.get(SUBMISSION_DATE_FIELD_NAME)); } @Autowired  EligibleCoupleReporter(ECReportingService ecReportingService, AllEligibleCouples allEligibleCouples); @Override void report(String entityId, String reportIndicator, Location location, String serviceProvidedDate, SafeMap reportData);  }
@Test public void shouldCallECReporting() { FormSubmission submission = create() .withEntityId("ec id 1") .addFormField("familyPlanningMethodChangeDate", "2012-03-01") .addFormField("submissionDate", "2012-03-01") .build(); ArrayList<String> fieldNames = new ArrayList<>(); fieldNames.add("submissionDate"); SafeMap reportData = new SafeMap(submission.getFields(fieldNames)); Location location = new Location("village", "sc", "phc"); when(allEligibleCouples.findByCaseId("ec id 1")).thenReturn(eligibleCouple); reporter.report(submission.entityId(), "OCP", location, "2012-03-01", reportData); verify(ecReportingService).reportIndicator(reportData, eligibleCouple, Indicator.from("OCP"), "2012-03-01", "2012-03-01"); }