ListenerManager { public void eventOccurred(String someEvent) { if (someEvent == null) { throw new IllegalArgumentException("someEvent must not be null"); } for (Listener listener : listeners) { listener.eventOccured(someEvent); } }  void eventOccurred(String someEvent); void setListeners(Set<Listener> listeners);  }
@Test public void shouldCallAllListeners() { String someEvent = "Something"; manager.eventOccurred(someEvent); verify(sampleListener1).eventOccured(someEvent); verify(sampleListener2).eventOccured(someEvent); }
@Test(expected = IllegalArgumentException.class) public void shouldFailGivenNull() { String someEvent = null; manager.eventOccurred(someEvent); }