use of javax.money.MonetaryAmount in project jsr354-ri 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);
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ECBHistoric90RateProviderTest method shouldConvertsDollarToEuro.
@Test
public void shouldConvertsDollarToEuro() {
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);
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ProviderTest method testAccess_IMF_HIST.
@Test
public void testAccess_IMF_HIST() throws InterruptedException {
final MonetaryAmount inEuro = Money.of(10, "EUR");
for (int i = 0; i < 100; i++) {
try {
final ExchangeRateProvider rateProvider = MonetaryConversions.getExchangeRateProvider("IMF-HIST");
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("IMF-HIST");
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.MonetaryAmount in project jsr354-ri by JavaMoney.
the class IMFRateProviderTest 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.MonetaryAmount in project jsr354-ri by JavaMoney.
the class MonetaryConversionTest method testMonetaryConversionsECB.
@Test
public void testMonetaryConversionsECB() {
final MonetaryAmount amt = Money.of(2000, "EUR");
CurrencyConversion conv = MonetaryConversions.getConversion("CHF", "ECB");
MonetaryAmount converted = amt.with(conv);
assertNotNull(converted);
}
Aggregations