use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ReciprocalOperatorTest method shouldReturnNegativeValue.
@Test
public void shouldReturnNegativeValue() {
CurrencyUnit currency = Monetary.getCurrency("EUR");
MonetaryAmount money = Money.parse("EUR -2.0");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), currency);
assertEquals(result.getNumber().doubleValue(), -0.5);
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ToStringMonetaryAmountFormatTest method shoudReturnToStringOnQueryFromWhenMonetaryWithFastMoney.
@Test
public void shoudReturnToStringOnQueryFromWhenMonetaryWithFastMoney() {
MonetaryAmount money = Money.of(10, BRAZILIAN_REAL);
String result = ToStringMonetaryAmountFormat.of(ToStringMonetaryAmountFormatStyle.FAST_MONEY).queryFrom(money);
Assert.assertEquals(result, "BRL 10");
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class ToStringMonetaryAmountFormatTest method shoudReturnToStringOnQueryFromWhenMonetaryWithRoundedMoney.
@Test
public void shoudReturnToStringOnQueryFromWhenMonetaryWithRoundedMoney() {
MonetaryAmount money = Money.of(10, BRAZILIAN_REAL);
String result = ToStringMonetaryAmountFormat.of(ToStringMonetaryAmountFormatStyle.ROUNDED_MONEY).queryFrom(money);
Assert.assertEquals(result, "BRL 10");
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class DefaultMonetaryAmountFormatSymbolsTest method shouldPrintMonetaryAmount.
@Test
public void shouldPrintMonetaryAmount() throws IOException {
StringBuilder sb = new StringBuilder();
MonetaryAmount money = Money.of(10, currency);
monetaryAmountFormat.print(sb, money);
String result = sb.toString();
assertTrue(result.contains("R$"));
assertTrue(result.contains("10,00"));
}
use of javax.money.MonetaryAmount in project jsr354-ri by JavaMoney.
the class MonetaryAmountDecimalFormatTest method shouldPrintMonetaryAmount.
@Test
public void shouldPrintMonetaryAmount() throws IOException {
StringBuilder sb = new StringBuilder();
MonetaryAmount money = Money.of(EXAMPLE_VALUE, currencyUnit);
format.print(sb, money);
assertEquals(sb.toString(), numberFormat.format(EXAMPLE_VALUE));
}
Aggregations