ChildReportingService { public void reportInfantBalanceTurningOneYearOld() { LocalDate today = DateUtil.today(); LocalDate startOfCurrentReportMonth = this.reportMonth.startOfCurrentReportMonth(today); List<Child> childrenTurnedOneYearOld = allChildren.findAllChildrenWhoTurnedOneYearOld( startOfCurrentReportMonth); logger.info(MessageFormat.format("Found {0} children for reporting Infant Balance (Turned One Year old) ", childrenTurnedOneYearOld.size())); updateInfantBalanceIndicator(Indicator.INFANT_BALANCE_TURNING_ONE_YEAR, childrenTurnedOneYearOld, startOfCurrentReportMonth.toString()); } @Autowired  ChildReportingService(ReportingService reportingService, AllChildren allChildren, AllMothers allMothers,
                                 AllEligibleCouples allEligibleCouples,
                                 AllInfantBalanceOnHandReportTokens allInfantBalanceOnHandReportTokens, ReportMonth reportMonth, MCTSReporter mctsReporter); void registerChild(SafeMap reportData); void immunizationProvided(SafeMap reportData, List<String> previousImmunizations); void vitaminAProvided(SafeMap reportData); void pncVisitHappened(SafeMap reportData); void sickVisitHappened(SafeMap reportData); void closeChild(SafeMap reportData); void reportToBoth(Child child, Indicator indicator, String serviceProvidedDate, String submissionDate, Location location); void reportToBoth(Child child, Indicator indicator, String serviceProvidedDate, Location location); void reportInfantAndChildBalance(); void reportInfantBalanceOnHand(); void reportInfantBalanceTurningOneYearOld(); void reportInfantBalanceTotalNumberOfOAChildren(); void reportInfantBalanceLessThanOneYearOld(); void reportChildBalanceLessThanFiveYearOld(); static final String CHILD_ID_FIELD; }
@Test public void shouldReportInfantBalanceTurningOneYear() throws Exception { DateUtil.fakeIt(parse("2013-02-01")); Mother mother = new Mother("mother id 1", "ec id 1", "thayi card 1"); Child child = new Child("child id 1", "mother id 1", "bcg", "3", "female").withThayiCard("thayi card 1").withAnm("ANM X").withDateOfBirth("2012-01-15"); EligibleCouple ec = new EligibleCouple("ec id 1", "123").withLocation("bherya", "Sub Center", "PHC X").asOutOfArea(); when(allEligibleCouples.findByCaseId("ec id 1")).thenReturn(ec); when(allMothers.findByCaseId("mother id 1")).thenReturn(mother); when(allChildren.findAllChildrenWhoTurnedOneYearOld(any(LocalDate.class))).thenReturn(asList(child)); when(reportMonth.startOfCurrentReportMonth(any(LocalDate.class))).thenReturn(parse("2013-01-26")); when(reportMonth.endOfCurrentReportMonth(any(LocalDate.class))).thenReturn(parse("2013-02-25")); when(reportMonth.isDateWithinCurrentReportMonth(any(LocalDate.class))).thenReturn(true); service.reportInfantBalanceTurningOneYearOld(); verifyBothUpdateReportCalls(Indicator.INFANT_BALANCE_TURNING_ONE_YEAR, "2013-01-26", "child id 1", "thayi card 1", "2013-01-26", "2013-02-25"); }
@Test public void shouldReportInfantBalanceTurningOneYearWithExternalIdAsECNumberIfThayiCardNumberIsNotPresent() throws Exception { DateUtil.fakeIt(parse("2013-02-01")); Mother mother = new Mother("mother id 1", "ec id 1", null); Child child = new Child("child id 1", "mother id 1", "bcg", "3", "female").withAnm("ANM X").withDateOfBirth("2012-01-15"); EligibleCouple ec = new EligibleCouple("ec id 1", "123").withLocation("bherya", "Sub Center", "PHC X").asOutOfArea(); when(allMothers.findByCaseId("mother id 1")).thenReturn(mother); when(allEligibleCouples.findByCaseId("ec id 1")).thenReturn(ec); when(allChildren.findAllChildrenWhoTurnedOneYearOld(any(LocalDate.class))).thenReturn(asList(child)); when(reportMonth.startOfCurrentReportMonth(any(LocalDate.class))).thenReturn(parse("2013-01-26")); when(reportMonth.endOfCurrentReportMonth(any(LocalDate.class))).thenReturn(parse("2013-02-25")); when(reportMonth.isDateWithinCurrentReportMonth(any(LocalDate.class))).thenReturn(true); service.reportInfantBalanceTurningOneYearOld(); verifyBothUpdateReportCalls(Indicator.INFANT_BALANCE_TURNING_ONE_YEAR, "2013-01-26", "child id 1", "123", "2013-01-26", "2013-02-25"); }