use of org.javamoney.moneta.spi.DefaultNumberValue in project jsr354-ri-bp by JavaMoney.
the class ExchangeRateSimpleTest method equalsTest.
@Test
public void equalsTest() {
DefaultNumberValue factor = new DefaultNumberValue(1.1);
DefaultNumberValue bigDecimalFactor = new DefaultNumberValue(new BigDecimal("1.1"));
ExchangeRate rate1 = new ExchangeRateBuilder("myprovider", RateType.ANY).setBase(EUR).setTerm(GBP).setFactor(factor).build();
ExchangeRate rate2 = new ExchangeRateBuilder("myprovider", RateType.ANY).setBase(EUR).setTerm(GBP).setFactor(factor).build();
ExchangeRate rate3 = new ExchangeRateBuilder("myprovider", RateType.ANY).setBase(EUR).setTerm(GBP).setFactor(bigDecimalFactor).build();
assertEquals(rate1, rate2, "Rates with same factor");
assertEquals(rate1, rate3, "Rates with numerically equal factor");
assertEquals(rate1.hashCode(), rate2.hashCode(), "Hashes with same factor");
assertEquals(rate1.hashCode(), rate3.hashCode(), "Hashes with numerically equal factor");
}
Aggregations