IsChildMoreThan16MonthsRule 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(16).isBefore(reportDate); }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnFalseWhenChildIsBelow16Months() { Map<String, String> reportData = create("serviceProvidedDate", "2012-12-01") .put("dateOfBirth", "2012-01-01") .map(); boolean didRuleSucceed = rule.apply(new SafeMap(reportData)); assertFalse(didRuleSucceed); reportData = create("serviceProvidedDate", "2013-05-01") .put("dateOfBirth", "2012-01-01") .map(); didRuleSucceed = rule.apply(new SafeMap(reportData)); assertFalse(didRuleSucceed); }
@Test public void shouldReturnTrueWhenChildIsAbove16Months() { Map<String, String> reportData = create("serviceProvidedDate", "2013-05-02") .put("dateOfBirth", "2012-01-01") .map(); boolean didRuleSucceed = rule.apply(new SafeMap(reportData)); assertTrue(didRuleSucceed); }