GatingDelayExecutor implements DelayExecutor, GatedWorkQueue { @Override public synchronized void execute(Runnable command) { enqueue(() -> gated.execute(command)); } @Inject  GatingDelayExecutor(ScheduledExecutorService gated); @Override T closeDuring(GatedOperation<T, E> operation); @Override synchronized void execute(Runnable command); @Override synchronized void execute(Runnable work, Amount<Long, Time> minDelay);  }
@Test public void testGateOpen() { gatedExecutor.execute(runnable); control.replay(); gatingExecutor.execute(runnable); }
@Test public void testExecute() { gatedExecutor.execute(runnable); invokeWorkWhenSubmitted(); runnable.run(); expectLastCall(); control.replay(); gatingExecutor.execute(runnable); }
@Test public void testExecuteAfterDelay() { gatedExecutor.schedule( runnable, ONE_SECOND.getValue().longValue(), ONE_SECOND.getUnit().getTimeUnit()); invokeWorkWhenSubmitted(); runnable.run(); control.replay(); gatingExecutor.execute(runnable, ONE_SECOND); }