GitHubHelper { public static String getGitHubAccessToken(String code, String githubClientID, String githubClientSecret) { final AuthorizationCodeFlow flow = new AuthorizationCodeFlow.Builder(BearerToken.authorizationHeaderAccessMethod(), HTTP_TRANSPORT, JSON_FACTORY, new GenericUrl("https: new ClientParametersAuthentication(githubClientID, githubClientSecret), githubClientID, "https: try { TokenResponse tokenResponse = flow.newTokenRequest(code) .setRequestInitializer(request -> request.getHeaders().setAccept("application/json")).execute(); if (tokenResponse.getAccessToken() != null) { return tokenResponse.getAccessToken(); } else { LOG.error("Retrieving accessToken was unsuccessful"); throw new CustomWebApplicationException("Could not retrieve github.com token", HttpStatus.SC_BAD_REQUEST); } } catch (IOException e) { LOG.error("Retrieving accessToken was unsuccessful"); throw new CustomWebApplicationException("Could not retrieve github.com token based on code", HttpStatus.SC_BAD_REQUEST); } } private  GitHubHelper(); static String getGitHubAccessToken(String code, String githubClientID, String githubClientSecret); static LicenseInformation getLicenseInformation(GitHub gitHub, String repositoryName); static String makeGitHubAppRequestAndGetRepositorySelection(Request request); static Set<String> getOrganizationsWithGitHubApp(Set<String> organizations); static Set<String> getReposWithGitHubApp(Set<String> repos); static String orgFromRepo(String repositoryName); static Set<String> individualReposWithGitHubApp(Collection<String> allRepositories, Collection<String> orgsWithAppInstalled); static void checkJWT(String gitHubAppId, String gitHubPrivateKeyFile); static String gitHubAppSetup(String gitHubAppId, String gitHubPrivateKeyFile, String installationId); static Collection<String> reposToCreateEntitiesFor(Collection<String> repositories, Optional<String> organization,
            Set<String> existingWorkflowPaths); static User findUserByGitHubUsername(TokenDAO tokenDAO, UserDAO userDAO, String username, boolean allowFail);  }
@Test public void testGetGitHubAccessToken() { try { GitHubHelper.getGitHubAccessToken(CODE, GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET); Assert.fail("No CustomWebApplicationException thrown"); } catch (CustomWebApplicationException e) { Assert.assertEquals("HTTP 400 Bad Request", e.getMessage()); } }