@Test public void returnsTasksFromAllPages() { ECSAsyncClient ecs = mock(FakeECSAsyncClient.class, Mockito.CALLS_REAL_METHODS); TaskLister tasks = new TaskLister(ecs, CLUSTER_ARN); List<ClusterSnapshot.Task> describe = tasks.describe().join(); assertThat( describe.stream().map(ClusterSnapshot.Task::getArn).collect(Collectors.toList()), containsInAnyOrder("1", "2", "3", "4", "5", "6")); }
public CompletableFuture<List<Task>> describe() { return new PaginatedResponseIterator<>(ListTasksResponse::nextToken, this::list) .stream() .map(ListTasksResponse::taskArns) .filter(arns -> !arns.isEmpty()) .map(this::describeTasks) .collect(CompletableFutures.joinList()) .thenApply(this::extractTasksFromResponses); }
TaskLister { public CompletableFuture<List<Task>> describe() { return new PaginatedResponseIterator<>(ListTasksResponse::nextToken, this::list) .stream() .map(ListTasksResponse::taskArns) .filter(arns -> !arns.isEmpty()) .map(this::describeTasks) .collect(CompletableFutures.joinList()) .thenApply(this::extractTasksFromResponses); } }
TaskLister { public CompletableFuture<List<Task>> describe() { return new PaginatedResponseIterator<>(ListTasksResponse::nextToken, this::list) .stream() .map(ListTasksResponse::taskArns) .filter(arns -> !arns.isEmpty()) .map(this::describeTasks) .collect(CompletableFutures.joinList()) .thenApply(this::extractTasksFromResponses); } TaskLister(ECSAsyncClient ecs, String clusterName); }
TaskLister { public CompletableFuture<List<Task>> describe() { return new PaginatedResponseIterator<>(ListTasksResponse::nextToken, this::list) .stream() .map(ListTasksResponse::taskArns) .filter(arns -> !arns.isEmpty()) .map(this::describeTasks) .collect(CompletableFutures.joinList()) .thenApply(this::extractTasksFromResponses); } TaskLister(ECSAsyncClient ecs, String clusterName); CompletableFuture<List<Task>> describe(); }
TaskLister { public CompletableFuture<List<Task>> describe() { return new PaginatedResponseIterator<>(ListTasksResponse::nextToken, this::list) .stream() .map(ListTasksResponse::taskArns) .filter(arns -> !arns.isEmpty()) .map(this::describeTasks) .collect(CompletableFutures.joinList()) .thenApply(this::extractTasksFromResponses); } TaskLister(ECSAsyncClient ecs, String clusterName); CompletableFuture<List<Task>> describe();  }