IsChildLessThan23MonthsRule implements IRule { @Override public boolean apply(SafeMap reportFields) { LocalDate dateOfBirth = LocalDate.parse(reportFields.get(DATE_OF_BIRTH)); LocalDate reportDate = LocalDate.parse(reportFields.get(SERVICE_PROVIDED_DATE)); return dateOfBirth.plusMonths(23).isAfter(reportDate); }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnTrueIfAgeIsLessThan23Months() { SafeMap safeMap = new SafeMap(); safeMap.put("serviceProvidedDate", "2012-03-01"); safeMap.put("dateOfBirth", "2012-01-01"); boolean didRuleApply = rule.apply(safeMap); Assert.assertTrue(didRuleApply); }
@Test public void shouldReturnFalseIfAgeIsNotLessThan23Months() { SafeMap safeMap = new SafeMap(); safeMap.put("serviceProvidedDate", "2014-03-01"); safeMap.put("dateOfBirth", "2011-01-01"); boolean didRuleApply = rule.apply(safeMap); assertFalse(didRuleApply); }