Search in sources :

Example 1 with HerokuAppDetails

use of io.codekvast.login.heroku.model.HerokuAppDetails in project codekvast by crispab.

the class HerokuApiWrapperImplTest method should_get_app_details.

@Test
void should_get_app_details() throws IOException {
    // given
    givenThat(get("/addons/some-external-id").withHeader("Authorization", new EqualToPattern("Bearer some-access-token")).withHeader("Accept", new EqualToPattern("application/vnd.heroku+json; version=3")).willReturn(okJson(readResource("/heroku/sample-heroku-addons-response.json"))));
    givenThat(get("/apps/some-app-id").withHeader("Authorization", new EqualToPattern("Bearer some-access-token")).withHeader("Accept", new EqualToPattern("application/vnd.heroku+json; version=3")).willReturn(okJson(readResource("/heroku/sample-heroku-apps-response.json"))));
    // when
    HerokuAppDetails appDetails = herokuApiWrapper.getAppDetails("some-external-id", "some-access-token");
    // then
    assertThat(appDetails, is(HerokuAppDetails.builder().appName("some-app-name").ownerEmail("some-owner-email").build()));
}
Also used : EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) HerokuAppDetails(io.codekvast.login.heroku.model.HerokuAppDetails) Test(org.junit.jupiter.api.Test) WireMockTest(com.github.tomakehurst.wiremock.junit5.WireMockTest)

Example 2 with HerokuAppDetails

use of io.codekvast.login.heroku.model.HerokuAppDetails in project codekvast by crispab.

the class HerokuServiceImpl method fetchAppDetails.

private void fetchAppDetails(String source, String externalId, String accessToken, Long customerId) {
    if (accessToken == null) {
        logger.info("Cannot get application details from {} for externalId '{}'", source, externalId);
        return;
    }
    HerokuAppDetails appDetails = herokuApiWrapper.getAppDetails(externalId, accessToken);
    customerService.updateAppDetails(appDetails.getAppName(), appDetails.getOwnerEmail(), customerId);
}
Also used : HerokuAppDetails(io.codekvast.login.heroku.model.HerokuAppDetails)

Aggregations

HerokuAppDetails (io.codekvast.login.heroku.model.HerokuAppDetails)2 WireMockTest (com.github.tomakehurst.wiremock.junit5.WireMockTest)1 EqualToPattern (com.github.tomakehurst.wiremock.matching.EqualToPattern)1 Test (org.junit.jupiter.api.Test)1