use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class MonetaryFunctionsOrderTest method sortorderNumberTest.
@Test
public void sortorderNumberTest() {
MonetaryAmount money = currencies().sorted(sortNumber()).findFirst().get();
Assert.assertEquals(BigDecimal.ZERO, money.getNumber().numberValue(BigDecimal.class));
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class MonetaryFunctionsOrderTest method sortCurrencyUnitTest.
@Test
public void sortCurrencyUnitTest() {
MonetaryAmount money = currencies().sorted(sortCurrencyUnit()).findFirst().get();
Assert.assertEquals(BRAZILIAN_REAL, money.getCurrency());
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class MonetaryFunctionsOrderTest method sortCurrencyUnitDescTest.
@Test
public void sortCurrencyUnitDescTest() {
MonetaryAmount money = currencies().sorted(sortCurrencyUnitDesc()).findFirst().get();
Assert.assertEquals(DOLLAR, money.getCurrency());
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class MonetaryOperatorsTest method testReciprocal.
/**
* Test method for
* {@link org.javamoney.moneta.function.MonetaryOperators#reciprocal()}.
*/
@Test
public void testReciprocal() {
MonetaryAmount m = Monetary.getDefaultAmountFactory().setCurrency("CHF").setNumber(200).create();
MonetaryAmount r = m.with(MonetaryOperators.reciprocal());
// noinspection BigDecimalMethodWithoutRoundingCalled
assertEquals(Monetary.getDefaultAmountFactory().setCurrency("CHF").setNumber(BigDecimal.ONE.divide(BigDecimal.valueOf(200))).create(), r);
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class MonetaryOperatorsTest method testPermilNumberMathContext.
/**
* Test method for
* {@link org.javamoney.moneta.function.MonetaryOperators#permil(java.lang.Number, java.math.MathContext)}
* .
*/
@Test
public void testPermilNumberMathContext() {
MonetaryAmount m = Monetary.getDefaultAmountFactory().setCurrency("CHF").setNumber(100).create();
MonetaryAmount r = m.with(MonetaryOperators.permil(25, MathContext.DECIMAL64));
assertEquals(Monetary.getDefaultAmountFactory().setCurrency("CHF").setNumber(new BigDecimal("2.5")).create(), r);
}
Aggregations