@Test public void testPopEvents() { invokeRunnablesOnce(); verifyNothingInvoked(); final List<Runnable> eventsList = threadAccess.popEvents(); 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(0, threadAccess.getEventsCount()); }
public List<Runnable> popEvents() { checkThread(); final List<Runnable> result = new LinkedList<Runnable>(); while (!events.isEmpty()) { final Runnable event = events.poll(); if (event != null) { result.add(event); } } return Collections.unmodifiableList(result); }
EventBufferSingleThreadAccessMock implements ISingleThreadAccess { public List<Runnable> popEvents() { checkThread(); final List<Runnable> result = new LinkedList<Runnable>(); while (!events.isEmpty()) { final Runnable event = events.poll(); if (event != null) { result.add(event); } } return Collections.unmodifiableList(result); } }
EventBufferSingleThreadAccessMock implements ISingleThreadAccess { public List<Runnable> popEvents() { checkThread(); final List<Runnable> result = new LinkedList<Runnable>(); while (!events.isEmpty()) { final Runnable event = events.poll(); if (event != null) { result.add(event); } } return Collections.unmodifiableList(result); } EventBufferSingleThreadAccessMock(); }
EventBufferSingleThreadAccessMock implements ISingleThreadAccess { public List<Runnable> popEvents() { checkThread(); final List<Runnable> result = new LinkedList<Runnable>(); while (!events.isEmpty()) { final Runnable event = events.poll(); if (event != null) { result.add(event); } } return Collections.unmodifiableList(result); } EventBufferSingleThreadAccessMock(); @Override boolean isSingleThread(); @Override void invoke(final Runnable runnable); int getEventsCount(); List<Runnable> getEventsCopy(); List<Runnable> popEvents(); void runEvents(); void checkThread(); }
EventBufferSingleThreadAccessMock implements ISingleThreadAccess { public List<Runnable> popEvents() { checkThread(); final List<Runnable> result = new LinkedList<Runnable>(); while (!events.isEmpty()) { final Runnable event = events.poll(); if (event != null) { result.add(event); } } return Collections.unmodifiableList(result); } EventBufferSingleThreadAccessMock(); @Override boolean isSingleThread(); @Override void invoke(final Runnable runnable); int getEventsCount(); List<Runnable> getEventsCopy(); List<Runnable> popEvents(); void runEvents(); void checkThread();  }