### Question:
JwtTokenValidationFilter implements Filter { static HttpRequest fromHttpServletRequest(final HttpServletRequest request) { return new HttpRequest() { @Override public String getHeader(String headerName) { return request.getHeader(headerName); } @Override public NameValue[] getCookies() { if (request.getCookies() == null) { return null; } return Arrays.stream(request.getCookies()).map(cookie -> new NameValue() { @Override public String getName() { return cookie.getName(); } @Override public String getValue() { return cookie.getValue(); } }).toArray(NameValue[]::new); } }; } JwtTokenValidationFilter(JwtTokenValidationHandler jwtTokenValidationHandler, TokenValidationContextHolder contextHolder); @Override void destroy(); @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); @Override void init(FilterConfig filterConfig);  }### Answer:
@Test void testRequestConverterShouldHandleWhenCookiesAreNULL() { when(servletRequest.getCookies()).thenReturn(null); when(servletRequest.getHeader(JwtTokenConstants.AUTHORIZATION_HEADER)).thenReturn(null); HttpRequest req = JwtTokenValidationFilter.fromHttpServletRequest(servletRequest); assertNull(req.getCookies()); assertNull(req.getHeader(JwtTokenConstants.AUTHORIZATION_HEADER)); }
@Test void testRequestConverterShouldConvertCorrectly() { when(servletRequest.getCookies()).thenReturn(new Cookie[]{new Cookie("JSESSIONID", "ABCDEF"), new Cookie("IDTOKEN", "THETOKEN")}); when(servletRequest.getHeader(JwtTokenConstants.AUTHORIZATION_HEADER)).thenReturn("Bearer eyAAA"); HttpRequest req = JwtTokenValidationFilter.fromHttpServletRequest(servletRequest); assertEquals("JSESSIONID", req.getCookies()[0].getName()); assertEquals("ABCDEF", req.getCookies()[0].getValue()); assertEquals("IDTOKEN", req.getCookies()[1].getName()); assertEquals("THETOKEN", req.getCookies()[1].getValue()); assertEquals("Bearer eyAAA", req.getHeader(JwtTokenConstants.AUTHORIZATION_HEADER)); }