### Question:
MemoryPluginEventListener { @Subscribe public void onPluginEvent(final DisplayEvent event) { if (events.size() == MAX_ITEMS) { events.remove(0); } if (event.isAddAsFirst()) { events.add(0, event); } else { events.add(event); } }  @Subscribe void onPluginEvent(final DisplayEvent event); List<DisplayEvent> pollEvents(); List<DisplayEvent> consumeEvents(); static final int MAX_ITEMS; }### Answer:
@Test public void testOnPluginEvent() throws Exception { final int maxItems = MemoryPluginEventListener.MAX_ITEMS + 10; for (int i = 0; i < maxItems; i++) { eventBus.post(new DisplayEvent(String.valueOf(i))); } List<DisplayEvent> pluginEvents = listener.consumeEvents(); assertEquals(MemoryPluginEventListener.MAX_ITEMS, pluginEvents.size()); pluginEvents = listener.consumeEvents(); assertEquals(0, pluginEvents.size()); eventBus.post(new DisplayEvent("test")); pluginEvents = listener.consumeEvents(); assertEquals(1, pluginEvents.size()); eventBus.post(new DisplayEvent("test", true)); eventBus.post(new DisplayEvent("test", true)); eventBus.post(new DisplayEvent("first", true)); pluginEvents = listener.consumeEvents(); assertEquals(3, pluginEvents.size()); assertEquals(pluginEvents.get(0).getMessage(), "first"); pluginEvents = listener.consumeEvents(); assertEquals(0, pluginEvents.size()); assertEquals(0, listener.pollEvents().size()); }