PNCVisitHappenedAtSubCenterOrHomeRule implements IRule { @Override public boolean apply(SafeMap reportFields) { return SUB_CENTER_SERVICE_PROVIDED_PLACE_VALUE.equalsIgnoreCase(reportFields.get(VISIT_PLACE_FIELD_NAME)) || HOME_FIELD_VALUE.equalsIgnoreCase(reportFields.get(VISIT_PLACE_FIELD_NAME)); }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnTrueWhenPNCVisitHappenedInSubCenterOrHome() { Map<String, String> reportFields = create("pncVisitPlace", "sub_center") .map(); boolean didRuleApplied = rule.apply(new SafeMap(reportFields)); assertTrue(didRuleApplied); reportFields = create("pncVisitPlace", "home") .map(); didRuleApplied = rule.apply(new SafeMap(reportFields)); assertTrue(didRuleApplied); }
@Test public void shouldReturnFalseWhenPNCVisitDidNotHappenedInSubCenterOrHome() { Map<String, String> reportFields = create("pncVisitPlace", "phc") .map(); boolean didRuleApplied = rule.apply(new SafeMap(reportFields)); assertFalse(didRuleApplied); reportFields = create("pncVisitPlace", "elsewhere") .map(); didRuleApplied = rule.apply(new SafeMap(reportFields)); assertFalse(didRuleApplied); }