HolidayDateRemovalFunction { public LocalDate[] getStrippedSchedule(final LocalDate[] dates, final Calendar holidays) { ArgumentChecker.notNull(dates, "date"); ArgumentChecker.notNull(holidays, "holidays"); final List<LocalDate> stripped = new ArrayList<>(); for (final LocalDate date : dates) { if (holidays.isWorkingDay(date)) { stripped.add(date); } } return stripped.toArray(EMPTY_ARRAY); } private  HolidayDateRemovalFunction(); static HolidayDateRemovalFunction getInstance(); LocalDate[] getStrippedSchedule(final LocalDate[] dates, final Calendar holidays);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullDates() { F.getStrippedSchedule(null, WEEKEND_CALENDAR); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullHolidays() { F.getStrippedSchedule(SCHEDULE, null); }
@Test public void test() { final LocalDate[] stripped = F.getStrippedSchedule(SCHEDULE, WEEKEND_CALENDAR); assertEquals(SCHEDULE.length, 366); assertEquals(stripped.length, 262); int i = 0, j = 0; for (final LocalDate date : SCHEDULE) { if (date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY) { i++; } else { assertEquals(SCHEDULE[i++], stripped[j++]); } } }