@Test public void returnsEmptyListWhenNoContainerInstances() { ECSAsyncClient ecs = mock(ECSAsyncClient.class); when(ecs.listContainerInstances(any())) .thenReturn( CompletableFuture.completedFuture( ListContainerInstancesResponse.builder().containerInstanceArns().build())); ContainerInstanceLister containerInstances = new ContainerInstanceLister(ecs, CLUSTER_1); List<ClusterSnapshot.ContainerInstance> describe = containerInstances.describe().join(); assertThat(describe, empty()); }
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();  }