use of javax.money.convert.CurrencyConversion in project jsr354-ri by JavaMoney.
the class IMFHistoricRateProviderTest method shouldSetTimeInLocalDateTime.
@Test
public void shouldSetTimeInLocalDateTime() {
LocalDate localDate = YearMonth.of(2014, Month.JANUARY).atDay(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);
}
use of javax.money.convert.CurrencyConversion in project jsr354-ri by JavaMoney.
the class IMFHistoricRateProviderTest 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);
}
use of javax.money.convert.CurrencyConversion in project jsr354-ri by JavaMoney.
the class IMFHistoricRateProviderTest 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);
}
use of javax.money.convert.CurrencyConversion in project jsr354-ri by JavaMoney.
the class IMFHistoricRateProviderTest method shouldConvertsEuroToDollar.
@Test
public void shouldConvertsEuroToDollar() {
CurrencyConversion currencyConversion = provider.getCurrencyConversion(DOLLAR);
assertNotNull(currencyConversion);
MonetaryAmount money = Money.of(BigDecimal.TEN, EURO);
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 IMFHistoricRateProviderTest 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);
}
Aggregations