@Test public void whenOnlyOneState() { List<ListenerRegistration> registrations = new ArrayList<>(); registrations.add(newRegistration(GameState.WAITING)); registrations.add(newRegistration(GameState.WAITING)); runTest(listenerRegistrationService -> { listenerRegistrationService.gameStateChanged(GameState.WAITING); verify(pluginManager, times(2)).registerEvents(any(), any()); verifyZeroInteractions(listenerUnregister); }, registrations); }
public void gameStateChanged(GameState newState) { Set<Listener> listenersForNewState = recalculateListenersForNewState(newState); this.registerNew(listenersForNewState); }
ListenerRegistrationService { public void gameStateChanged(GameState newState) { Set<Listener> listenersForNewState = recalculateListenersForNewState(newState); this.registerNew(listenersForNewState); } }
ListenerRegistrationService { public void gameStateChanged(GameState newState) { Set<Listener> listenersForNewState = recalculateListenersForNewState(newState); this.registerNew(listenersForNewState); } ListenerRegistrationService(Plugin plugin, PluginManager pluginManager, List<ListenerRegistration> registrationListeners, ListenerUnregister listenerUnregister); }
ListenerRegistrationService { public void gameStateChanged(GameState newState) { Set<Listener> listenersForNewState = recalculateListenersForNewState(newState); this.registerNew(listenersForNewState); } ListenerRegistrationService(Plugin plugin, PluginManager pluginManager, List<ListenerRegistration> registrationListeners, ListenerUnregister listenerUnregister); void gameStateChanged(GameState newState); }
ListenerRegistrationService { public void gameStateChanged(GameState newState) { Set<Listener> listenersForNewState = recalculateListenersForNewState(newState); this.registerNew(listenersForNewState); } ListenerRegistrationService(Plugin plugin, PluginManager pluginManager, List<ListenerRegistration> registrationListeners, ListenerUnregister listenerUnregister); void gameStateChanged(GameState newState);  }