DecimalToBigDecimal extends TypeConverterBase { @Override public void validate(Class<?> type, int size, int decimals) { if(size < 2) { throw new TypeConverterException("Field to small to hold a decimal number: " + size + " < 2"); } if(!BigDecimal.class.equals(type)) { throw new TypeConverterException("Only supports converting to and from BigDecimal"); } }  @Override void validate(Class<?> type, int size, int decimals); @Override Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding); @Override byte[] from(Object value, int length, int decimals, boolean addPadding);  }
@Test public void testValidateSuccess() throws Exception { typeConverter.validate(BigDecimal.class, 10, -1); }
@Test public void testValidateTyopeFail() throws Exception { expectedEx.expect(TypeConverterException.class); expectedEx.expectMessage("Only supports converting to and from BigDecimal"); typeConverter.validate(Integer.TYPE, 2, -1); }
@Test public void testValidateFail() throws Exception { expectedEx.expect(TypeConverterException.class); expectedEx.expectMessage("Field to small to hold a decimal number"); typeConverter.validate(BigDecimal.class, 1, -1); }