### Question:
StringToFloatConverterFactory implements TypeConverterFactory<String, Float> { @Override public TypeConverter<String, Float> createTypeConverter() { return new NumberTypeConverter<String, Float>() { @Override protected Float doConvert(String value) { if (numberFormat != null) { try { final Number number = numberFormat.parse(value.trim()); return number.floatValue(); } catch (ParseException e) { throw new TypeConverterException("Failed to decode Float value '" + value + "' using NumberFormat instance " + numberFormat + ".", e); } } else { try { return Float.parseFloat(value.trim()); } catch (NumberFormatException e) { throw new TypeConverterException("Failed to decode float value '" + value + "'.", e); } } } }; }  @Override TypeConverter<String, Float> createTypeConverter(); @Override TypeConverterDescriptor<Class<String>, Class<Float>> getTypeConverterDescriptor();  }### Answer:
@Test public void test_empty_ok_value() { StringToFloatConverterFactory stringToFloatConverterFactory = new StringToFloatConverterFactory(); assertEquals(new Float(1.0d), stringToFloatConverterFactory.createTypeConverter().convert("1.0")); }
@Test public void test_empty_data_string() { StringToFloatConverterFactory stringToFloatConverterFactory = new StringToFloatConverterFactory(); try { stringToFloatConverterFactory.createTypeConverter().convert(""); fail("Expected DataDecodeException"); } catch (TypeConverterException e) { assertEquals("Failed to decode float value ''.", e.getMessage()); } }
@Test public void test_decode_locale_config() { StringToFloatConverterFactory stringToFloatConverterFactory = new StringToFloatConverterFactory(); Properties config = new Properties(); config.setProperty(NumberTypeConverter.LOCALE, "de-DE"); TypeConverter<String, Float> typeConverter = stringToFloatConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); Float floatVal = typeConverter.convert("1234,45"); assertEquals(1234.45f, floatVal, 0f); }
@Test public void test_decode_format_config() { StringToFloatConverterFactory stringToFloatConverterFactory = new StringToFloatConverterFactory(); Properties config = new Properties(); config.setProperty(NumberTypeConverter.FORMAT, "#,###.##"); TypeConverter<String, Float> typeConverter = stringToFloatConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); Float floatVal = typeConverter.convert("1,234.45"); assertEquals(1234.45f, floatVal, 0f); }