CalendarWindows { public static DaysWindows days(int number) { return new DaysWindows(number, 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 testDays() throws Exception { Map<IntervalWindow, Set<String>> expected = new HashMap<>(); final List<Long> timestamps = Arrays.asList( makeTimestamp(2014, 1, 1, 0, 0).getMillis(), makeTimestamp(2014, 1, 1, 23, 59).getMillis(), makeTimestamp(2014, 1, 2, 0, 0).getMillis(), makeTimestamp(2014, 1, 2, 5, 5).getMillis(), makeTimestamp(2015, 1, 1, 0, 0).getMillis(), makeTimestamp(2015, 1, 1, 5, 5).getMillis()); expected.put( new IntervalWindow(makeTimestamp(2014, 1, 1, 0, 0), makeTimestamp(2014, 1, 2, 0, 0)), set(timestamps.get(0), timestamps.get(1))); expected.put( new IntervalWindow(makeTimestamp(2014, 1, 2, 0, 0), makeTimestamp(2014, 1, 3, 0, 0)), set(timestamps.get(2), timestamps.get(3))); expected.put( new IntervalWindow(makeTimestamp(2015, 1, 1, 0, 0), makeTimestamp(2015, 1, 2, 0, 0)), set(timestamps.get(4), timestamps.get(5))); assertEquals(expected, runWindowFn(CalendarWindows.days(1), timestamps)); }
@Test public void testDaysCompatibility() throws IncompatibleWindowException { CalendarWindows.DaysWindows daysWindows = CalendarWindows.days(10); daysWindows.verifyCompatibility(CalendarWindows.days(10)); thrown.expect(IncompatibleWindowException.class); daysWindows.verifyCompatibility(CalendarWindows.days(9)); }
@Test public void testTimeZone() throws Exception { Map<IntervalWindow, Set<String>> expected = new HashMap<>(); DateTimeZone timeZone = DateTimeZone.forID("America/Los_Angeles"); final List<Long> timestamps = Arrays.asList( new DateTime(2014, 1, 1, 0, 0, timeZone).getMillis(), new DateTime(2014, 1, 1, 23, 59, timeZone).getMillis(), new DateTime(2014, 1, 2, 8, 0, DateTimeZone.UTC).getMillis(), new DateTime(2014, 1, 3, 7, 59, DateTimeZone.UTC).getMillis()); expected.put( new IntervalWindow( new DateTime(2014, 1, 1, 0, 0, timeZone).toInstant(), new DateTime(2014, 1, 2, 0, 0, timeZone).toInstant()), set(timestamps.get(0), timestamps.get(1))); expected.put( new IntervalWindow( new DateTime(2014, 1, 2, 0, 0, timeZone).toInstant(), new DateTime(2014, 1, 3, 0, 0, timeZone).toInstant()), set(timestamps.get(2), timestamps.get(3))); assertEquals(expected, runWindowFn(CalendarWindows.days(1).withTimeZone(timeZone), timestamps)); }