Search in sources :

Example 1 with MoneyProducer

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);
}
Also used : MonetaryAmount(javax.money.MonetaryAmount) MoneyProducer(org.javamoney.moneta.spi.MoneyProducer) Test(org.testng.annotations.Test)

Example 2 with MoneyProducer

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);
}
Also used : Locale(java.util.Locale) MoneyProducer(org.javamoney.moneta.spi.MoneyProducer) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with MoneyProducer

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);
}
Also used : CurrencyUnit(javax.money.CurrencyUnit) MonetaryAmount(javax.money.MonetaryAmount) MoneyProducer(org.javamoney.moneta.spi.MoneyProducer) Test(org.testng.annotations.Test)

Aggregations

MoneyProducer (org.javamoney.moneta.spi.MoneyProducer)3 MonetaryAmount (javax.money.MonetaryAmount)2 Test (org.testng.annotations.Test)2 Locale (java.util.Locale)1 CurrencyUnit (javax.money.CurrencyUnit)1 BeforeMethod (org.testng.annotations.BeforeMethod)1