DailyTrigger implements Trigger { @Override public ZonedDateTime next(ZonedDateTime previous) { ZonedDateTime next = previous.with(time); if (!next.isAfter(previous)) { next = next.plusDays(1).with(time); } return next; } DailyTrigger(LocalTime time); @Override ZonedDateTime next(ZonedDateTime previous); @Override String toString();  }
@Test void next() { var trigger = new DailyTrigger(of(10, 0)); assertThat(trigger.next(date("2017-04-10T09:00:00"))).isEqualTo(date("2017-04-10T10:00:00")); assertThat(trigger.next(ZonedDateTime.parse("2017-04-10T09:00:00Z"))).isEqualTo("2017-04-10T10:00:00Z"); assertThat(trigger.next(date("2017-04-10T10:00:00"))).isEqualTo(date("2017-04-11T10:00:00")); assertThat(trigger.next(date("2017-04-10T11:00:00"))).isEqualTo(date("2017-04-11T10:00:00")); }
@Test void nextWithDayLightSavingStart() { var trigger = new DailyTrigger(of(2, 30)); assertThat(trigger.next(date("2017-03-12T01:00:00"))).isEqualTo(date("2017-03-12T02:30:00")); assertThat(trigger.next(date("2017-03-12T02:30:00"))).isEqualTo(date("2017-03-13T02:30:00")); assertThat(trigger.next(date("2017-03-13T02:30:00"))).isEqualTo(date("2017-03-14T02:30:00")); }
@Test void nextWithDayLightSavingEnd() { var trigger = new DailyTrigger(of(2, 0)); assertThat(trigger.next(date("2017-11-05T00:00:00"))).isEqualTo(date("2017-11-05T02:00:00")); assertThat(trigger.next(date("2017-11-05T02:00:00"))).isEqualTo(date("2017-11-06T02:00:00")); assertThat(trigger.next(date("2017-11-05T02:30:00"))).isEqualTo(date("2017-11-06T02:00:00")); }