DefaultValueChecker implements ValueChecker { @Override public AlertType checkValue(BigDecimal value, BigDecimal warn, BigDecimal error) { boolean isHighValueWorse = isTheValueBeingHighWorse(warn, error); if (isBeyondThreshold(value, error, isHighValueWorse)) { return AlertType.ERROR; } else if (isBeyondThreshold(value, warn, isHighValueWorse)) { return AlertType.WARN; } return AlertType.OK; }  @Override AlertType checkValue(BigDecimal value, BigDecimal warn, BigDecimal error);  }
@Test public void alertHasOkStateForBadHighValueWhenValueIsLessThanWarn() { assertThat(checker.checkValue(bd("0.10"), bd("0.15"), bd("0.20")), is(AlertType.OK)); }
@Test public void alertHasWarnStateForBadHighValueWhenValueIsEqualToWarn() { assertThat(checker.checkValue(bd("0.15"), bd("0.15"), bd("0.20")), is(AlertType.WARN)); }
@Test public void alertHasWarnStateForBadHighValueWhenValueIsGreaterToWarnButLessThanError() { assertThat(checker.checkValue(bd("0.16"), bd("0.15"), bd("0.20")), is(AlertType.WARN)); }
@Test public void alertHasErrorStateForBadHighValueWhenValueIsEqualToError() { assertThat(checker.checkValue(bd("0.20"), bd("0.15"), bd("0.20")), is(AlertType.ERROR)); }
@Test public void alertHasErrorStateForBadHighValueWhenValueIsGreaterThanError() { assertThat(checker.checkValue(bd("0.21"), bd("0.15"), bd("0.20")), is(AlertType.ERROR)); }
@Test public void alertHasOkStateForBadLowValueWhenValueIsGreaterThanWarn() { assertThat(checker.checkValue(bd("0.21"), bd("0.20"), bd("0.15")), is(AlertType.OK)); }
@Test public void alertHasWarnStateForBadLowValueWhenValueIsEqualToWarn() { assertThat(checker.checkValue(bd("0.20"), bd("0.20"), bd("0.15")), is(AlertType.WARN)); }
@Test public void alertHasWarnStateForBadLowValueWhenValueIsLessThanWarnButGreaterThanError() { assertThat(checker.checkValue(bd("0.19"), bd("0.20"), bd("0.15")), is(AlertType.WARN)); }
@Test public void alertHasErrorStateForBadLowValueWhenValueIsEqualToError() { assertThat(checker.checkValue(bd("0.15"), bd("0.20"), bd("0.15")), is(AlertType.ERROR)); }
@Test public void alertHasErrorStateForBadLowValueWhenValueIsLessThanError() { assertThat(checker.checkValue(bd("0.14"), bd("0.20"), bd("0.15")), is(AlertType.ERROR)); }