BigDecimalConverter { public static SerializableFunction<BigDecimal, ? extends Number> forSqlType(TypeName typeName) { if (!CONVERTER_MAP.containsKey(typeName)) { throw new UnsupportedOperationException( "Conversion from " + typeName + " to BigDecimal is not supported"); } return CONVERTER_MAP.get(typeName); }  static SerializableFunction<BigDecimal, ? extends Number> forSqlType(TypeName typeName);  }
@Test public void testReturnsConverterForNumericTypes() { for (TypeName numericType : TypeName.NUMERIC_TYPES) { SerializableFunction<BigDecimal, ? extends Number> converter = BigDecimalConverter.forSqlType(numericType); assertNotNull(converter); assertNotNull(converter.apply(BigDecimal.TEN)); } }
@Test public void testThrowsForUnsupportedTypes() { thrown.expect(UnsupportedOperationException.class); BigDecimalConverter.forSqlType(TypeName.STRING); }