Search in sources :

Example 6 with NumberValue

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

the class DefaultNumberValueTest method shouldReturnFloat.

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

Example 7 with NumberValue

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

the class DefaultNumberValueTest method shouldReturnAmountFractionNumerator.

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

Example 8 with NumberValue

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

the class DefaultNumberValueTest method shouldReturnPrecision.

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

Example 9 with NumberValue

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

the class DefaultNumberValueTest method shouldReturnDouble.

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

Example 10 with NumberValue

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

the class DefaultNumberValueTest method shoudReturnAmountFractionNumerator.

@Test
public void shoudReturnAmountFractionNumerator() {
    NumberValue numberValue = DefaultNumberValue.of(BigDecimal.valueOf(62.5));
    assertEquals(5L, numberValue.getAmountFractionNumerator());
    assertEquals(10L, 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