IsPersonAnaemicRule implements IRule { @Override public boolean apply(SafeMap reportFields) { double hbLevel = DoubleUtil.tryParse(reportFields.get(HB_LEVEL_FIELD), HB_LEVEL_THRESHOLD_FOR_ANAEMIA + 1); return hbLevel < HB_LEVEL_THRESHOLD_FOR_ANAEMIA; }  @Override boolean apply(SafeMap reportFields); static final Double HB_LEVEL_THRESHOLD_FOR_ANAEMIA; }
@Test public void shouldReturnTrueWhenHBLevelIsLessThanEleven() throws Exception { EasyMap easyMap = create("serviceProvidedPlace", "sub_center").put("hbLevel", "10.3"); boolean rulePassed = isPersonAnaemicRule.apply(new SafeMap(easyMap.map())); assertTrue(rulePassed); }
@Test public void shouldReturnFalseWhenHBLevelIsMoreThanEleven() throws Exception { EasyMap easyMap = create("serviceProvidedPlace", "sub_center").put("hbLevel", "11.3"); boolean rulePassed = isPersonAnaemicRule.apply(new SafeMap(easyMap.map())); assertFalse(rulePassed); }