IsDeliveryDateOneYearInThePastRule implements IRule { @Override public boolean apply(SafeMap reportFields) { LocalDate dateOfBirth = LocalDate.parse(reportFields.get(REFERENCE_DATE)); LocalDate serviceProvidedDate = LocalDate.parse(reportFields.get(SERVICE_PROVIDED_DATE)); return dateOfBirth.plusYears(1).isAfter(serviceProvidedDate); }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnTrueIfDeliveryDateIsLessThanOneYear() { SafeMap safeMap = new SafeMap(); safeMap.put("serviceProvidedDate", "2012-03-01"); safeMap.put("referenceDate", "2012-01-01"); boolean didRuleApply = rule.apply(safeMap); assertTrue(didRuleApply); }
@Test public void shouldReturnTrueIfDeliveryDateIsNotLessThanOneYear() { SafeMap safeMap = new SafeMap(); safeMap.put("serviceProvidedDate", "2012-03-01"); safeMap.put("referenceDate", "2011-01-01"); boolean didRuleApply = rule.apply(safeMap); assertFalse(didRuleApply); }