IsMotherDidNotSurvivedOnDeliveryRule implements IRule { @Override public boolean apply(SafeMap reportFields) { String didWomanSurvive = reportFields.get(DID_WOMAN_SURVIVE); String didMotherSurvive = reportFields.get(DID_MOTHER_SURVIVE); return (didWomanSurvive != null && didWomanSurvive.equalsIgnoreCase(BOOLEAN_FALSE_VALUE)) || (didMotherSurvive != null && didMotherSurvive.equalsIgnoreCase(BOOLEAN_FALSE_VALUE)); }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnTrueIfMotherDidNotSurviveOnDelivery() { SafeMap safeMap = new SafeMap(create("didWomanSurvive", "no") .put("didMotherSurvive", "no").map()); boolean didRuleApply = rule.apply(safeMap); assertTrue(didRuleApply); safeMap = new SafeMap(create("didWomanSurvive", "yes") .put("didMotherSurvive", "no").map()); didRuleApply = rule.apply(safeMap); assertTrue(didRuleApply); safeMap = new SafeMap(create("didWomanSurvive", "no") .put("didMotherSurvive", "yes").map()); didRuleApply = rule.apply(safeMap); assertTrue(didRuleApply); safeMap = new SafeMap().put("didWomanSurvive", "no") .put("didMotherSurvive", null); didRuleApply = rule.apply(safeMap); assertTrue(didRuleApply); safeMap = new SafeMap().put("didWomanSurvive", null) .put("didMotherSurvive", "no"); didRuleApply = rule.apply(safeMap); assertTrue(didRuleApply); }
@Test public void shouldReturnFalseIfMotherSurvivedOnDelivery() { SafeMap safeMap = new SafeMap(create("didWomanSurvive", "yes") .put("didMotherSurvive", "yes").map()); boolean didRuleApply = rule.apply(safeMap); assertFalse(didRuleApply); safeMap = new SafeMap().put("didWomanSurvive", null) .put("didMotherSurvive", "yes"); didRuleApply = rule.apply(safeMap); assertFalse(didRuleApply); safeMap = new SafeMap().put("didWomanSurvive", "yes") .put("didMotherSurvive", null); didRuleApply = rule.apply(safeMap); assertFalse(didRuleApply); }