Scheduler { public void triggerNow(String name) { Task task = tasks.get(name); if (task == null) throw new NotFoundException("job not found, name=" + name); submitJob(task, ZonedDateTime.now(clock), true); } 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 triggerNow() throws Exception { scheduler.addFixedRateTask("hourly-job", new TestJob(), Duration.ofHours(1)); scheduler.triggerNow("hourly-job"); @SuppressWarnings("unchecked") ArgumentCaptor<Callable<?>> task = ArgumentCaptor.forClass(Callable.class); verify(jobExecutor).submit(task.capture()); var actionLog = new ActionLog(null, null); when(logManager.begin(anyString(), isNull())).thenReturn(actionLog); task.getValue().call(); assertThat(actionLog.trace).isTrue(); assertThat(actionLog.context).containsKeys("trigger", "job", "job_class", "scheduled_time"); }