IsPNCVisit48HoursOfDeliveryRule implements IRule { @Override public boolean apply(SafeMap reportFields) { LocalDate pncVisitDate = LocalDate.parse(reportFields.get(VISIT_DATE_FIELD_NAME)); LocalDate dateOfBirth = LocalDate.parse(reportFields.get(REFERENCE_DATE)); LocalDate threeDaysAfterDateOfBirth = dateOfBirth.plusDays(3); return pncVisitDate.isBefore(threeDaysAfterDateOfBirth); }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnTrueIfThePNCVisitIsTheVisitHappenedBefore48HoursOfDelivery() { SafeMap safeMap = new SafeMap(); safeMap.put("pncVisitDate", "2012-01-01"); safeMap.put("referenceDate", "2012-01-01"); boolean didRuleApply = rule.apply(safeMap); assertTrue(didRuleApply); safeMap = new SafeMap(); safeMap.put("pncVisitDate", "2012-01-02"); safeMap.put("referenceDate", "2012-01-01"); didRuleApply = rule.apply(safeMap); assertTrue(didRuleApply); }
@Test public void shouldReturnFalseIfThePNCVisitIsNotTheVisit48HoursOfDelivery() { SafeMap safeMap = new SafeMap(); safeMap.put("pncVisitDate", "2012-01-04"); safeMap.put("pncVisitDates", null); safeMap.put("referenceDate", "2012-01-01"); boolean didRuleApply = rule.apply(safeMap); assertFalse(didRuleApply); safeMap = new SafeMap(); safeMap.put("pncVisitDate", "2012-01-06"); safeMap.put("referenceDate", "2012-01-01"); didRuleApply = rule.apply(safeMap); assertFalse(didRuleApply); }