CalendarWindows { public static YearsWindows years(int number) { return new YearsWindows(number, 1, 1, DEFAULT_START_DATE, DateTimeZone.UTC); }  static DaysWindows days(int number); static DaysWindows weeks(int number, int startDayOfWeek); static MonthsWindows months(int number); static YearsWindows years(int number);  }
@Test public void testYears() throws Exception { Map<IntervalWindow, Set<String>> expected = new HashMap<>(); final List<Long> timestamps = Arrays.asList( makeTimestamp(2000, 5, 5, 0, 0).getMillis(), makeTimestamp(2010, 5, 4, 23, 59).getMillis(), makeTimestamp(2010, 5, 5, 0, 0).getMillis(), makeTimestamp(2015, 3, 1, 0, 0).getMillis(), makeTimestamp(2052, 1, 5, 0, 0).getMillis(), makeTimestamp(2060, 5, 4, 5, 5).getMillis()); expected.put( new IntervalWindow(makeTimestamp(2000, 5, 5, 0, 0), makeTimestamp(2010, 5, 5, 0, 0)), set(timestamps.get(0), timestamps.get(1))); expected.put( new IntervalWindow(makeTimestamp(2010, 5, 5, 0, 0), makeTimestamp(2020, 5, 5, 0, 0)), set(timestamps.get(2), timestamps.get(3))); expected.put( new IntervalWindow(makeTimestamp(2050, 5, 5, 0, 0), makeTimestamp(2060, 5, 5, 0, 0)), set(timestamps.get(4), timestamps.get(5))); assertEquals( expected, runWindowFn( CalendarWindows.years(10).withStartingYear(2000).beginningOnDay(5, 5), timestamps)); }
@Test public void testYearsCompatibility() throws IncompatibleWindowException { CalendarWindows.YearsWindows yearsWindows = CalendarWindows.years(2017).beginningOnDay(1, 1); yearsWindows.verifyCompatibility(CalendarWindows.years(2017).beginningOnDay(1, 1)); thrown.expect(IncompatibleWindowException.class); yearsWindows.verifyCompatibility(CalendarWindows.years(2017).beginningOnDay(1, 2)); }