static Duration getDefaultPeriod(Duration size) {
    if (size.isLongerThan(Duration.standardHours(1))) {
      return Duration.standardHours(1);
    }
    if (size.isLongerThan(Duration.standardMinutes(1))) {
      return Duration.standardMinutes(1);
    }
    if (size.isLongerThan(Duration.standardSeconds(1))) {
      return Duration.standardSeconds(1);
    }
    return Duration.millis(1);
  }
@Test
  public void testDefaultPeriods() throws Exception {
    assertEquals(
        Duration.standardHours(1), SlidingWindows.getDefaultPeriod(Duration.standardDays(1)));
    assertEquals(
        Duration.standardHours(1), SlidingWindows.getDefaultPeriod(Duration.standardHours(2)));
    assertEquals(
        Duration.standardMinutes(1), SlidingWindows.getDefaultPeriod(Duration.standardHours(1)));
    assertEquals(
        Duration.standardMinutes(1), SlidingWindows.getDefaultPeriod(Duration.standardMinutes(10)));
    assertEquals(
        Duration.standardSeconds(1), SlidingWindows.getDefaultPeriod(Duration.standardMinutes(1)));
    assertEquals(
        Duration.standardSeconds(1), SlidingWindows.getDefaultPeriod(Duration.standardSeconds(10)));
    assertEquals(Duration.millis(1), SlidingWindows.getDefaultPeriod(Duration.standardSeconds(1)));
    assertEquals(Duration.millis(1), SlidingWindows.getDefaultPeriod(Duration.millis(10)));
    assertEquals(Duration.millis(1), SlidingWindows.getDefaultPeriod(Duration.millis(1)));
  }