### Question:
EventPublisher { public <E extends Event> void publish(E event) { if (!eventListenerMap.isEmpty()) { EventListener<E> eventListener = getEventListener(event); if (eventListener != null) { eventListener.on(event); } } } EventPublisher(List<? extends EventListener<? extends Event>> eventListeners); protected  EventPublisher(); static EventPublisher newInstance(EventListenerResolver eventListenerResolver); void publish(E event);  }### Answer:
@Test public void testPublishWithNoListeners() { EventPublisher eventPublisher = new EventPublisher(); eventPublisher.publish(new ConnectionAcquireTimeoutEvent("123")); }
@Test public void testPublishWithListeners() { FirstEventListener firstEventListener = new FirstEventListener(); SecondEventListener secondEventListener = new SecondEventListener(); EventPublisher eventPublisher = new EventPublisher( Arrays.asList(firstEventListener, secondEventListener) ); FirstEvent firstEvent = new FirstEvent("first"); SecondEvent secondEvent = new SecondEvent("second"); assertNull(firstEventListener.event); assertNull(secondEventListener.event); eventPublisher.publish(firstEvent); eventPublisher.publish(secondEvent); assertSame(firstEvent, firstEventListener.event); assertSame(secondEvent, secondEventListener.event); }