@Test(dataProvider = "matches") public void test_matches(RollConvention conv, LocalDate input, boolean expected) { assertEquals(conv.matches(input), expected); }
public void test_noAdjust() { LocalDate date = date(2014, AUGUST, 17); assertEquals(NONE.adjust(date), date); assertEquals(NONE.matches(date), true); }
public void test_ofDayOfWeek_matches() { assertEquals(RollConvention.ofDayOfWeek(TUESDAY).matches(date(2014, SEPTEMBER, 1)), false); assertEquals(RollConvention.ofDayOfWeek(TUESDAY).matches(date(2014, SEPTEMBER, 2)), true); assertEquals(RollConvention.ofDayOfWeek(TUESDAY).matches(date(2014, SEPTEMBER, 3)), false); }
if (rollConv.matches(start) == false) { throw new ScheduleException( schedule, "Date '{}' does not match roll convention '{}' when starting to roll forwards", start, rollConv);
public void test_ofDayOfMonth_matches_Day30() { assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2016, JANUARY, 29)), false); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2016, JANUARY, 30)), true); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2016, JANUARY, 31)), false); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2016, FEBRUARY, 28)), false); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2016, FEBRUARY, 29)), true); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2015, FEBRUARY, 27)), false); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2015, FEBRUARY, 28)), true); }
public void test_ofDayOfMonth_matches_Day29() { assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2016, JANUARY, 30)), false); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2016, JANUARY, 29)), true); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2016, JANUARY, 30)), false); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2016, FEBRUARY, 28)), false); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2016, FEBRUARY, 29)), true); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2015, FEBRUARY, 27)), false); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2015, FEBRUARY, 28)), true); }
@Test(dataProvider = "types") public void test_null(RollConvention type) { assertThrowsIllegalArg(() -> type.adjust(null)); assertThrowsIllegalArg(() -> type.matches(null)); assertThrowsIllegalArg(() -> type.next(date(2014, JULY, 1), null)); assertThrowsIllegalArg(() -> type.next(null, P3M)); assertThrowsIllegalArg(() -> type.previous(date(2014, JULY, 1), null)); assertThrowsIllegalArg(() -> type.previous(null, P3M)); }
private static List<LocalDate> generateBackwards( PeriodicSchedule schedule, LocalDate start, LocalDate end, Frequency frequency, RollConvention rollConv, StubConvention stubConv, LocalDate explicitStartDate) { // validate if (rollConv.matches(end) == false) { throw new ScheduleException( schedule, "Date '{}' does not match roll convention '{}' when starting to roll backwards", end, rollConv); } // generate BackwardsList dates = new BackwardsList(estimateNumberPeriods(start, end, frequency)); dates.addFirst(end); LocalDate temp = rollConv.previous(end, frequency); while (temp.isAfter(start)) { dates.addFirst(temp); temp = rollConv.previous(temp, frequency); } // convert to long stub, but only if we actually have a stub boolean stub = temp.equals(start) == false; if (stub && dates.size() > 1 && stubConv.isStubLong(start, dates.get(0))) { dates.removeFirst(); } dates.addFirst(explicitStartDate); return dates; }