### Question:
AmbariJwtAuthenticationFilter implements AmbariAuthenticationFilter { String getJWTFromCookie(HttpServletRequest req) { String serializedJWT = null; Cookie[] cookies = req.getCookies(); if (cookies != null) { JwtAuthenticationProperties jwtProperties = propertiesProvider.get(); String jwtCookieName = (jwtProperties == null) ? null : jwtProperties.getCookieName(); if (StringUtils.isEmpty(jwtCookieName)) { jwtCookieName = AmbariServerConfigurationKey.SSO_JWT_COOKIE_NAME.getDefaultValue(); } for (Cookie cookie : cookies) { if (jwtCookieName.equals(cookie.getName())) { LOG.info("{} cookie has been found and is being processed", jwtCookieName); serializedJWT = cookie.getValue(); break; } } } return serializedJWT; } AmbariJwtAuthenticationFilter(AuthenticationEntryPoint ambariEntryPoint,
                                JwtAuthenticationPropertiesProvider propertiesProvider,
                                AmbariJwtAuthenticationProvider authenticationProvider,
                                AmbariAuthenticationEventHandler eventHandler); @Override boolean shouldApply(HttpServletRequest httpServletRequest); @Override boolean shouldIncrementFailureCount(); @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain); @Override void destroy();  }### Answer:
@Test public void testGetJWTFromCookie() throws Exception { HttpServletRequest request = createNiceMock(HttpServletRequest.class); Cookie cookie = createNiceMock(Cookie.class); expect(cookie.getName()).andReturn("non-default"); expect(cookie.getValue()).andReturn("stubtokenstring"); expect(request.getCookies()).andReturn(new Cookie[]{cookie}); JwtAuthenticationPropertiesProvider jwtAuthenticationPropertiesProvider = createMock(JwtAuthenticationPropertiesProvider.class); expect(jwtAuthenticationPropertiesProvider.get()).andReturn(createTestProperties()).anyTimes(); AmbariAuthenticationEventHandler eventHandler = createNiceMock(AmbariAuthenticationEventHandler.class); replayAll(); AmbariJwtAuthenticationFilter filter = new AmbariJwtAuthenticationFilter(null, jwtAuthenticationPropertiesProvider, null, eventHandler); String jwtFromCookie = filter.getJWTFromCookie(request); verifyAll(); assertEquals("stubtokenstring", jwtFromCookie); }