use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class RoudingMonetaryAmountOperatorTest method shouldReturnNegativeValueUsingRoudingType.
@Test
public void shouldReturnNegativeValueUsingRoudingType() {
operator = new RoudingMonetaryAmountOperator(RoundingMode.HALF_EVEN);
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);
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class RoudingMonetaryAmountOperatorTest method shouldReturnNegativeValueUsingRoudingTypeAndScale.
@Test
public void shouldReturnNegativeValueUsingRoudingTypeAndScale() {
operator = new RoudingMonetaryAmountOperator(RoundingMode.HALF_EVEN, 4);
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.3453);
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class MonetaryOperatorsTest method shouldRouding.
@Test
public void shouldRouding() {
CurrencyUnit euro = Monetary.getCurrency("EUR");
MonetaryAmount money = Money.parse("EUR 2.355432");
MonetaryAmount result = MonetaryOperators.rounding().apply(money);
assertNotNull(result);
assertEquals(result.getCurrency(), euro);
assertEquals(Double.valueOf(2.36), result.getNumber().doubleValue());
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class PercentOperatorTest method shouldReturnPositiveValue.
@Test
public void shouldReturnPositiveValue() {
CurrencyUnit currency = Monetary.getCurrency("EUR");
MonetaryAmount money = Money.parse("EUR 200.0");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), currency);
assertEquals(result.getNumber().doubleValue(), 20.0);
}
use of javax.money.CurrencyUnit in project jsr354-ri by JavaMoney.
the class PermilOperatorTest method shouldReturnPositiveValue.
@Test
public void shouldReturnPositiveValue() {
CurrencyUnit currency = Monetary.getCurrency("EUR");
MonetaryAmount money = Money.parse("EUR 2.35");
MonetaryAmount result = operator.apply(money);
assertEquals(result.getCurrency(), currency);
assertEquals(result.getNumber().doubleValue(), 0.0235);
}
Aggregations