use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ExchangeCurrencyOperatorTest method shouldReturnPositiveValue.
@Test
public void shouldReturnPositiveValue() {
MonetaryAmount money = Money.parse("EUR 2.35");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), this.real);
assertEquals(result.getNumber().doubleValue(), 2.35);
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ExchangeCurrencyOperatorTest method shouldReturnNegativeValue.
@Test
public void shouldReturnNegativeValue() {
MonetaryAmount money = Money.parse("BHD -1.345");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), real);
assertEquals(result.getNumber().doubleValue(), -1.345);
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ECBHistoric90RateProviderTest 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.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ECBHistoric90RateProviderTest 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 ECBHistoric90RateProviderTest 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);
}
Aggregations