@Test public void schedule_runnable_at_fixed_rate_passes_through_to_delegate_with_tracing_wrapper() { Runnable origTaskMock = mock(Runnable.class); ScheduledFuture<?> expectedResultMock = mock(ScheduledFuture.class); doReturn(expectedResultMock).when(executorServiceMock) .scheduleAtFixedRate(any(Runnable.class), anyLong(), anyLong(), any(TimeUnit.class)); TracingState expectedTracingState = generateTracingStateOnCurrentThread(); ScheduledFuture<?> result = instance.scheduleAtFixedRate(origTaskMock, 10L, 10L, TimeUnit.SECONDS); assertThat(result).isSameAs(expectedResultMock); verify(executorServiceMock).scheduleAtFixedRate(runnableCaptor.capture(), eq(10L), eq(10L), eq(TimeUnit.SECONDS)); Runnable actualTask = runnableCaptor.getValue(); verifyRunnableWithTracingWrapper(actualTask, origTaskMock, expectedTracingState); verifyNoMoreInteractions(executorServiceMock); }
@Override public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return this.delegate.scheduleAtFixedRate(new RunnableWithTracing(command), initialDelay, period, unit); }
ScheduledExecutorServiceWithTracing extends ExecutorServiceWithTracing implements ScheduledExecutorService { @Override public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return this.delegate.scheduleAtFixedRate(new RunnableWithTracing(command), initialDelay, period, unit); } }
ScheduledExecutorServiceWithTracing extends ExecutorServiceWithTracing implements ScheduledExecutorService { @Override public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return this.delegate.scheduleAtFixedRate(new RunnableWithTracing(command), initialDelay, period, unit); } ScheduledExecutorServiceWithTracing(ScheduledExecutorService delegate); }
ScheduledExecutorServiceWithTracing extends ExecutorServiceWithTracing implements ScheduledExecutorService { @Override public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return this.delegate.scheduleAtFixedRate(new RunnableWithTracing(command), initialDelay, period, unit); } ScheduledExecutorServiceWithTracing(ScheduledExecutorService delegate); static ScheduledExecutorServiceWithTracing withTracing(ScheduledExecutorService delegate); @Override ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit); @Override ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit); @Override ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit); @Override ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit); }
ScheduledExecutorServiceWithTracing extends ExecutorServiceWithTracing implements ScheduledExecutorService { @Override public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return this.delegate.scheduleAtFixedRate(new RunnableWithTracing(command), initialDelay, period, unit); } ScheduledExecutorServiceWithTracing(ScheduledExecutorService delegate); static ScheduledExecutorServiceWithTracing withTracing(ScheduledExecutorService delegate); @Override ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit); @Override ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit); @Override ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit); @Override ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit);  }