### Question:
QualityThreshold { public QualityStatus toStatus(int percent) { if (percent < failure) { return QualityStatus.FAILED; } else if (percent < warning) { return QualityStatus.WARNING; } return QualityStatus.PASSED; }  QualityStatus toStatus(int percent);  }### Answer:
@Test public void toStatus_should_return_FAILED_when_under_failure_threshold() { QualityThreshold threshold = new QualityThreshold().withFailure(50).withWarning(75); final QualityStatus status = threshold.toStatus(49); assertThat(status).isEqualTo(QualityStatus.FAILED); }
@Test public void toStatus_should_return_WARNING_when_over_failure_threshold_and_under_warning_threshold() { QualityThreshold threshold = new QualityThreshold().withFailure(50).withWarning(75); final QualityStatus status = threshold.toStatus(50); assertThat(status).isEqualTo(QualityStatus.WARNING); }
@Test public void toStatus_should_return_PASSED_when_over_warning_threshold() { QualityThreshold threshold = new QualityThreshold().withFailure(50).withWarning(75); final QualityStatus status = threshold.toStatus(75); assertThat(status).isEqualTo(QualityStatus.PASSED); }