@Test public void testToDerivativeAfterFixing() { final String fundingCurve = "Funding"; final String forwardCurve = "Forward"; final String[] curves = {fundingCurve, forwardCurve}; final Payment[] couponIborConverted = new Payment[PAYMENT_DATES.length]; ZonedDateTime date = REFERENCE_DATE.plusMonths(1); for (int loopcpn = 0; loopcpn < PAYMENT_DATES.length; loopcpn++) { couponIborConverted[loopcpn] = IBOR_ANNUITY.getNthPayment(loopcpn).toDerivative(date, FIXING_TS, curves); } GenericAnnuity<Payment> referenceAnnuity = new GenericAnnuity<Payment>(couponIborConverted); GenericAnnuity<? extends Payment> convertedDefinition = IBOR_ANNUITY.toDerivative(date, FIXING_TS, curves); assertEquals(referenceAnnuity, convertedDefinition); assertTrue(convertedDefinition.getNthPayment(0) instanceof CouponFixed); assertEquals( ((CouponFixed) convertedDefinition.getNthPayment(0)).getFixedRate(), FIXING_RATE, 0); for (int i = 1; i < PAYMENT_DATES.length; i++) { assertTrue(convertedDefinition.getNthPayment(i) instanceof CouponIbor); } date = REFERENCE_DATE; for (int loopcpn = 0; loopcpn < PAYMENT_DATES.length; loopcpn++) { couponIborConverted[loopcpn] = IBOR_ANNUITY.getNthPayment(loopcpn).toDerivative(date, FIXING_TS, curves); } referenceAnnuity = new GenericAnnuity<Payment>(couponIborConverted); convertedDefinition = IBOR_ANNUITY.toDerivative(date, FIXING_TS, curves); assertEquals(referenceAnnuity, convertedDefinition); assertTrue(convertedDefinition.getNthPayment(0) instanceof CouponFixed); assertEquals( ((CouponFixed) convertedDefinition.getNthPayment(0)).getFixedRate(), FIXING_RATE, 0); for (int i = 1; i < PAYMENT_DATES.length; i++) { assertTrue(convertedDefinition.getNthPayment(i) instanceof CouponIbor); } }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullConversionDate() { IBOR_ANNUITY.toDerivative(null, FIXING_TS, new String[] {"L", "K"}); }