EventDispatcher implements EventAPI { @Override public void removeListener(Listener listener, Enum<?>... eventTypes) { removeListener(listener, ImmutableSet.copyOf(eventTypes)); } EventDispatcher(Set<Enum<?>> supportedEventTypes);  EventDispatcher(Enum<?>... supportedEventTypes); void dispatchEvent(Event e); void safeDispatchEvent(Event e); @Override void addListener(Listener listener, Enum<?>... eventTypes); @Override void addListener(Listener listener,
      Iterable<? extends Enum<?>> eventTypes); @Override void removeListener(Listener listener, Enum<?>... eventTypes); @Override void removeListener(Listener listener,
      Iterable<? extends Enum<?>> eventTypes); @Override boolean containsListener(Listener listener, Enum<?> eventType); boolean hasListenerFor(Enum<?> eventType); EventAPI getPublicEventAPI();  }
@Test(expected = IllegalArgumentException.class) public void removeListenerFail3() { dispatcher.removeListener(l1, EVENT1); }
@Test public void removeListener() { dispatcher.addListener(l1, EVENT1); dispatcher.addListener(l2, EVENT3, EVENT2); dispatcher.addListener(l3, EVENT1, EVENT3); assertTrue(dispatcher.containsListener(l1, EVENT1)); assertFalse(dispatcher.containsListener(l1, EVENT2)); assertFalse(dispatcher.containsListener(l1, EVENT3)); assertFalse(dispatcher.containsListener(l1, OTHER_EVENT1)); assertFalse(dispatcher.containsListener(l2, EVENT1)); assertTrue(dispatcher.containsListener(l2, EVENT2)); assertTrue(dispatcher.containsListener(l2, EVENT3)); assertFalse(dispatcher.containsListener(l2, OTHER_EVENT1)); assertTrue(dispatcher.containsListener(l3, EVENT1)); assertFalse(dispatcher.containsListener(l3, EVENT2)); assertTrue(dispatcher.containsListener(l3, EVENT3)); assertFalse(dispatcher.containsListener(l3, OTHER_EVENT1)); dispatcher.removeListener(l2, EVENT2, EVENT3); assertFalse(dispatcher.containsListener(l2, EVENT1)); assertFalse(dispatcher.containsListener(l2, EVENT2)); assertFalse(dispatcher.containsListener(l2, EVENT3)); assertFalse(dispatcher.containsListener(l2, OTHER_EVENT1)); }
@Test public void removeFail() { final EventDispatcher disp = new EventDispatcher(EventTypes.values()); boolean fail = false; try { disp.removeListener(l1, new LinkedHashSet<Enum<?>>(null)); } catch (final NullPointerException e) { fail = true; } assertThat(fail).isTrue(); }