private GithubAuthenticationToken getGithubAuthentication(String user) { GithubAuthenticationToken auth = Mockito.mock(GithubAuthenticationToken.class); Mockito.when(auth.getName()).thenReturn(user); Mockito.when(auth.isAuthenticated()).thenReturn(true); return auth; }