ExecutorImpl implements Executor { @Override public <T> Future<T> submit(String action, Callable<T> task) { Instant now = Instant.now(); String actionId = LogManager.ID_GENERATOR.next(now); logger.debug("submit task, action={}, id={}", action, actionId); Callable<T> execution = execution(actionId, action, now, task); return submitTask(action, execution); } ExecutorImpl(int poolSize, String name, LogManager logManager); void shutdown(); void awaitTermination(long timeoutInMs); @Override Future<T> submit(String action, Callable<T> task); @Override void submit(String action, Task task, Duration delay);  }
@Test void submit() throws ExecutionException, InterruptedException { ActionLog parentAction = logManager.begin("begin", null); parentAction.action("parentAction"); parentAction.trace = true; parentAction.correlationIds = List.of("correlationId"); Future<Boolean> future = executor.submit("action", () -> { ActionLog actionLog = LogManager.CURRENT_ACTION_LOG.get(); assertThat(actionLog.action).isEqualTo("parentAction:action"); assertThat(actionLog.trace).isTrue(); assertThat(actionLog.correlationIds).containsExactly("correlationId"); return Boolean.TRUE; }); assertThat(future.get()).isEqualTo(true); logManager.end("end"); }
@Test void submitWithDelayedTask() { executor.submit("action", () -> { }, Duration.ofHours(12)); assertThat(executor.scheduler).isNotNull(); }