IsOPV0ImmunizationGivenRule implements IRule { @Override public boolean apply(SafeMap reportFields) { return new ChildImmunization().isImmunizedWith(OPV_0_VALUE, reportFields); }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnTrueIfImmunizationsGivenContainsOPV_0() { SafeMap safeMap = new SafeMap(create("immunizationsGiven", "pentavalent_1 opv_0 tt_1").map()); boolean didRuleApply = rule.apply(safeMap); assertTrue(didRuleApply); didRuleApply = rule.apply(new SafeMap(create("immunizationsGiven", "pentavalent_1 opv_0 tt_1").put("previousImmunizations", "pentavalent_1 tt_1").map())); Assert.assertTrue(didRuleApply); didRuleApply = rule.apply(new SafeMap(create("immunizationsGiven", "pentavalent_1 opv_0 tt_1").put("previousImmunizations", "").map())); Assert.assertTrue(didRuleApply); didRuleApply = rule.apply(new SafeMap(create("immunizationsGiven", "pentavalent_1 opv_0 tt_1").put("previousImmunizations", null).map())); Assert.assertTrue(didRuleApply); }
@Test public void shouldReturnFalseIfImmunizationsGivenDoesNotContainOPV_0() { boolean didRuleApply = rule.apply(new SafeMap(create("immunizationsGiven", "").map())); assertFalse(didRuleApply); didRuleApply = rule.apply(new SafeMap().put("immunizationsGiven", null)); assertFalse(didRuleApply); didRuleApply = rule.apply(new SafeMap(create("immunizationsGiven", "pentavalent_1 tt_1").map())); assertFalse(didRuleApply); didRuleApply = rule.apply(new SafeMap(create("immunizationsGiven", "pentavalent_1 opv_0 tt_1").put("previousImmunizations", "opv_0").map())); Assert.assertFalse(didRuleApply); }