IsHypertensionStateChangedRule implements IRule { @Override public boolean apply(SafeMap reportFields) { boolean currentHyperTensionStatus = isHyperTensed(reportFields.get(BP_DIASTOLIC), reportFields.get(BP_SYSTOLIC)); boolean previousHyperTensionStatus =isHyperTensed(reportFields.get(PREVIOUS_BP_DIASTOLIC),reportFields.get(PREVIOUS_BP_SYSTOLIC)); return currentHyperTensionStatus != previousHyperTensionStatus; }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnTrueWhenHyperTensionStateChanged() { Map<String, String> reportFields = create("id", "mother id 1") .put("bpSystolic","140") .put("bpDiastolic", "90") .put("previousBpSystolic", "130") .put("previousBpDiastolic", "80") .map(); assertTrue(rule.apply(new SafeMap(reportFields))); reportFields = create("id", "mother id 1") .put("bpSystolic","140") .put("bpDiastolic", "80") .put("previousBpSystolic", "130") .put("previousBpDiastolic", "80") .map(); assertTrue(rule.apply(new SafeMap(reportFields))); reportFields = create("id", "mother id 1") .put("bpSystolic","120") .put("bpDiastolic", "90") .put("previousBpSystolic", "130") .put("previousBpDiastolic", "80") .map(); assertTrue(rule.apply(new SafeMap(reportFields))); }
@Test public void shouldReturnFalseWhenHyperTensionStateIsNotChanged() { Map<String, String> reportFields = create("id", "mother id 1") .put("bpSystolic", "125") .put("bpDiastolic", "80") .put("previousBpSystolic", "130") .put("previousBpDiastolic", "80") .map(); assertFalse(rule.apply(new SafeMap(reportFields))); }