final double fixingPeriodEndTime1 = TimeCalculator.getTimeBetween(referenceDate, IBOR_AVERAGE_COUPON_DEFINITION_1.getFixingPeriodEndDate1());
final double fixingPeriodStartTime2 = TimeCalculator.getTimeBetween(referenceDate, IBOR_AVERAGE_COUPON_DEFINITION_1.getFixingPeriodStartDate2());
final double fixingPeriodEndTime2 = TimeCalculator.getTimeBetween(referenceDate, IBOR_AVERAGE_COUPON_DEFINITION_1.getFixingPeriodEndDate2());
// The fixing is known
final CouponFixed coupon = new CouponFixed(CUR, paymentTime, ACCRUAL_FACTOR, NOTIONAL, FIXING_RATE);
final Payment couponConverted = IBOR_AVERAGE_COUPON_DEFINITION_1.toDerivative(referenceDate, FIXING_TS);
assertEquals(coupon, couponConverted);
// The fixing is not known
final DoubleTimeSeries<ZonedDateTime> fixingTS2 = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(new ZonedDateTime[] {ScheduleCalculator.getAdjustedDate(FIXING_DATE, -1, CALENDAR) },
new double[] {FIXING_RATE });
final CouponIborAverage coupon2 = new CouponIborAverage(CUR, paymentTime, ACCRUAL_FACTOR, NOTIONAL, fixingTime, INDEX_1, fixingPeriodStartTime1, fixingPeriodEndTime1,
IBOR_AVERAGE_COUPON_DEFINITION_1.getFixingPeriodAccrualFactor1(), INDEX_2, fixingPeriodStartTime2, fixingPeriodEndTime2,
IBOR_AVERAGE_COUPON_DEFINITION_1.getFixingPeriodAccrualFactor2(), WEIGHT_1, WEIGHT_2);
final Payment couponConverted2 = IBOR_AVERAGE_COUPON_DEFINITION_1.toDerivative(referenceDate, fixingTS2);
assertEquals("CouponIborAverageDefinition: toDerivative", coupon2, couponConverted2);
final Payment couponConverted3 = IBOR_AVERAGE_COUPON_DEFINITION_1.toDerivative(referenceDate);
assertEquals("CouponIborAverageDefinition: toDerivative", coupon2, couponConverted3);
}