Search in sources :

Example 21 with MonetaryAmount

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

the class ExchangeCurrencyOperatorTest method shouldReturnPositiveValue.

@Test
public void shouldReturnPositiveValue() {
    MonetaryAmount money = Money.parse("EUR 2.35");
    MonetaryAmount result = operator.apply(money);
    assertEquals(result.getCurrency(), this.real);
    assertEquals(result.getNumber().doubleValue(), 2.35);
}
Also used : MonetaryAmount(javax.money.MonetaryAmount) Test(org.testng.annotations.Test)

Example 22 with MonetaryAmount

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

the class ExchangeCurrencyOperatorTest method shouldReturnNegativeValue.

@Test
public void shouldReturnNegativeValue() {
    MonetaryAmount money = Money.parse("BHD -1.345");
    MonetaryAmount result = operator.apply(money);
    assertEquals(result.getCurrency(), real);
    assertEquals(result.getNumber().doubleValue(), -1.345);
}
Also used : MonetaryAmount(javax.money.MonetaryAmount) Test(org.testng.annotations.Test)

Example 23 with MonetaryAmount

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

the class ECBHistoric90RateProviderTest method shouldSetTimeInLocalDateTime2.

@Test
public void shouldSetTimeInLocalDateTime2() {
    LocalDate localDate = LocalDate.now().minusDays(90).with(TemporalAdjusters.next(DayOfWeek.FRIDAY));
    ConversionQuery conversionQuery = ConversionQueryBuilder.of().setTermCurrency(EURO).set(localDate).build();
    CurrencyConversion currencyConversion = provider.getCurrencyConversion(conversionQuery);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
    MonetaryAmount result = currencyConversion.apply(money);
    assertEquals(result.getCurrency(), EURO);
    assertTrue(result.getNumber().doubleValue() > 0);
}
Also used : ConversionQuery(javax.money.convert.ConversionQuery) MonetaryAmount(javax.money.MonetaryAmount) CurrencyConversion(javax.money.convert.CurrencyConversion) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 24 with MonetaryAmount

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

the class ECBHistoric90RateProviderTest method shouldConvertsDollarToBrazilian.

@Test
public void shouldConvertsDollarToBrazilian() {
    CurrencyConversion currencyConversion = provider.getCurrencyConversion(BRAZILIAN_REAL);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
    MonetaryAmount result = currencyConversion.apply(money);
    assertEquals(result.getCurrency(), BRAZILIAN_REAL);
    assertTrue(result.getNumber().doubleValue() > 0);
}
Also used : MonetaryAmount(javax.money.MonetaryAmount) CurrencyConversion(javax.money.convert.CurrencyConversion) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 25 with MonetaryAmount

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

the class ECBHistoric90RateProviderTest method shouldReturnsSameBrazilianValue.

@Test
public void shouldReturnsSameBrazilianValue() {
    CurrencyConversion currencyConversion = provider.getCurrencyConversion(BRAZILIAN_REAL);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, BRAZILIAN_REAL);
    MonetaryAmount result = currencyConversion.apply(money);
    assertEquals(result.getCurrency(), BRAZILIAN_REAL);
    assertEquals(result.getNumber().numberValue(BigDecimal.class), BigDecimal.TEN);
}
Also used : MonetaryAmount(javax.money.MonetaryAmount) CurrencyConversion(javax.money.convert.CurrencyConversion) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

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