EventController { void addContext(Map<String, String> context, String userAgent, List<Cookie> cookies, String clientIP) { if (userAgent != null) context.put("user_agent", userAgent); context.put("client_ip", clientIP); if (cookies != null) { for (Cookie cookie : cookies) { context.put(cookie.name, cookie.value); } } } EventController(List<String> allowedOrigins, List<String> collectCookies); Response options(Request request); Response post(Request request);  }
@Test void addContext() { var controller = new EventController(List.of(), null); Map<String, String> context = new HashMap<>(); controller.addContext(context, "agent", List.of(new Cookie("cookie", "value")), "ip"); assertThat(context).containsKeys("client_ip", "user_agent", "cookie"); }