YIELD_CURVE = new ISDADateCurve("ISDA", BASE_DATE, YC_DATES, YC_RATES, OFFSET);
}
@Test
public void accLegRegrTest() {
final CreditDefaultSwapDefinition cds1 = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
final CreditDefaultSwapDefinition cds2 = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinitionWithProtectionStart(false);
final ZonedDateTime[] hrDates = new ZonedDateTime[HR_DATES.length];
final double[] hrTimes = new double[HR_TIMES.length];
final int len = HR_DATES.length;
for (int j = 1; j < 15; j += 3) {
for (int i = 0; i < len; i++) {
hrDates[i] = HR_DATES[i].plusDays(j);
hrTimes[i] = DAY_COUNT.getDayCountFraction(BASE_DATE, hrDates[i]);
}
final HazardRateCurve hazardRateCurve = new HazardRateCurve(hrDates, hrTimes, HR_RATES, OFFSET);
ZonedDateTime[] res1 = CALCULATOR.constructCreditDefaultSwapAccruedLegIntegrationSchedule(VALUATION_DATE, cds1, YIELD_CURVE, hazardRateCurve, true);
final ZonedDateTime[] expected = new ZonedDateTime[hrDates.length - 1 + YC_DATES.length - 1 + 2];
for (int i = 0; i < YC_DATES.length - 1; i++) {
expected[i * 2 + 1] = YC_DATES[i];
}
for (int i = 0; i < hrDates.length - 1; i++) {
expected[i * 2 + 2] = hrDates[i];
}
expected[0] = cds1.getStartDate();
expected[expected.length - 1] = cds1.getMaturityDate().plusDays(1);
assertDateArrayEquals(expected, res1);
ZonedDateTime[] res2 = CALCULATOR.constructCreditDefaultSwapAccruedLegIntegrationSchedule(VALUATION_DATE, cds2, YIELD_CURVE, hazardRateCurve, false);
expected[expected.length - 1] = cds2.getMaturityDate().plusDays(0);
assertDateArrayEquals(expected, res2);
// DEPRECATED_CALCULATOR.constructCreditDefaultSwapAccruedLegIntegrationSchedule(VALUATION_DATE, cds2, YIELD_CURVE, hazardRateCurve, true);
// final int nRes = res1.length;
// for (int i = 0; i < nRes; ++i) {