@Test public void testHashCodeAndEquals() { VasicekDataBundle other = new VasicekDataBundle(SHORT_RATE, SIGMA, DATE, LONG_RATE, SPEED); assertEquals(other, DATA); assertEquals(other.hashCode(), DATA.hashCode()); other = new VasicekDataBundle( new YieldCurve(ConstantDoublesCurve.from(SHORT_RATE.getInterestRate(0.) + 1)), SIGMA, DATE, LONG_RATE, SPEED); assertFalse(other.equals(DATA)); other = new VasicekDataBundle( SHORT_RATE, new VolatilityCurve(ConstantDoublesCurve.from(SIGMA.getVolatility(0.) + 0.2)), DATE, LONG_RATE, SPEED); assertFalse(other.equals(DATA)); other = new VasicekDataBundle(SHORT_RATE, SIGMA, DATE.plusDays(10), LONG_RATE, SPEED); assertFalse(other.equals(DATA)); other = new VasicekDataBundle(SHORT_RATE, SIGMA, DATE, LONG_RATE + 1, SPEED); assertFalse(other.equals(DATA)); other = new VasicekDataBundle(SHORT_RATE, SIGMA, DATE, LONG_RATE, SPEED + 1); assertFalse(other.equals(DATA)); }
@Test public void testGetters() { final double t = Math.random(); assertEquals(DATA.getShortRateCurve(), SHORT_RATE); assertEquals(DATA.getShortRate(t), SHORT_RATE.getInterestRate(t), 0); assertEquals(DATA.getLongTermInterestRate(), LONG_RATE, 0); assertEquals(DATA.getReversionSpeed(), SPEED, 0); assertEquals(DATA.getShortRateVolatilityCurve(), SIGMA); assertEquals(DATA.getShortRateVolatility(t), SIGMA.getVolatility(t), 0); assertEquals(DATA.getDate(), DATE); }