Scheduler { ZonedDateTime next(Trigger trigger, ZonedDateTime previous) { ZonedDateTime next = trigger.next(previous); if (next == null || !next.isAfter(previous)) throw new Error(format("next scheduled time must be after previous, previous={}, next={}", previous, next)); return next; } Scheduler(LogManager logManager);   Scheduler(LogManager logManager, ScheduledExecutorService scheduler, ExecutorService jobExecutor); void start(); void shutdown(); void awaitTermination(long timeoutInMs); void addFixedRateTask(String name, Job job, Duration rate); void addTriggerTask(String name, Job job, Trigger trigger); void triggerNow(String name); final Map<String, Task> tasks; public Clock clock; }
@Test void next() { assertThatThrownBy(() -> scheduler.next(previous -> null, ZonedDateTime.now())) .hasMessageContaining("must be after previous"); assertThat(scheduler.next(previous -> previous.plusHours(1), ZonedDateTime.now())).isNotNull(); }