/** * Check if a correct double value is returned, truncation is * allowed to be performed. Check should be done for every JDK type * supported. */ @SpecAssertion(section = "4.2.3", id = "423-B9") @Test(description = "4.2.3 Checks if a correct double value is returned, truncation is" + " allowed to be performed. Check should be done for every JDK type.") public void testNumberValueWithTruncationNegative_Short() { Number[] nums = new Number[]{-1213243544435L, -3234, -3.5f - 1.1, -1.2d, -21323234324324.23}; for (Number num : nums) { for (Class type : Monetary.getAmountTypes()) { if (type.equals(TestAmount.class)) { continue; } MonetaryAmount mAmount1 = Monetary.getAmountFactory(type).setCurrency(DEFAULT_CURRENCY).setNumber(num).create(); NumberValue result = mAmount1.getNumber(); AssertJUnit .assertEquals("Section 4.2.3: Number value (BigDecimal -> byte) returned is not correct for " + type.getName(), (long) new BigDecimal(String.valueOf(num)).shortValue(), (long) result.numberValue(Short.class)); AssertJUnit .assertEquals("Section 4.2.3: Number value (BigDecimal -> byte) returned is not correct for " + type.getName(), (long) new BigDecimal(String.valueOf(num)).shortValue(), (long) result.shortValue()); } } }
} else if (Short.class.equals(numType)) { AssertJUnit.assertEquals("Section 4.2.3: Truncating conversion to short failed for type " + type.getName(), dec.shortValue(), result.shortValue()); } else if (Integer.class.equals(numType)) { AssertJUnit.assertEquals("Section 4.2.3: Truncating conversion to int failed for type " + type.getName(),