### Question:
StringToDoubleConverterFactory implements TypeConverterFactory<String, Double> { @Override public TypeConverter<String, Double> createTypeConverter() { return new StringToDoubleTypeConverter(); }  @Override TypeConverter<String, Double> createTypeConverter(); @Override TypeConverterDescriptor<Class<String>, Class<Double>> getTypeConverterDescriptor();  }### Answer:
@Test public void test_decode_format_config_03() { StringToDoubleConverterFactory stringToDoubleConverterFactory = new StringToDoubleConverterFactory(); Properties config = new Properties(); config.setProperty(NumberTypeConverter.TYPE, NumberTypeConverter.NumberType.CURRENCY.toString()); config.setProperty(NumberTypeConverter.LOCALE, "en_US"); TypeConverter<String, Double> typeConverter = stringToDoubleConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); double doubleVal = typeConverter.convert("$29.99"); assertEquals(29.99d, doubleVal, 0d); }
@Test public void test_empty_ok_value() { assertEquals(new Double(1.0d), stringToDoubleConverterFactory.createTypeConverter().convert("1.0")); }
@Test public void test_empty_data_string() { try { stringToDoubleConverterFactory.createTypeConverter().convert(""); fail("Expected DataDecodeException"); } catch (TypeConverterException e) { assertEquals("Failed to decode Double value ''.", e.getMessage()); } }
@Test public void test_decode_locale_config() { StringToDoubleConverterFactory stringToDoubleConverterFactory = new StringToDoubleConverterFactory(); Properties config = new Properties(); config.setProperty(NumberTypeConverter.LOCALE, "de_DE"); TypeConverter<String, Double> typeConverter = stringToDoubleConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); Double doubleVal = typeConverter.convert("1234,45"); assertEquals(1234.45d, doubleVal.doubleValue(), 0d); }
@Test public void test_decode_format_config_01() { StringToDoubleConverterFactory stringToDoubleConverterFactory = new StringToDoubleConverterFactory(); Properties config = new Properties(); config.setProperty(NumberTypeConverter.FORMAT, "#,###.##"); TypeConverter<String, Double> typeConverter = stringToDoubleConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); Double doubleVal = typeConverter.convert("1,234.45"); assertEquals(1234.45d, doubleVal.doubleValue(), 0d); }
@Test public void test_decode_format_config_02() { StringToDoubleConverterFactory stringToDoubleConverterFactory = new StringToDoubleConverterFactory(); Properties config = new Properties(); config.setProperty(NumberTypeConverter.FORMAT, "#%"); TypeConverter<String, Double> typeConverter = stringToDoubleConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); double doubleVal = typeConverter.convert("30%"); assertEquals(0.3d, doubleVal, 0d); }