IsMotherHavingMalariaParasiteRule implements IRule { @Override public boolean apply(SafeMap reportFields) { String testsWithPositiveResult = reportFields.get(TESTS_POSITIVE_RESULTS); return testsWithPositiveResult != null ? testsWithPositiveResult.contains(MALARIA_VALUE) : false; }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnTrueIfMotherHasMalaria() { SafeMap safeMap = new SafeMap(create("testsResultPositive", "mp urine_albumin").map()); boolean didRuleApply = rule.apply(safeMap); assertTrue(didRuleApply); }
@Test public void shouldReturnFalseIfMotherDoesNotHaveMalaria() { boolean didRuleApply = rule.apply(new SafeMap(create("testsResultPositive", "").map())); assertFalse(didRuleApply); didRuleApply = rule.apply(new SafeMap().put("testsResultPositive", "urine_albumin")); assertFalse(didRuleApply); didRuleApply = rule.apply(new SafeMap().put("testsResultPositive", null)); assertFalse(didRuleApply); }