SessionManager implements SessionContext { public void cookie(String name, String domain) { if (name == null) throw new Error("name must not be null"); cookieSpec = new CookieSpec(name).domain(domain).path("/").sessionScope().httpOnly().secure().sameSite(); }  Session load(Request request, ActionLog actionLog); void save(RequestImpl request, Response response, ActionLog actionLog); void store(SessionStore store); void timeout(Duration timeout); void cookie(String name, String domain); void header(String name); @Override void invalidate(String key, String value);  }
@Test void cookie() { sessionManager.cookie("SessionId", null); String sessionId = UUID.randomUUID().toString(); store.save(sessionId, "localhost", Map.of("key", "value"), Set.of(), Duration.ofMinutes(30)); when(request.scheme()).thenReturn("https"); when(request.cookie(eq(new CookieSpec("SessionId").path("/")))).thenReturn(Optional.of(sessionId)); Session session = sessionManager.load(request, new ActionLog(null, null)); assertThat(session).isNotNull(); assertThat(session.get("key")).isNotNull().hasValue("value"); }