### Question:
EventPublisher { public static EventPublisher newInstance(EventListenerResolver eventListenerResolver) { List<? extends EventListener<? extends Event>> eventListeners = eventListenerResolver != null ? eventListenerResolver.resolveListeners() : null; return eventListeners != null && !eventListeners.isEmpty() ? new EventPublisher(eventListeners) : new EventPublisher(); } EventPublisher(List<? extends EventListener<? extends Event>> eventListeners); protected  EventPublisher(); static EventPublisher newInstance(EventListenerResolver eventListenerResolver); void publish(E event);  }### Answer:
@Test public void testNewInstance() { FirstEventListener firstEventListener = new FirstEventListener(); FirstEvent firstEvent = new FirstEvent("first"); EventListenerResolver eventListenerResolver = Mockito.mock(EventListenerResolver.class); List<FirstEventListener> eventListeners = Collections.<FirstEventListener>singletonList(firstEventListener); when(eventListenerResolver.resolveListeners()).thenReturn((List) eventListeners); EventPublisher eventPublisher = EventPublisher.newInstance(eventListenerResolver); assertNotNull(eventPublisher); assertNull(firstEventListener.event); eventPublisher.publish(firstEvent); assertSame(firstEvent, firstEventListener.event); }