/**
* Test Invalid Amounts (too big/small)
*/
public void testInvalidAmount() {
Converter converter = makeConverter();
Class<?> clazz = Byte.class;
Long min = new Long(Byte.MIN_VALUE);
Long max = new Long(Byte.MAX_VALUE);
Long minMinusOne = new Long(min.longValue() - 1);
Long maxPlusOne = new Long(max.longValue() + 1);
// Minimum
assertEquals("Minimum", new Byte(Byte.MIN_VALUE), converter.convert(clazz, min));
// Maximum
assertEquals("Maximum", new Byte(Byte.MAX_VALUE), converter.convert(clazz, max));
// Too Small
try {
assertEquals("Minimum - 1", null, converter.convert(clazz, minMinusOne));
fail("Less than minimum, expected ConversionException");
} catch (Exception e) {
// expected result
}
// Too Large
try {
assertEquals("Maximum + 1", null, converter.convert(clazz, maxPlusOne));
fail("More than maximum, expected ConversionException");
} catch (Exception e) {
// expected result
}
}