use of javax.money.convert.CurrencyConversion in project jsr354-ri-bp by JavaMoney.
the class IdentityRateProviderTest 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);
}
use of javax.money.convert.CurrencyConversion in project jsr354-ri-bp by JavaMoney.
the class IdentityRateProviderTest 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);
}
use of javax.money.convert.CurrencyConversion in project jsr354-ri-bp by JavaMoney.
the class ExchangeRateMonetarySummaryStatistics method to.
@Override
public MonetarySummaryStatistics to(CurrencyUnit unit) {
CurrencyConversion currencyConversion = provider.getCurrencyConversion(unit);
ExchangeRateMonetarySummaryStatistics another = new ExchangeRateMonetarySummaryStatistics(unit, provider);
another.average = currencyConversion.apply(average);
another.count = count;
another.max = currencyConversion.apply(max);
another.min = currencyConversion.apply(min);
another.sum = currencyConversion.apply(sum);
return another;
}
use of javax.money.convert.CurrencyConversion in project jsr354-ri by JavaMoney.
the class ProviderTest method testAccess_HIST90.
@Test
public void testAccess_HIST90() throws InterruptedException {
final MonetaryAmount inEuro = Money.of(10, "EUR");
for (int i = 0; i < 100; i++) {
try {
final ExchangeRateProvider rateProvider = MonetaryConversions.getExchangeRateProvider("ECB-HIST90");
final CurrencyConversion dollarConversion = rateProvider.getCurrencyConversion("USD");
final MonetaryAmount inDollar = inEuro.with(dollarConversion);
System.out.println(String.format("RUN: %n - %s: %s ≙ %s", i, rateProvider, inEuro, inDollar));
} catch (Exception e) {
e.printStackTrace();
}
}
for (int i = 0; i < 100; i++) {
final ExchangeRateProvider rateProvider = MonetaryConversions.getExchangeRateProvider("ECB-HIST90");
final CurrencyConversion dollarConversion = rateProvider.getCurrencyConversion("USD");
Thread.sleep(100L);
final MonetaryAmount inDollar = inEuro.with(dollarConversion);
System.out.println(String.format("RUN: %n - %s: %s ≙ %s", i, rateProvider, inEuro, inDollar));
}
}
use of javax.money.convert.CurrencyConversion in project jsr354-ri by JavaMoney.
the class IMFRateProviderTest 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