@Test public void returnsContainerInstancesFromAllPages() { ECSAsyncClient ecs = mock(FakeECSAsyncClient.class, Mockito.CALLS_REAL_METHODS); ContainerInstanceLister containerInstances = new ContainerInstanceLister(ecs, CLUSTER_1); List<ClusterSnapshot.ContainerInstance> describe = containerInstances.describe().join(); assertThat( describe .stream() .map(ClusterSnapshot.ContainerInstance::getArn) .collect(Collectors.toList()), containsInAnyOrder("1", "2", "3", "4", "5", "6")); }
public CompletableFuture<List<ContainerInstance>> describe() { return new PaginatedResponseIterator<>(ListContainerInstancesResponse::nextToken, this::list) .stream() .map(ListContainerInstancesResponse::containerInstanceArns) .filter(arns -> !arns.isEmpty()) .map(this::describeContainerInstances) .collect(CompletableFutures.joinList()) .thenApply(this::extractContainerInstancesFromResponses); }
ContainerInstanceLister { public CompletableFuture<List<ContainerInstance>> describe() { return new PaginatedResponseIterator<>(ListContainerInstancesResponse::nextToken, this::list) .stream() .map(ListContainerInstancesResponse::containerInstanceArns) .filter(arns -> !arns.isEmpty()) .map(this::describeContainerInstances) .collect(CompletableFutures.joinList()) .thenApply(this::extractContainerInstancesFromResponses); } }
ContainerInstanceLister { public CompletableFuture<List<ContainerInstance>> describe() { return new PaginatedResponseIterator<>(ListContainerInstancesResponse::nextToken, this::list) .stream() .map(ListContainerInstancesResponse::containerInstanceArns) .filter(arns -> !arns.isEmpty()) .map(this::describeContainerInstances) .collect(CompletableFutures.joinList()) .thenApply(this::extractContainerInstancesFromResponses); } ContainerInstanceLister(ECSAsyncClient ecs, String clusterName); }
ContainerInstanceLister { public CompletableFuture<List<ContainerInstance>> describe() { return new PaginatedResponseIterator<>(ListContainerInstancesResponse::nextToken, this::list) .stream() .map(ListContainerInstancesResponse::containerInstanceArns) .filter(arns -> !arns.isEmpty()) .map(this::describeContainerInstances) .collect(CompletableFutures.joinList()) .thenApply(this::extractContainerInstancesFromResponses); } ContainerInstanceLister(ECSAsyncClient ecs, String clusterName); CompletableFuture<List<ContainerInstance>> describe(); }
ContainerInstanceLister { public CompletableFuture<List<ContainerInstance>> describe() { return new PaginatedResponseIterator<>(ListContainerInstancesResponse::nextToken, this::list) .stream() .map(ListContainerInstancesResponse::containerInstanceArns) .filter(arns -> !arns.isEmpty()) .map(this::describeContainerInstances) .collect(CompletableFutures.joinList()) .thenApply(this::extractContainerInstancesFromResponses); } ContainerInstanceLister(ECSAsyncClient ecs, String clusterName); CompletableFuture<List<ContainerInstance>> describe();  }