### Question:
Combinators { @SuppressWarnings("unchecked") public static CompletionStage<Void> allOf( final Collection<? extends CompletionStage<?>> stages) { final Iterator<? extends CompletionStage<?>> backingIt = stages.iterator(); final int size = stages.size(); final Iterator<? extends CompletionStage<?>> it = size > MAX_DEPENDANT_DEPTH ? new Iterator<CompletionStage<?>>() { @Override public boolean hasNext() { return backingIt.hasNext(); } @Override public CompletionStage<?> next() { return backingIt.next().toCompletableFuture(); } } : backingIt; return allOfImpl(it); } private  Combinators(); @SuppressWarnings("unchecked") static CompletionStage<Void> allOf(
      final Collection<? extends CompletionStage<?>> stages); @SuppressWarnings("unchecked") static CompletionStage<Collection<T>> collect(
      final Collection<? extends CompletionStage<T>> stages); @SuppressWarnings("unchecked") static CompletionStage<R> collect(
      final Collection<? extends CompletionStage<T>> stages,
      final Collector<? super T, A, R> collector); @SuppressWarnings("unchecked") static CompletionStage<Map<K, V>> keyedAll(
      final Map<K, ? extends CompletionStage<V>> stageMap);  }### Answer:
@Test public void testAllOf() { final List<Integer> results = Arrays.asList(1, 2, 3); final List<CompletionStage<Integer>> collect = results.stream().map(this::getCompletedStage).collect(Collectors.toList()); TestUtil.join(Combinators.allOf(collect)); Assert.assertArrayEquals(results.toArray(), TestUtil.join(Combinators.collect(collect)).toArray()); Assert.assertArrayEquals(results.toArray(), TestUtil.join(Combinators.collect(collect, Collectors.toList())).toArray()); }