### Question:
DoubleConverter implements Converter<Double> { @Override public Double convert(String toBeConverted) throws ConversionException { if (toBeConverted == null || toBeConverted.isEmpty()) { return null; } try { return Double.parseDouble(toBeConverted); } catch (NumberFormatException e) { throw new ConversionException(toBeConverted + " cannot be converted to Double", e); } }  @Override Double convert(String toBeConverted);  }### Answer:
@Test public void nullIsConvertedToNull() throws Exception { Double converted = converter.convert(null); assertNull(converted); }
@Test public void emptyIsConvertedToNull() throws Exception { Double converted = converter.convert(""); assertNull(converted); }
@Test public void doubleNumberIsParsedToDouble() throws Exception { double converted = converter.convert("1.23"); assertEquals(1.23d, converted, 0d); }
@Test(expected = ConversionException.class) public void nonParsableStringThrowAConversionException() throws Exception { converter.convert("nonParsable"); }