WebSocketHandler { Session loadSession(RequestImpl request, ActionLog actionLog) { Session session = sessionManager.load(request, actionLog); if (session == null) return null; return new ReadOnlySession(session); } WebSocketHandler(LogManager logManager, SessionManager sessionManager, RateControl rateControl); boolean checkWebSocket(HTTPMethod method, HeaderMap headers); void handle(HttpServerExchange exchange, RequestImpl request, ActionLog actionLog); void shutdown(); void add(String path, ChannelHandler<?, ?> handler); final WebSocketContextImpl context; }
@Test void loadSession() { when(sessionManager.load(any(), any())).thenReturn(new SessionImpl("localhost")); Session session = handler.loadSession(null, null); assertThat(session).isInstanceOf(ReadOnlySession.class); when(sessionManager.load(any(), any())).thenReturn(null); session = handler.loadSession(null, null); assertThat(session).isNull(); }