### Question:
Combinators { @SuppressWarnings("unchecked") public static <T> CompletionStage<Collection<T>> collect( final Collection<? extends CompletionStage<T>> stages) { return collect(stages, Collectors.toCollection(() -> new ArrayList<>(stages.size()))); } 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 testCombineEtAl() { for (final BiFunction<CompletionStage<?>, CompletionStage<?>, CompletionStage<Void>> combineMethod : Stream .<BiFunction<CompletionStage<?>, CompletionStage<?>, CompletionStage<Void>>>of( (a, b) -> a.thenCombine(b, CombinatorsTest.voidFunction()), (a, b) -> a.thenCombineAsync(b, CombinatorsTest.voidFunction()), (a, b) -> a.thenCombineAsync(b, CombinatorsTest.voidFunction(), ASYNC), (a, b) -> a.thenAcceptBoth(b, CombinatorsTest.voidConsumer()), (a, b) -> a.thenAcceptBothAsync(b, CombinatorsTest.voidConsumer()), (a, b) -> a.thenAcceptBothAsync(b, CombinatorsTest.voidConsumer(), ASYNC), (a, b) -> a.runAfterBoth(b, CombinatorsTest.voidRunnable()), (a, b) -> a.runAfterBothAsync(b, CombinatorsTest.voidRunnable()), (a, b) -> a.runAfterBothAsync(b, CombinatorsTest.voidRunnable(), ASYNC)) .flatMap(function -> Stream.of(function, (a, b) -> function.apply(b, a))) .collect(Collectors.toList())) { { final CompletionStage<String> doneNormal = getCompletedStage("a"); final CompletableStage<String> incompleteNormal = getCompletableStage(); final CompletionStage<Void> combine = combineMethod.apply(doneNormal, incompleteNormal); CombinatorsTest.assertIncomplete(combine); incompleteNormal.complete("b"); TestUtil.join(combine); } { final CompletionStage<String> doneExceptional = getExceptionalStage(new TestException()); final CompletableStage<String> incompleteNormal = getCompletableStage(); final CompletionStage<Void> combine = combineMethod.apply(doneExceptional, incompleteNormal); CombinatorsTest.assertIncomplete(combine); incompleteNormal.complete("b"); CombinatorsTest.assertError(combine); } } }