use of javax.money.MonetaryAmount in project tutorials by eugenp.
the class JavaMoneyUnitManualTest method givenAmount_whenRounded_thanEquals.
@Test
public void givenAmount_whenRounded_thanEquals() {
MonetaryAmount fstAmtEUR = Monetary.getDefaultAmountFactory().setCurrency("EUR").setNumber(1.30473908).create();
MonetaryAmount roundEUR = fstAmtEUR.with(Monetary.getDefaultRounding());
assertEquals("EUR 1.30473908", fstAmtEUR.toString());
assertEquals("EUR 1.3", roundEUR.toString());
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ECBHistoricRateProviderTest 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 ECBHistoricRateProviderTest 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 ECBHistoricRateProviderTest 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.MonetaryAmount 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);
}
Aggregations