use of javax.money.MonetaryAmount in project jsr354-ri-bp by JavaMoney.
the class RoundedMoneyProducerTest method shouldCreateUsingRoundedMoneyImplementation.
@Test
public void shouldCreateUsingRoundedMoneyImplementation() {
Long value = 10L;
MonetaryAmount amount = producer.create(currency, value);
assertTrue(RoundedMoney.class.isInstance(amount));
}
use of javax.money.MonetaryAmount in project jsr354-ri-bp by JavaMoney.
the class RoundedMoneyProducerTest method shouldCreateMonetaryAmount.
@Test
public void shouldCreateMonetaryAmount() {
Long value = 10L;
MonetaryAmount amount = producer.create(currency, value);
assertEquals(amount.getCurrency(), currency);
assertEquals(Long.valueOf(amount.getNumber().longValue()), value);
}
use of javax.money.MonetaryAmount in project jsr354-ri-bp by JavaMoney.
the class ScaleRoundedOperatorTest method shouldRoundedMonetaryOperatorWhenTheImplementationIsMoney.
@Test
public void shouldRoundedMonetaryOperatorWhenTheImplementationIsMoney() {
int scale = 4;
CurrencyUnit real = Monetary.getCurrency("BRL");
MonetaryAmount money = Money.of(BigDecimal.valueOf(35.34567), real);
ScaleRoundedOperator monetaryOperator = ScaleRoundedOperator.of(scale, RoundingMode.HALF_EVEN);
MonetaryAmount result = monetaryOperator.apply(money);
assertTrue(RoundedMoney.class.isInstance(result));
assertEquals(result.getCurrency(), real);
assertEquals(result.getNumber().getScale(), scale);
assertEquals(BigDecimal.valueOf(35.3457), result.getNumber().numberValue(BigDecimal.class));
}
use of javax.money.MonetaryAmount in project jsr354-ri-bp by JavaMoney.
the class RoundedMoneyTest method shouldRerturnZeroWhenUsingZero.
@Test
public void shouldRerturnZeroWhenUsingZero() {
MonetaryAmount zero = RoundedMoney.zero(DOLLAR);
assertEquals(BigDecimal.ZERO, zero.getNumber().numberValue(BigDecimal.class));
assertEquals(DOLLAR, zero.getCurrency());
}
use of javax.money.MonetaryAmount in project jsr354-ri-bp by JavaMoney.
the class RoundedMoneyTest method shouldRerturnMonetaryAmount.
@Test
public void shouldRerturnMonetaryAmount() {
MonetaryAmount amount = RoundedMoney.ofMinor(DOLLAR, 1234L);
assertEquals(12.34, amount.getNumber().doubleValue());
assertEquals(DOLLAR, amount.getCurrency());
}
Aggregations