use of org.javamoney.moneta.spi.MoneyProducer 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 org.javamoney.moneta.spi.MoneyProducer in project jsr354-ri by JavaMoney.
the class DefaultMonetaryAmountFormatSymbolsTest method setup.
@BeforeMethod
public void setup() {
locale = new Locale("pt", "BR");
symbols = new MonetaryAmountSymbols(locale);
currency = Monetary.getCurrency(locale);
producer = new MoneyProducer();
monetaryAmountFormat = new DefaultMonetaryAmountFormatSymbols(symbols, producer);
}
use of org.javamoney.moneta.spi.MoneyProducer 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);
}
Aggregations