ISDACompliantScheduleGenerator { public static double[] getIntegrationNodesAsTimes(final LocalDate today, final LocalDate startDate, final LocalDate endDate, final LocalDate[] disCurveDates, final LocalDate[] spreadCurveDates) { ArgumentChecker.notNull(today, "null today"); ArgumentChecker.notNull(startDate, "null startDate"); ArgumentChecker.isFalse(today.isAfter(startDate), "today is after startDate"); final LocalDate[] dates = getIntegrationNodesAsDates(startDate, endDate, disCurveDates, spreadCurveDates); return getYearFractionFromToday(today, dates); }  static LocalDate[] getIntegrationNodesAsDates(final LocalDate startDate, final LocalDate endDate, final LocalDate[] disCurveDates, final LocalDate[] spreadCurveDates); static double[] getIntegrationNodesAsTimes(final LocalDate today, final LocalDate startDate, final LocalDate endDate, final LocalDate[] disCurveDates, final LocalDate[] spreadCurveDates); static LocalDate[] truncateList(final LocalDate startDate, final LocalDate endDate, final LocalDate[] dateList); static double[] getYearFractionFromToday(final LocalDate today, final LocalDate[] dates); static double[] getYearFractionFromToday(final LocalDate today, final LocalDate[] dates, final DayCount dayCount);  }
@Test void nodesAsTimesTest() { final LocalDate today = LocalDate.of(2013, 1, 23); final LocalDate[] expectedDates = new LocalDate[] {START_DATE, LocalDate.of(2013, 2, 23), LocalDate.of(2013, 3, 13), LocalDate.of(2013, 4, 12), LocalDate.of(2013, 4, 13), LocalDate.of(2014, 2, 17), LocalDate.of(2014, 7, 2), LocalDate.of(2015, 4, 30), END_DATE }; final int n = expectedDates.length; final double[] expected = new double[n]; for (int i = 0; i < n; ++i) { expected[i] = ACT.getDayCountFraction(today, expectedDates[i]); } final double[] res = ISDACompliantScheduleGenerator.getIntegrationNodesAsTimes(today, START_DATE, END_DATE, DISCOUNT_CURVE_DATES, SPREAD_CURVE_DATES); assertEquals(n, res.length); for (int i = 0; i < n; ++i) { assertEquals(expected[i], res[i]); } }
@Test(expectedExceptions = IllegalArgumentException.class) public void nodesAsTimesNullTodayTest() { final LocalDate today = null; ISDACompliantScheduleGenerator.getIntegrationNodesAsTimes(today, START_DATE, END_DATE, DISCOUNT_CURVE_DATES, SPREAD_CURVE_DATES); }
@Test(expectedExceptions = IllegalArgumentException.class) public void nodesAsTimesNullStartTest() { final LocalDate today = LocalDate.of(2013, 1, 23); final LocalDate start = null; ISDACompliantScheduleGenerator.getIntegrationNodesAsTimes(today, start, END_DATE, DISCOUNT_CURVE_DATES, SPREAD_CURVE_DATES); }
@Test(expectedExceptions = IllegalArgumentException.class) public void nodesAsTimeTodayAfterStartTest() { final LocalDate today = LocalDate.of(2013, 3, 23); ISDACompliantScheduleGenerator.getIntegrationNodesAsTimes(today, START_DATE, END_DATE, DISCOUNT_CURVE_DATES, SPREAD_CURVE_DATES); }