class UserController {

    @RequestMapping(value = "check", method = RequestMethod.GET)
    public LoginResponse check(final HttpServletResponse response) {
        if (JwtFilter.SUBJECT_ANONYMOUS.equals(response.getHeader(JwtFilter.HEADER_CLAIMS_SUBJECT))) {
            return new LoginResponse(JwtFilter.ANONYMOUS_USER_ID, response.getHeader(JwtFilter.HEADER_CLAIMS_SUBJECT),
                authenticationService.anonymousToken());
        }

        return new LoginResponse(response.getHeader(JwtFilter.HEADER_CLAIMS_USER_ID),
            response.getHeader(JwtFilter.HEADER_CLAIMS_SUBJECT),
            response.getHeader(JwtFilter.JWT_TOKEN));
    }

}

class UserControllerTest {

    private static final String USERNAME;
    private static final String PASSWORD;
    private static final String ROLE;
    @Mock
    private UserService mockUserService;
    @Mock
    private AuthenticationService mockAuthenticationService;
    @Mock
    private HttpServletRequest mockHttpServletRequest;
    @Mock
    private HttpServletResponse mockHttpServletResponse;
    @Mock
    private UserEntity mockUserEntity;
    private UserController userController;

    @Test
    public void testCheckNotAnonymousHeader() {

        Mockito.when(mockHttpServletResponse.getHeader(JwtFilter.HEADER_CLAIMS_SUBJECT)).thenReturn("not anonymous");
        Mockito.when(mockHttpServletResponse.getHeader(JwtFilter.JWT_TOKEN)).thenReturn("token");

        final LoginResponse loginResponse = userController.check(mockHttpServletResponse);

        assertNotNull(loginResponse);

        Mockito.verify(mockHttpServletResponse, Mockito.times(2)).getHeader(JwtFilter.HEADER_CLAIMS_SUBJECT);
        Mockito.verify(mockHttpServletResponse).getHeader(JwtFilter.JWT_TOKEN);
    }

}