@Override
  public Optional<Long> getInstallationId(GithubAppConfiguration githubAppConfiguration, String repositorySlug) {
    AppToken appToken = appSecurity.createAppToken(githubAppConfiguration.getId(), githubAppConfiguration.getPrivateKey());
    String endpoint = String.format("/repos/%s/installation", repositorySlug);
    return get(githubAppConfiguration.getApiEndpoint(), appToken, endpoint, GithubBinding.GsonInstallation.class)
      .map(GithubBinding.GsonInstallation::getId)
      .filter(installationId -> installationId != 0L);
  }
@Test
  public void getInstallationId_throws_IAE_if_fail_to_create_app_token() {
    when(appSecurity.createAppToken(githubAppConfiguration.getId(), githubAppConfiguration.getPrivateKey())).thenThrow(IllegalArgumentException.class);

    assertThatThrownBy(() -> underTest.getInstallationId(githubAppConfiguration, "torvalds"))
      .isInstanceOf(IllegalArgumentException.class);
  }