Source:
<code>static AppInstallationToken generateAppInstallationToken(String appId, String appPrivateKey, String apiUrl, String owner) { try (Timeout timeout = Timeout.limit(30, TimeUnit.SECONDS)) { String jwtToken = createJWT(appId, appPrivateKey); GitHub gitHubApp = Connector .createGitHubBuilder(apiUrl) .withJwtToken(jwtToken) .build(); GHApp app = gitHubApp.getApp(); <START> List<GHAppInstallation> appInstallations = app.listInstallations().asList(); if (appInstallations.isEmpty()) { throw new IllegalArgumentException(String.format(ERROR_NOT_INSTALLED, appId)); } GHAppInstallation appInstallation; if (appInstallations.size() == 1) { appInstallation = appInstallations.get(0); } else { appInstallation = appInstallations.stream() .filter(installation -> installation.getAccount().getLogin().equals(owner)) .findAny() .orElseThrow(() -> new IllegalArgumentException(String.format( ERROR_NOT_INSTALLED, appId))); <END> } GHAppInstallationToken appInstallationToken = appInstallation .createToken(appInstallation.getPermissions()) .create(); long expiration = getExpirationSeconds(appInstallationToken); LOGGER.log(Level.FINEST, "Token raw expiration epoch seconds: {0,number,#}", expiration); AppInstallationToken token = new AppInstallationToken(appInstallationToken.getToken(), expiration); LOGGER.log(Level.FINE, "Generated App Installation Token for app ID {0}", appId); return token; } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to retrieve GitHub App installation token for app ID " + appId, e); throw new IllegalArgumentException(String.format(ERROR_AUTHENTICATING_GITHUB_APP, appId), e); } }</code><technical_language>reformatting</technical_language>

Target:
static AppInstallationToken generateAppInstallationToken(String appId, String appPrivateKey, String apiUrl, String owner) { try (Timeout timeout = Timeout.limit(30, TimeUnit.SECONDS)) { String jwtToken = createJWT(appId, appPrivateKey); GitHub gitHubApp = Connector .createGitHubBuilder(apiUrl) .withJwtToken(jwtToken) .build(); GHApp app; try { app = gitHubApp.getApp(); } catch (IOException e) { throw new IllegalArgumentException(String.format(ERROR_AUTHENTICATING_GITHUB_APP, appId), e); } List<GHAppInstallation> appInstallations = app.listInstallations().asList(); if (appInstallations.isEmpty()) { throw new IllegalArgumentException(String.format(ERROR_NOT_INSTALLED, appId)); } GHAppInstallation appInstallation; if (appInstallations.size() == 1) { appInstallation = appInstallations.get(0); } else { appInstallation = appInstallations.stream() .filter(installation -> installation.getAccount().getLogin().equals(owner)) .findAny() .orElseThrow(() -> new IllegalArgumentException(String.format(ERROR_NOT_INSTALLED, appId))); } GHAppInstallationToken appInstallationToken = appInstallation .createToken(appInstallation.getPermissions()) .create(); long expiration = getExpirationSeconds(appInstallationToken); AppInstallationToken token = new AppInstallationToken(appInstallationToken.getToken(), expiration); LOGGER.log(Level.FINER, "Generated App Installation Token for app ID {0}", appId); return token; } catch (Exception e) { throw new IllegalArgumentException("Failed to generate GitHub App installation token for app ID " + appId , e); } }