Search in sources :

Example 81 with CurrencyConversion

use of javax.money.convert.CurrencyConversion in project jsr354-ri-bp by JavaMoney.

the class ECBHistoric90RateProviderTest method shouldReturnsSameEuroValue.

@Test
public void shouldReturnsSameEuroValue() {
    CurrencyConversion currencyConversion = provider.getCurrencyConversion(EURO);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, EURO);
    MonetaryAmount result = currencyConversion.apply(money);
    assertEquals(result.getCurrency(), EURO);
    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)

Example 82 with CurrencyConversion

use of javax.money.convert.CurrencyConversion in project jsr354-ri-bp 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)

Example 83 with CurrencyConversion

use of javax.money.convert.CurrencyConversion in project jsr354-ri-bp by JavaMoney.

the class ECBHistoric90RateProviderTest method shouldConvertsBrazilianToDollar.

@Test
public void shouldConvertsBrazilianToDollar() {
    CurrencyConversion currencyConversion = provider.getCurrencyConversion(DOLLAR);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, BRAZILIAN_REAL);
    MonetaryAmount result = currencyConversion.apply(money);
    assertEquals(result.getCurrency(), DOLLAR);
    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 84 with CurrencyConversion

use of javax.money.convert.CurrencyConversion in project jsr354-ri-bp by JavaMoney.

the class ECBHistoric90RateProviderTest method shouldConvertsDolarToEuro.

@Test
public void shouldConvertsDolarToEuro() {
    CurrencyConversion currencyConversion = provider.getCurrencyConversion(EURO);
    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 : MonetaryAmount(javax.money.MonetaryAmount) CurrencyConversion(javax.money.convert.CurrencyConversion) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 85 with CurrencyConversion

use of javax.money.convert.CurrencyConversion in project jsr354-ri-bp by JavaMoney.

the class ECBHistoricRateProviderTest method shouldSetTimeInLocalDateTime.

@Test
public void shouldSetTimeInLocalDateTime() {
    Calendar localDate = new GregorianCalendar(2014, Calendar.JANUARY, 9);
    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) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) CurrencyConversion(javax.money.convert.CurrencyConversion) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

CurrencyConversion (javax.money.convert.CurrencyConversion)91 MonetaryAmount (javax.money.MonetaryAmount)88 Test (org.testng.annotations.Test)88 BeforeTest (org.testng.annotations.BeforeTest)76 BigDecimal (java.math.BigDecimal)30 ConversionQuery (javax.money.convert.ConversionQuery)10 ExchangeRateProvider (javax.money.convert.ExchangeRateProvider)10 LocalDate (java.time.LocalDate)8 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2 Money (org.javamoney.moneta.Money)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1