use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class MonetaryAmountDecimalFormatBuilderTest method shouldCreateSettingCurrencyUnit.
@Test
public void shouldCreateSettingCurrencyUnit() {
CurrencyUnit currencyUnit = Monetary.getCurrency("BRL");
MonetaryAmountDecimalFormat format = (MonetaryAmountDecimalFormat) MonetaryAmountDecimalFormatBuilder.newInstance().withProducer(new FastMoneyProducer()).withCurrencyUnit(currencyUnit).build();
assertEquals(format.getCurrencyUnit(), currencyUnit);
assertEquals(format.getProducer().getClass(), FastMoneyProducer.class);
assertEquals(format.getDecimalFormat().getCurrency().getCurrencyCode(), format.getCurrencyUnit().getCurrencyCode());
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class MonetaryAmountSymbolsTest method shouldReturnCurrencyFromLocale.
@Test
public void shouldReturnCurrencyFromLocale() {
MonetaryAmountSymbols symbols = new MonetaryAmountSymbols(Locale.US);
CurrencyUnit currency = Monetary.getCurrency(Locale.US);
assertEquals(symbols.getCurrency(), currency);
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class MonetaryAmountSymbolsTest method shouldReturnDefaultCurrency.
@Test
public void shouldReturnDefaultCurrency() {
MonetaryAmountSymbols symbols = new MonetaryAmountSymbols();
CurrencyUnit currency = Monetary.getCurrency(Locale.getDefault(Locale.Category.FORMAT));
assertEquals(symbols.getCurrency(), currency);
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class RoudingMonetaryAmountOperatorTest method shouldReturnPositiveValue.
@Test
public void shouldReturnPositiveValue() {
CurrencyUnit currency = Monetary.getCurrency("EUR");
MonetaryAmount money = Money.parse("EUR 2.3523");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), currency);
assertEquals(result.getNumber().doubleValue(), 2.35);
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class RoudingMonetaryAmountOperatorTest method shouldReturnNegativeValue.
@Test
public void shouldReturnNegativeValue() {
CurrencyUnit currency = Monetary.getCurrency("BHD");
MonetaryAmount money = Money.parse("BHD -1.34534432");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), currency);
assertEquals(result.getNumber().doubleValue(), -1.345);
}
Aggregations