### Question:
ValueValidator { public static <T> T checkAndGet(T value, T defaultValue, Validator<T> v) { if (v.validate(value)) { return value; } return defaultValue; }  static T checkAndGet(T value, T defaultValue, Validator<T> v);  }### Answer:
@Test public void testValidator() { assertThat(ValueValidator.checkAndGet(-1, 1, Validator.INTEGER_GT_ZERO_VALIDATOR)).isEqualTo(1); assertThat(ValueValidator.checkAndGet("testUnEmpty", "isEmpty", Validator.STRING_EMPTY_VALUE_VALIDATOR)) .isEqualTo("testUnEmpty"); assertThat(ValueValidator.checkAndGet("flase", "true", Validator.STRICT_BOOL_VALUE_VALIDATOR)) .isEqualTo("true"); }
@Test public void testValidator() { assertThat(ValueValidator.checkAndGet(-1, 1, Validator.INTEGER_GT_ZERO_VALIDATOR)).isEqualTo(1); assertThat(ValueValidator.checkAndGet("testUnEmpty", "isEmpty", Validator.STRING_EMPTY_VALUE_VALIDATOR)).isEqualTo("testUnEmpty"); assertThat(ValueValidator.checkAndGet("flase", "true", Validator.STRICT_BOOL_VALUE_VALIDATOR)).isEqualTo("true"); }