StringToBooleanConverter extends AbstractGenericConverter<String, Boolean> { @Override public Boolean convert(String source) { String normalize = source.trim().toLowerCase(); if (TRUE_STRING.contains(normalize)) { return true; } else if (FALSE_STRING.contains(normalize)) { return false; } else { throw new ConverterException(source, getTargetTypeToken().getRawType()); } }  @Override Boolean convert(String source);  }
@Test public void testConvert() { assertTrue(converter.convert("yes")); assertTrue(converter.convert("t")); assertTrue(converter.convert("true")); assertFalse(converter.convert("false")); assertFalse(converter.convert("f")); assertFalse(converter.convert("no")); }
@Test(expected = ConverterException.class) public void testRaiseException() { converter.convert("abc"); }