Search in sources :

Example 11 with NumberValue

use of javax.money.NumberValue in project jsr354-ri-bp by JavaMoney.

the class DefaultNumberValueTest method shouldReturnErrorWhenIntValueExactMustBeTruncated.

@Test(expectedExceptions = ArithmeticException.class)
public void shouldReturnErrorWhenIntValueExactMustBeTruncated() {
    NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.12));
    numberValue.intValueExact();
}
Also used : NumberValue(javax.money.NumberValue) Test(org.testng.annotations.Test)

Example 12 with NumberValue

use of javax.money.NumberValue in project jsr354-ri-bp by JavaMoney.

the class DefaultNumberValueTest method shouldReturnIntValueExact.

@Test
public void shouldReturnIntValueExact() {
    NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132));
    assertEquals(numberValue.intValueExact(), 132);
}
Also used : NumberValue(javax.money.NumberValue) Test(org.testng.annotations.Test)

Example 13 with NumberValue

use of javax.money.NumberValue in project jsr354-ri-bp by JavaMoney.

the class DefaultNumberValueTest method shouldReturnLongValueExact.

@Test
public void shouldReturnLongValueExact() {
    NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132));
    assertEquals(numberValue.longValueExact(), 132L);
}
Also used : NumberValue(javax.money.NumberValue) Test(org.testng.annotations.Test)

Example 14 with NumberValue

use of javax.money.NumberValue in project jsr354-ri-bp by JavaMoney.

the class DefaultNumberValueTest method shouldReturnErrorWhenLongValueExactMustBeTruncated.

@Test(expectedExceptions = ArithmeticException.class)
public void shouldReturnErrorWhenLongValueExactMustBeTruncated() {
    NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.12));
    numberValue.longValueExact();
}
Also used : NumberValue(javax.money.NumberValue) Test(org.testng.annotations.Test)

Example 15 with NumberValue

use of javax.money.NumberValue in project jsr354-ri-bp by JavaMoney.

the class DefaultNumberValueTest method shouldReturnAmountFractionDenominator.

@Test
public void shouldReturnAmountFractionDenominator() {
    NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(132.21));
    assertEquals(100L, numberValue.getAmountFractionDenominator());
}
Also used : NumberValue(javax.money.NumberValue) Test(org.testng.annotations.Test)

Aggregations

NumberValue (javax.money.NumberValue)40 Test (org.testng.annotations.Test)36 BigDecimal (java.math.BigDecimal)6 BigInteger (java.math.BigInteger)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 CurrencyConversionException (javax.money.convert.CurrencyConversionException)2 ExchangeRate (javax.money.convert.ExchangeRate)2