Search in sources :

Example 71 with MonetaryAmount

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));
}
Also used : MonetaryAmount(javax.money.MonetaryAmount) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 72 with MonetaryAmount

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());
}
Also used : MonetaryAmount(javax.money.MonetaryAmount) Test(org.testng.annotations.Test)

Example 73 with MonetaryAmount

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());
}
Also used : MonetaryAmount(javax.money.MonetaryAmount) Test(org.testng.annotations.Test)

Example 74 with MonetaryAmount

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);
}
Also used : MonetaryAmount(javax.money.MonetaryAmount) Test(org.testng.annotations.Test)

Example 75 with MonetaryAmount

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);
}
Also used : MonetaryAmount(javax.money.MonetaryAmount) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Aggregations

MonetaryAmount (javax.money.MonetaryAmount)275 Test (org.testng.annotations.Test)260 CurrencyConversion (javax.money.convert.CurrencyConversion)88 BeforeTest (org.testng.annotations.BeforeTest)83 BigDecimal (java.math.BigDecimal)64 CurrencyUnit (javax.money.CurrencyUnit)57 ConversionQuery (javax.money.convert.ConversionQuery)10 RoundedMoney (org.javamoney.moneta.RoundedMoney)10 LocalDate (java.time.LocalDate)9 ExchangeRateProvider (javax.money.convert.ExchangeRateProvider)9 Test (org.junit.Test)9 FastMoney (org.javamoney.moneta.FastMoney)6 Money (org.javamoney.moneta.Money)6 MathContext (java.math.MathContext)4 MonetaryOperator (javax.money.MonetaryOperator)4 MonetaryAmountFormat (javax.money.format.MonetaryAmountFormat)4 MonetaryAmountFactory (javax.money.MonetaryAmountFactory)3 BookingBean (com.github.drbookings.model.data.BookingBean)2 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2