IsDeathDueToSpontaneousAbortionRule implements IRule { @Override public boolean apply(SafeMap reportFields) { return SPONTANEOUS_ABORTION_VALUE.equalsIgnoreCase(reportFields.get(CLOSE_REASON_FIELD_NAME)); }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnFalseWhenDeathIsNotDueToAbortion() { boolean didRuleSucceed = rule.apply(new SafeMap().put("closeReason", null)); assertFalse(didRuleSucceed); didRuleSucceed = rule.apply(new SafeMap().put("closeReason", "")); assertFalse(didRuleSucceed); didRuleSucceed = rule.apply(new SafeMap().put("closeReason", "fever_infection")); assertFalse(didRuleSucceed); }
@Test public void shouldReturnTrueWhenDeathIsDueToAbortion() { boolean didRuleSucceed = rule.apply(new SafeMap().put("closeReason", "spontaneous_abortion")); assertTrue(didRuleSucceed); }