### Question:
StringToShortConverterFactory implements TypeConverterFactory<String, Short> { @Override public TypeConverter<String, Short> createTypeConverter() { return new NumberTypeConverter<String, Short>() { @Override protected Short doConvert(String value) { if(numberFormat != null) { try { final Number number = numberFormat.parse(value.trim()); if(isPercentage()) { return (short) (number.doubleValue() * 100); } else { return number.shortValue(); } } catch (ParseException e) { throw new TypeConverterException("Failed to decode Short value '" + value + "' using NumberFormat instance " + numberFormat + ".", e); } } else { try { return Short.parseShort(value.trim()); } catch(NumberFormatException e) { throw new TypeConverterException("Failed to decode Short value '" + value + "'.", e); } } } }; }  @Override TypeConverter<String, Short> createTypeConverter(); @Override TypeConverterDescriptor<Class<String>, Class<Short>> getTypeConverterDescriptor();  }### Answer:
@Test public void test_empty_ok_value() { assertEquals(new Short((short)1), stringToShortConverterFactory.createTypeConverter().convert("1")); }
@Test public void test_empty_data_string() { try { stringToShortConverterFactory.createTypeConverter().convert(""); fail("Expected DataDecodeException"); } catch (TypeConverterException e) { assertEquals("Failed to decode Short value ''.", e.getMessage()); } }
@Test public void test_decode_locale_config() { StringToShortConverterFactory stringToShortConverterFactory = new StringToShortConverterFactory(); Properties config = new Properties(); config.setProperty(NumberTypeConverter.LOCALE, "de-DE"); TypeConverter<String, Short> typeConverter = stringToShortConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); Short shortVal = typeConverter.convert("1234,45"); assertEquals(new Short((short)1234), shortVal); }
@Test public void test_decode_format_config() { StringToShortConverterFactory stringToShortConverterFactory = new StringToShortConverterFactory(); Properties config = new Properties(); config.setProperty(NumberTypeConverter.FORMAT, "#,###.##"); TypeConverter<String, Short> typeConverter = stringToShortConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); Short shortVal = typeConverter.convert("1,234.45"); assertEquals(new Short((short)1234), shortVal); }