Search in sources :

Example 6 with DefaultNumberValue

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");
}
Also used : DefaultNumberValue(org.javamoney.moneta.spi.DefaultNumberValue) ExchangeRateBuilder(org.javamoney.moneta.convert.ExchangeRateBuilder) ExchangeRate(javax.money.convert.ExchangeRate) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Aggregations

ExchangeRate (javax.money.convert.ExchangeRate)6 DefaultNumberValue (org.javamoney.moneta.spi.DefaultNumberValue)6 BigDecimal (java.math.BigDecimal)4 ExchangeRateBuilder (org.javamoney.moneta.convert.ExchangeRateBuilder)4 Test (org.testng.annotations.Test)4 CurrencyUnit (javax.money.CurrencyUnit)3 RateType (javax.money.convert.RateType)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 DecimalFormat (java.text.DecimalFormat)1 NumberFormat (java.text.NumberFormat)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1