DefaultFlusher implements Flusher { @Override public void schedule(Flushable flushable) { flushables.add(flushable); scheduleFlush(); } private  DefaultFlusher(Scheduler scheduler, long flushDelay, TimeUnit flushDelayUnit); @Override void schedule(Flushable flushable);  }
@Test public void singleSchedule() { flusher.schedule(flushable1); scheduler.advanceTimeBy(1, TimeUnit.SECONDS); scheduler.triggerActions(); verify(flushable1).flush(); }
@Test public void multipleSchedule() { flusher.schedule(flushable1); flusher.schedule(flushable2); scheduler.advanceTimeBy(500, TimeUnit.MILLISECONDS); verifyZeroInteractions(flushable1, flushable2); scheduler.advanceTimeBy(500, TimeUnit.MILLISECONDS); scheduler.triggerActions(); verify(flushable1).flush(); verify(flushable2).flush(); verifyNoMoreInteractions(flushable1, flushable2); }