ScheduledRunnable implements Runnable, Cancellable { public void scheduleWithFixedDelay(ScheduledExecutorService scheduledExecutor, long initialDelay, long period, TimeUnit unit) { if (future != null) { logger.error("command has already been scheduled: {}", this); return; } future = scheduledExecutor.scheduleWithFixedDelay(this, initialDelay, period, unit); }  void scheduleWithFixedDelay(ScheduledExecutorService scheduledExecutor,
            long initialDelay, long period, TimeUnit unit); @Override void run(); @Override void cancel();  }
@Test public void testScheduleWithFixedDelay() { TestScheduledRunnable testScheduledRunnable = new TestScheduledRunnable(); testScheduledRunnable.scheduleWithFixedDelay(scheduledExecutorService, 0, 1, SECONDS); verify(scheduledExecutorService).scheduleWithFixedDelay(testScheduledRunnable, 0, 1, SECONDS); verifyNoMoreInteractions(scheduledExecutorService); }
@Test public void testScheduleWithFixedDelayCalledTwice() { TestScheduledRunnable testScheduledRunnable = new TestScheduledRunnable(); testScheduledRunnable.scheduleWithFixedDelay(scheduledExecutorService, 0, 1, SECONDS); testScheduledRunnable.scheduleWithFixedDelay(scheduledExecutorService, 0, 1, SECONDS); verify(scheduledExecutorService).scheduleWithFixedDelay(testScheduledRunnable, 0, 1, SECONDS); verifyNoMoreInteractions(scheduledExecutorService); }