PresenceEventListener { @EventListener void handleSessionDisconnect(final SessionDisconnectEvent event) { final String sessionId = event.getSessionId(); webSocketConsumersManager.removeConsumersForSessionId(sessionId); } PresenceEventListener(final WebSocketConsumersManager webSocketConsumersManager);   }
@Test public void testDisconnectListner() { final String sessionId = "my-session-id"; final SessionDisconnectEvent mockEvent = mock(SessionDisconnectEvent.class); when(mockEvent.getSessionId()).thenReturn(sessionId); final WebSocketConsumersManager mockManager = mock(WebSocketConsumersManager.class); final PresenceEventListener eventListener = new PresenceEventListener(mockManager); eventListener.handleSessionDisconnect(mockEvent); verify(mockManager, times(1)).removeConsumersForSessionId(eq(sessionId)); }