use of javax.money.MonetaryAmount in project jsr354-ri-bp by JavaMoney.
the class MonetaryOperatorsTest method shouldRouding.
@Test
public void shouldRouding() {
CurrencyUnit euro = Monetary.getCurrency("EUR");
MonetaryAmount money = Money.parse("EUR 2.355432");
MonetaryAmount result = MonetaryOperators.rounding().apply(money);
assertNotNull(result);
assertEquals(result.getCurrency(), euro);
assertEquals(2.36, result.getNumber().doubleValue());
}
use of javax.money.MonetaryAmount in project jsr354-ri-bp by JavaMoney.
the class MonetaryOperatorsTest method testMajorPart.
/**
* Test method for
* {@link org.javamoney.moneta.function.MonetaryOperators#majorPart()}.
*/
@Test
public void testMajorPart() {
MonetaryAmount m = Monetary.getDefaultAmountFactory().setCurrency("CHF").setNumber(new BigDecimal("1234.56789")).create();
MonetaryAmount r = m.with(MonetaryOperators.majorPart());
assertEquals(Monetary.getDefaultAmountFactory().setCurrency("CHF").setNumber(new BigDecimal("1234")).create(), r);
}
use of javax.money.MonetaryAmount in project jsr354-ri-bp by JavaMoney.
the class PercentOperatorTest method shouldReturnNegativeValue.
@Test
public void shouldReturnNegativeValue() {
CurrencyUnit currency = Monetary.getCurrency("BHD");
MonetaryAmount money = Money.parse("BHD -200.0");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), currency);
assertEquals(result.getNumber().doubleValue(), -20.0);
}
use of javax.money.MonetaryAmount in project jsr354-ri-bp by JavaMoney.
the class PercentOperatorTest method shouldReturnPositiveValue.
@Test
public void shouldReturnPositiveValue() {
CurrencyUnit currency = Monetary.getCurrency("EUR");
MonetaryAmount money = Money.parse("EUR 200.0");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), currency);
assertEquals(result.getNumber().doubleValue(), 20.0);
}
use of javax.money.MonetaryAmount in project jsr354-ri-bp by JavaMoney.
the class PermilOperatorTest method shouldReturnNegativeValue.
@Test
public void shouldReturnNegativeValue() {
CurrencyUnit currency = Monetary.getCurrency("EUR");
MonetaryAmount money = Money.parse("EUR -2.35");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), currency);
assertEquals(result.getNumber().doubleValue(), -0.0235);
}
Aggregations