MotherReportingService { public void reportToBoth(Mother mother, Indicator indicator, String date, String submissionDate, Location location) { if (!isBlank(date) && !reportMonth.areDatesBelongToSameReportingMonth(LocalDate.parse(date), LocalDate.parse(submissionDate))) return; report(mother, indicator, date, location); } @Autowired  MotherReportingService(ReportingService reportingService, AllMothers allMothers, AllEligibleCouples allEligibleCouples, ReportMonth reportMonth); void registerANC(SafeMap reportData); void ancVisit(SafeMap reportData); void ttProvided(SafeMap reportData); void deliveryOutcome(SafeMap reportData); void pncVisitHappened(SafeMap reportData); void closeANC(SafeMap reportData); void closePNC(SafeMap reportData); void reportToBoth(Mother mother, Indicator indicator, String date, String submissionDate, Location location); void pncRegistrationOA(SafeMap reportData); void deleteReports(String motherCaseId); static final int NUMBER_OF_DAYS_IN_12_WEEKS; static final int NUMBER_OF_DAYS_IN_PNC_PERIOD; }
@Test public void shouldNotReportWhenServiceProvidedDateAndFormSubmissionDateBelongToDifferentReportingMonth() throws Exception { Mother mother = new Mother("CASE-1", "EC-CASE-1", "TC 1"); Location location = new Location("village", "sc", "phc"); when(reportMonth.areDatesBelongToSameReportingMonth(parse("2012-01-01"), parse("2012-01-01"))).thenReturn(false); service.reportToBoth(mother, Indicator.ANC, "2012-01-01", "2012-01-01", location); verifyZeroInteractions(reportingService); verify(reportMonth).areDatesBelongToSameReportingMonth(parse("2012-01-01"), parse("2012-01-01")); }