BooleanTypeConverter implements TypeConverter<String, Boolean> { @Override public Boolean convert(final String value) { return Boolean.parseBoolean(value) || "1".equals(value) || "on".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value); }  @Override Boolean convert(final String value);  }
@Test public void whenInputIsOneOfPredefinedTrueValues_ThenShouldReturnBooleanTrueValue() { assertThat(booleanTypeConverter.convert("true")).isTrue(); assertThat(booleanTypeConverter.convert("TRUE")).isTrue(); assertThat(booleanTypeConverter.convert("1")).isTrue(); assertThat(booleanTypeConverter.convert("on")).isTrue(); assertThat(booleanTypeConverter.convert("ON")).isTrue(); assertThat(booleanTypeConverter.convert("yes")).isTrue(); assertThat(booleanTypeConverter.convert("YES")).isTrue(); }
@Test public void whenInputIsNotOneOfPredefinedTrueValues_ThenShouldReturnBooleanFalseValue() { assertThat(booleanTypeConverter.convert("false")).isFalse(); assertThat(booleanTypeConverter.convert("0")).isFalse(); assertThat(booleanTypeConverter.convert("off")).isFalse(); assertThat(booleanTypeConverter.convert("no")).isFalse(); assertThat(booleanTypeConverter.convert("foo")).isFalse(); assertThat(booleanTypeConverter.convert("foobar")).isFalse(); }