Scheduler { void executeTask(TriggerTask task, ZonedDateTime scheduledTime) { try { ZonedDateTime next = next(task.trigger, scheduledTime); schedule(task, next); logger.info("execute scheduled job, job={}, trigger={}, scheduled={}, next={}", task.name(), task.trigger(), scheduledTime, next); submitJob(task, scheduledTime, false); } catch (Throwable e) { logger.error("failed to execute scheduled job, job is terminated, job={}, error={}", task.name(), e.getMessage(), e); } } 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 executeTaskWithTriggerError() { var task = new TriggerTask("trigger-job", null, previous -> previous, ZoneId.systemDefault()); scheduler.executeTask(task, ZonedDateTime.now()); verify(jobExecutor, never()).submit((Callable<?>) any(Callable.class)); }