use of javax.money.NumberValue in project jsr354-ri by JavaMoney.
the class DefaultNumberValueTest method shouldReturnAmountFractionDenominator.
@Test
public void shouldReturnAmountFractionDenominator() {
NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.21));
assertEquals(100L, numberValue.getAmountFractionDenominator());
}
use of javax.money.NumberValue in project jsr354-ri by JavaMoney.
the class DefaultNumberValueTest method shouldReturnScale.
@Test
public void shouldReturnScale() {
NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.21));
assertEquals(numberValue.getScale(), 2);
}
use of javax.money.NumberValue in project jsr354-ri by JavaMoney.
the class DefaultNumberValueTest method shouldReturnLong.
@Test
public void shouldReturnLong() {
NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.21));
assertEquals(numberValue.longValue(), 132L);
}
use of javax.money.NumberValue in project jsr354-ri by JavaMoney.
the class DefaultNumberValueTest method shouldReturnAmountFractionDenominatorForNegativeScale.
@Test
public void shouldReturnAmountFractionDenominatorForNegativeScale() {
NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(10.00));
assertEquals(1, numberValue.getAmountFractionDenominator());
}
use of javax.money.NumberValue in project jsr354-ri by JavaMoney.
the class DefaultNumberValueTest method shouldReturnNumberValueExact.
@Test
public void shouldReturnNumberValueExact() {
NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(21));
assertEquals(Long.valueOf(21L), numberValue.numberValueExact(Long.class));
assertEquals(Integer.valueOf(21), numberValue.numberValueExact(Integer.class));
assertEquals(Float.valueOf(21), numberValue.numberValueExact(Float.class));
assertEquals(Byte.valueOf((byte) 21), numberValue.numberValueExact(Byte.class));
assertEquals(Short.valueOf((short) 21), numberValue.numberValueExact(Short.class));
assertEquals(new AtomicLong(21L).get(), numberValue.numberValueExact(AtomicLong.class).get());
assertEquals(new AtomicInteger(21).get(), numberValue.numberValueExact(AtomicInteger.class).get());
assertEquals(BigDecimal.valueOf(21L), numberValue.numberValueExact(BigDecimal.class));
assertEquals(BigInteger.valueOf(21L), numberValue.numberValueExact(BigInteger.class));
}
Aggregations