use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class MonetaryAmountFormatSymbolsTest method shouldReturnMonetaryAmountDecimalSymbols.
@Test
public void shouldReturnMonetaryAmountDecimalSymbols() {
CurrencyUnit dollar = Monetary.getCurrency(Locale.US);
MonetaryAmountSymbols symbols = new MonetaryAmountSymbols();
symbols.setCurrency(dollar);
MonetaryAmountFormatSymbols monetaryFormat = MonetaryAmountFormatSymbols.of(symbols, new MoneyProducer());
money = Money.of(number, dollar);
String format = monetaryFormat.format(money);
MonetaryAmount amount = monetaryFormat.parse(format);
assertEquals(amount.getCurrency(), dollar);
assertEquals(amount.getNumber().numberValue(Long.class), number);
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class ConvertMinorPartQueryTest method shouldReturnWhenTheValueIsBiggerThanLong.
@Test(expectedExceptions = ArithmeticException.class)
public void shouldReturnWhenTheValueIsBiggerThanLong() {
CurrencyUnit real = Monetary.getCurrency("BRL");
MonetaryAmount monetaryAmount = Money.of(Long.MAX_VALUE, real);
query.queryFrom(monetaryAmount.add(Money.of(10, real)));
fail();
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class ExtractorMajorPartQueryTest method shouldReturnWhenTheValueIsBiggerThanLong.
@Test(expectedExceptions = ArithmeticException.class)
public void shouldReturnWhenTheValueIsBiggerThanLong() {
CurrencyUnit real = Monetary.getCurrency("BRL");
MonetaryAmount monetaryAmount = Money.of(Long.MAX_VALUE, real);
query.queryFrom(monetaryAmount.add(Money.of(10, real)));
fail();
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class ExtractorMajorPartOperatorTest method shouldReturnPositiveValue.
@Test
public void shouldReturnPositiveValue() {
CurrencyUnit currency = Monetary.getCurrency("EUR");
MonetaryAmount money = Money.parse("EUR 2.35");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), currency);
assertEquals(result.getNumber().doubleValue(), 2.0);
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class ExtractorMajorPartOperatorTest method shouldReturnNegativeValue.
@Test
public void shouldReturnNegativeValue() {
CurrencyUnit currency = Monetary.getCurrency("BHD");
MonetaryAmount money = Money.parse("BHD -1.345");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), currency);
assertEquals(result.getNumber().doubleValue(), -1.0);
}
Aggregations