GitHub github = PowerMockito.mock(GitHub.class);
PowerMockito.when(GitHub.connectUsingOAuth("https://localhost/api/v3", "thisismytoken")).thenReturn(github);
PowerMockito.when(github.getMyself()).thenReturn(myself);
PowerMockito.when(github.getRepository("groupon/DotCi")).thenReturn(ghRepository);
GithubAuthenticationToken token = PowerMockito.mock(GithubAuthenticationToken.class);
PowerMockito.when(token.getGitHub()).thenReturn(github);
PowerMockito.when(token.getAccessToken()).thenReturn("thisismytoken");
PowerMockito.when(token.getName()).thenReturn("thisismyname");
SecurityContext context = PowerMockito.mock(SecurityContext.class);
PowerMockito.when(context.getAuthentication()).thenReturn(token);
SecurityContextHolder.setContext(context);