### Question:
SimpleConverter implements Converter { @Override public <T> T convert(Object source, Class<T> targetType) { if (source == null) { return null; } if (targetType == Boolean.class || targetType == Boolean.TYPE) { @SuppressWarnings("unchecked") T t = (T) Boolean.valueOf(source.toString()); return t; } @SuppressWarnings("unchecked") T t = (T) parse(source.toString(), targetType); return t; }  @Override T convert(Object source, Class<T> targetType);  }### Answer:
@Test public void convertsBooleanValue() { assertThat(converter.convert("true", Boolean.TYPE), is(true)); assertThat(converter.convert("false", Boolean.TYPE), is(false)); }
@Test public void convertsIntegerValues() { assertThat(converter.convert("9000", Integer.TYPE), is(9000)); }
@Test public void convertsStringValue() { assertThat(converter.convert("9000", String.class), is("9000")); }
@Test public void convertsEnumValues() { assertThat(converter.convert("CLOSE", Status.class), is(Status.CLOSE)); assertThat(converter.convert("OPEN", Status.class), is(Status.OPEN)); }
@Test public void convertsArrayOfPrimitives() { String[] locales = converter.convert("UK,US,IT", String[].class); assertThat(asList(locales), contains("UK", "US", "IT")); }
@Test public void failsForUndefinedEnumValue() { assertThrows(ConversionException.class, () -> converter.convert("UDEFINED", Status.class)); }
@Test public void failsForUndefinedObject() { assertThrows(ConversionException.class, () -> converter.convert("UDEFINED", ConfigurationValue.class)); }