### Question:
JwtRememberMeServices extends AbstractRememberMeServices { @Override protected void onLoginSuccess(@Nonnull final HttpServletRequest request, @Nonnull final HttpServletResponse response, @Nonnull final Authentication authentication) { final String user = authentication.getPrincipal().toString(); final String principals = generatePrincipalsToken(authentication.getAuthorities()); final String[] tokens = Arrays.asList(user, principals).stream().toArray(String[]::new); setCookie(tokens, getTokenValiditySeconds(), request, response); } JwtRememberMeServices(@Nonnull final JwtProperties properties);   }### Answer:
@Test public void onLoginSuccess() throws Exception { final AtomicReference<Cookie> cookie = new AtomicReference<>(); final HttpServletResponse response = Mockito.mock(HttpServletResponse.class); Mockito.doAnswer(answer -> cookie.compareAndSet(null, answer.getArgumentAt(0, Cookie.class))) .when(response).addCookie(Mockito.any()); final HttpServletRequest request = Mockito.mock(HttpServletRequest.class); Mockito.when(request.getContextPath()).thenReturn(""); final Authentication auth = new UsernamePasswordAuthenticationToken("dladmin", "thinkbig", groupAuthorities("admin")); service.onLoginSuccess(request, response, auth); Assert.assertEquals("eyJhbGciOiJIUzI1NiIsImtpZCI6IkhNQUMifQ.eyJleHAiOjE0NjMxNTE5MDAsInN1YiI6ImRsYWRtaW4iLCJwcmluY2lwYWxzIjpbIntcImNvbS50aGlua2J" + "pZ2FuYWx5dGljcy5zZWN1cml0eS5Hcm91cFByaW5jaXBhbFwiOltcImFkbWluXCJdfSJdfQ.DH4pxE8eWCmqPlhFMiEAbBja5k833gg0guE6m8DXvIA", cookie.get().getValue()); }