ExecutorServiceWithTracing implements ExecutorService { @Override public void execute(Runnable command) { delegate.execute(new RunnableWithTracing(command)); } ExecutorServiceWithTracing(ExecutorService delegate); static ExecutorServiceWithTracing withTracing(ExecutorService delegate); @Override void shutdown(); @Override List<Runnable> shutdownNow(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override Future<T> submit(Callable<T> task); @Override Future<T> submit(Runnable task, T result); @Override Future<?> submit(Runnable task); @Override List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks); @Override List<Future<T>> invokeAll(
        Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit
    ); @Override T invokeAny(Collection<? extends Callable<T>> tasks); @Override T invokeAny(
        Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit
    ); @Override void execute(Runnable command);  }
@Test public void execute_passes_through_to_delegate_with_tracing_wrapped_runnable() { Runnable origRunnableMock = mock(Runnable.class); TracingState expectedTracingState = generateTracingStateOnCurrentThread(); instance.execute(origRunnableMock); verify(executorServiceMock).execute(runnableCaptor.capture()); Runnable actualRunnable = runnableCaptor.getValue(); verifyRunnableWithTracingWrapper(actualRunnable, origRunnableMock, expectedTracingState); verifyNoMoreInteractions(executorServiceMock); }