EventBufferSingleThreadAccessMock implements ISingleThreadAccess { public List<Runnable> getEventsCopy() { checkThread(); return Collections.unmodifiableList(new LinkedList<Runnable>(events)); } EventBufferSingleThreadAccessMock(); @Override boolean isSingleThread(); @Override void invoke(final Runnable runnable); int getEventsCount(); List<Runnable> getEventsCopy(); List<Runnable> popEvents(); void runEvents(); void checkThread();  }
@Test public void testGetEventsCopy() { invokeRunnablesOnce(); verifyNothingInvoked(); final List<Runnable> eventsList = threadAccess.getEventsCopy(); Assert.assertEquals(4, eventsList.size()); final Runnable[] eventsArray = eventsList.toArray(new Runnable[4]); Assert.assertEquals(runnable0, eventsArray[0]); Assert.assertEquals(runnable1, eventsArray[1]); Assert.assertEquals(runnable2, eventsArray[2]); Assert.assertEquals(runnable3, eventsArray[3]); Assert.assertEquals(4, threadAccess.getEventsCount()); }