static ChannelByIdGet of(final Identifiable<Channel> resource) { return of(resource.getId()); }
static ChannelByIdGet of(final Identifiable<Channel> channel) { return of(channel.getId()); }
@Test public void retryOnInvalidToken() throws Exception { final RetryInvalidTokenHttpClient httpClient = new RetryInvalidTokenHttpClient(getSphereClientConfig()); final SphereAccessTokenSupplier tokenSupplier = SphereAccessTokenSupplier.ofAutoRefresh(getSphereClientConfig(), httpClient, false); try(final SphereClient client = SphereClient.of(getSphereClientConfig(), httpClient, tokenSupplier)) { assertThat(httpClient.isTokenValid()).isTrue(); assertThat(client.execute(CategoryByIdGet.of("cat-id")).toCompletableFuture().join()).isNull(); //here is the point where the token expires assertThat(httpClient.isTokenValid()).isFalse(); assertThat(client.execute(ChannelByIdGet.of("channel-id")).toCompletableFuture().join()).isNull(); assertThat(httpClient.isTokenValid()).isTrue(); } }
@Test public void execution() throws Exception { withChannelOfRole(client(), INVENTORY_SUPPLY, channel -> { final String id = channel.getId(); final Channel fetchedChannel = client().executeBlocking(ChannelByIdGet.of(id)); assertThat(fetchedChannel).isEqualTo(channel); }); } }
@Test public void execution() throws Exception { final Channel channel = client().executeBlocking(ChannelCreateCommand.of(ChannelDraft.of(randomKey()))); client().executeBlocking(ChannelDeleteCommand.of(channel)); assertThat(client().executeBlocking(ChannelByIdGet.of(channel.getId()))).isNull(); } }