@Test /** Tests the equal and hashCode methods. */ public void equalHash() { assertTrue(BOND_FUTURE_SECURITY.equals(BOND_FUTURE_SECURITY)); final BondFuture other = new BondFuture( LAST_TRADING_TIME, FIRST_NOTICE_TIME, LAST_NOTICE_TIME, FIRST_DELIVERY_TIME, LAST_DELIVERY_TIME, NOTIONAL, BASKET, CONVERSION_FACTOR, REF_PRICE); assertTrue(BOND_FUTURE_SECURITY.equals(other)); assertTrue(BOND_FUTURE_SECURITY.hashCode() == other.hashCode()); BondFuture modifiedFuture; modifiedFuture = new BondFuture( LAST_TRADING_TIME + 0.1, FIRST_NOTICE_TIME, LAST_NOTICE_TIME, FIRST_DELIVERY_TIME, LAST_DELIVERY_TIME, NOTIONAL, BASKET, CONVERSION_FACTOR, REF_PRICE); assertFalse(BOND_FUTURE_SECURITY.equals(modifiedFuture)); modifiedFuture = new BondFuture( LAST_TRADING_TIME, FIRST_NOTICE_TIME + 0.1, LAST_NOTICE_TIME, FIRST_DELIVERY_TIME, LAST_DELIVERY_TIME, NOTIONAL, BASKET, CONVERSION_FACTOR, REF_PRICE); assertFalse(BOND_FUTURE_SECURITY.equals(modifiedFuture)); modifiedFuture = new BondFuture( LAST_TRADING_TIME, FIRST_NOTICE_TIME, LAST_NOTICE_TIME + 0.1, FIRST_DELIVERY_TIME, LAST_DELIVERY_TIME, NOTIONAL, BASKET, CONVERSION_FACTOR, REF_PRICE); assertFalse(BOND_FUTURE_SECURITY.equals(modifiedFuture)); modifiedFuture = new BondFuture( LAST_TRADING_TIME, FIRST_NOTICE_TIME, LAST_NOTICE_TIME, FIRST_DELIVERY_TIME + 0.1, LAST_DELIVERY_TIME, NOTIONAL, BASKET, CONVERSION_FACTOR, REF_PRICE); assertFalse(BOND_FUTURE_SECURITY.equals(modifiedFuture)); modifiedFuture = new BondFuture( LAST_TRADING_TIME, FIRST_NOTICE_TIME, LAST_NOTICE_TIME, FIRST_DELIVERY_TIME, LAST_DELIVERY_TIME + 0.1, NOTIONAL, BASKET, CONVERSION_FACTOR, REF_PRICE); assertFalse(BOND_FUTURE_SECURITY.equals(modifiedFuture)); modifiedFuture = new BondFuture( LAST_TRADING_TIME, FIRST_NOTICE_TIME, LAST_NOTICE_TIME, FIRST_DELIVERY_TIME, LAST_DELIVERY_TIME, NOTIONAL + 100000, BASKET, CONVERSION_FACTOR, REF_PRICE); assertFalse(BOND_FUTURE_SECURITY.equals(modifiedFuture)); final BondFixedSecurity[] otherBasket = new BondFixedSecurity[NB_BOND]; for (int loopbasket = 0; loopbasket < NB_BOND; loopbasket++) { otherBasket[loopbasket] = BASKET_DEFINITION[loopbasket].toDerivative(REFERENCE_DATE, LAST_NOTICE_DATE); } modifiedFuture = new BondFuture( LAST_TRADING_TIME, FIRST_NOTICE_TIME, LAST_NOTICE_TIME, FIRST_DELIVERY_TIME, LAST_DELIVERY_TIME, NOTIONAL, otherBasket, CONVERSION_FACTOR, REF_PRICE); assertFalse(BOND_FUTURE_SECURITY.equals(modifiedFuture)); final double[] otherConversionFactor = new double[] {.9000, .8565, .8493, .8516, .8540, .8417, .8292}; modifiedFuture = new BondFuture( LAST_TRADING_TIME, FIRST_NOTICE_TIME, LAST_NOTICE_TIME, FIRST_DELIVERY_TIME, LAST_DELIVERY_TIME, NOTIONAL, BASKET, otherConversionFactor, REF_PRICE); assertFalse(BOND_FUTURE_SECURITY.equals(modifiedFuture)); assertFalse(BOND_FUTURE_SECURITY.equals(LAST_TRADING_DATE)); assertFalse(BOND_FUTURE_SECURITY.equals(null)); }