use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class MonetaryAmountDecimalFormatTest method shouldParseMonetaryAmount.
@Test
public void shouldParseMonetaryAmount() throws IOException {
MonetaryAmount money = Money.of(EXAMPLE_VALUE, currencyUnit);
String parse = format.queryFrom(money);
assertEquals(format.parse(parse), money);
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class MonetaryAmountFormatSymbolsTest method shouldReturnMonetaryAmountFromPattern.
@Test
public void shouldReturnMonetaryAmountFromPattern() {
MonetaryAmountFormatSymbols monetaryFormat = MonetaryAmountFormatSymbols.of("##,####,####", new MonetaryAmountSymbols(), new MoneyProducer());
money = Money.of(number, currency);
String format = monetaryFormat.format(money);
MonetaryAmount amount = monetaryFormat.parse(format);
assertEquals(amount.getCurrency(), currency);
assertEquals(amount.getNumber().numberValue(Long.class), number);
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ConvertMinorPartQueryTest method shouldReturnMajorPartNegative.
@Test
public void shouldReturnMajorPartNegative() {
MonetaryAmount monetaryAmount = Money.parse("BHD -1.345");
Long result = query.queryFrom(monetaryAmount);
Long expected = -1345L;
assertEquals(result, expected);
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ConvertMinorPartQueryTest method shouldReturnMajorPartPositive.
@Test
public void shouldReturnMajorPartPositive() {
MonetaryAmount monetaryAmount = Money.parse("EUR 2.35");
Long result = query.queryFrom(monetaryAmount);
Long expected = 235L;
assertEquals(result, expected);
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class RoundedMoneyProducerTest method shouldCreateUsingRoundedMoneyImplementation.
@Test
public void shouldCreateUsingRoundedMoneyImplementation() {
Long value = 10L;
MonetaryAmount amount = producer.create(currency, value);
assertTrue(RoundedMoney.class.isInstance(amount));
}
Aggregations