### Question:
StringToBigDecimalConverterFactory implements TypeConverterFactory<String, BigDecimal> { @Override public TypeConverter<String, BigDecimal> createTypeConverter() { return new NumberTypeConverter<String, BigDecimal>() { @Override protected BigDecimal doConvert(String value) { if (numberFormat != null) { try { Number number = numberFormat.parse(value.trim()); if(number instanceof BigDecimal) { return (BigDecimal) number; } else if(number instanceof BigInteger) { return new BigDecimal((BigInteger) number); } return BigDecimal.valueOf(number.doubleValue()); } catch (ParseException e) { throw new TypeConverterException("Failed to decode BigDecimal value '" + value + "' using NumberFormat instance " + numberFormat + ".", e); } } else { try { return new BigDecimal(value.trim()); } catch (NumberFormatException e) { throw new TypeConverterException("Failed to decode BigDecimal value '" + value + "'.", e); } } } }; }  @Override TypeConverter<String, BigDecimal> createTypeConverter(); @Override TypeConverterDescriptor<Class<String>, Class<BigDecimal>> getTypeConverterDescriptor();  }### Answer:
@Test public void test_decode_no_config() { StringToBigDecimalConverterFactory bigDecimalConverterFactory = new StringToBigDecimalConverterFactory(); BigDecimal bigD = bigDecimalConverterFactory.createTypeConverter().convert("1234.45"); assertEquals(new BigDecimal("1234.45"), bigD); }
@Test public void test_decode_locale_config() { StringToBigDecimalConverterFactory stringToBigDecimalConverterFactory = new StringToBigDecimalConverterFactory(); Properties config = new Properties(); config.setProperty(NumberTypeConverter.LOCALE, "de-DE"); TypeConverter<String, BigDecimal> typeConverter = stringToBigDecimalConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); BigDecimal bigD = typeConverter.convert("1234,45"); assertEquals(new BigDecimal("1234.45").toBigInteger(), bigD.toBigInteger()); }
@Test public void test_decode_format_config() { StringToBigDecimalConverterFactory stringToBigDecimalConverterFactory = new StringToBigDecimalConverterFactory(); Properties config = new Properties(); config.setProperty(NumberTypeConverter.FORMAT, "#,###.##"); TypeConverter<String, BigDecimal> typeConverter = stringToBigDecimalConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); BigDecimal bigD = typeConverter.convert("1,234.45"); assertEquals(new BigDecimal("1234.45").toBigInteger(), bigD.toBigInteger()); }