use of javax.money.convert.CurrencyConversion in project jsr354-ri by JavaMoney.
the class ECBHistoricRateProviderTest 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);
}
use of javax.money.convert.CurrencyConversion in project jsr354-ri by JavaMoney.
the class ECBHistoricRateProviderTest 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);
}
use of javax.money.convert.CurrencyConversion in project jsr354-ri by JavaMoney.
the class IMFHistoricRateProviderTest method shouldReturnErrorWhenDoesNotFindTheExchangeRate.
@Test(expectedExceptions = MonetaryException.class)
public void shouldReturnErrorWhenDoesNotFindTheExchangeRate() {
LocalDate localDate = YearMonth.of(2011, Month.JANUARY).atDay(9);
ConversionQuery conversionQuery = ConversionQueryBuilder.of().set(localDate).setTermCurrency(EURO).build();
CurrencyConversion currencyConversion = provider.getCurrencyConversion(conversionQuery);
assertNotNull(currencyConversion);
MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
currencyConversion.apply(money);
fail();
}
use of javax.money.convert.CurrencyConversion in project jsr354-ri by JavaMoney.
the class IMFHistoricRateProviderTest method shouldReturnErrorWhenFindFromHistoricalUsingPeriod.
@Test(expectedExceptions = MonetaryException.class)
public void shouldReturnErrorWhenFindFromHistoricalUsingPeriod() {
LocalDate localDate = YearMonth.of(2011, Month.JANUARY).atDay(9);
ConversionQuery conversionQuery = ConversionQueryBuilder.of().setTermCurrency(EURO).set(withDaysBetween(localDate.minusDays(1), localDate)).build();
CurrencyConversion currencyConversion = provider.getCurrencyConversion(conversionQuery);
assertNotNull(currencyConversion);
MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
currencyConversion.apply(money);
fail();
}
use of javax.money.convert.CurrencyConversion in project jsr354-ri by JavaMoney.
the class IMFHistoricRateProviderTest method shouldReturnsSameDollarValue.
@Test
public void shouldReturnsSameDollarValue() {
CurrencyConversion currencyConversion = provider.getCurrencyConversion(DOLLAR);
assertNotNull(currencyConversion);
MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
MonetaryAmount result = currencyConversion.apply(money);
assertEquals(result.getCurrency(), DOLLAR);
assertEquals(result.getNumber().numberValue(BigDecimal.class), BigDecimal.TEN);
}
Aggregations