IsPersonAnaemicStatusChangedRule implements IRule { @Override public boolean apply(SafeMap reportFields) { String anaemicStatus = reportFields.get(ANAEMIC_STATUS_FIELD) != null ? reportFields.get(ANAEMIC_STATUS_FIELD) : ""; String previousAnaemicStatus = reportFields.get(PREVIOUS_ANAEMIC_STATUS_FIELD); return !anaemicStatus.equalsIgnoreCase(previousAnaemicStatus); }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnTrueWhenThePersonAnaemicStatusChanged() throws Exception { SafeMap reportFields = new SafeMap(create("previousAnaemicStatus", "Anaemia") .put("anaemicStatus", "Severe_Anaemia") .map()); boolean rulePassed = rule.apply(reportFields); assertTrue(rulePassed); reportFields = new SafeMap(create("previousAnaemicStatus", "") .put("anaemicStatus", "Severe_Anaemia") .map()); rulePassed = rule.apply(reportFields); assertTrue(rulePassed); }
@Test public void shouldReturnFalseWhenThePersonAnaemicStatusIsNotChanges() throws Exception { SafeMap reportFields = new SafeMap(create("previousAnaemicStatus", "Severe_Anaemia") .put("anaemicStatus", "Severe_Anaemia") .map()); boolean rulePassed = rule.apply(reportFields); assertFalse(rulePassed); }