### Question:
Combinators { @SuppressWarnings("unchecked") public static <K, V> CompletionStage<Map<K, V>> keyedAll( final Map<K, ? extends CompletionStage<V>> stageMap) { return Combinators .allOf(stageMap.values()) .thenApply(ignore -> stageMap.entrySet().stream() .collect(Collectors.toMap( e -> e.getKey(), e -> e.getValue().toCompletableFuture().join()))); } 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 testKeyedAll() { final Map<Integer, CompletionStage<Integer>> stageMap = IntStream.range(0, 5) .boxed() .collect(Collectors.toMap(Function.identity(), this::getCompletedStage)); final Map<Integer, Integer> integerMap = TestUtil.join(Combinators.keyedAll(stageMap)); Assert.assertEquals(5, integerMap.size()); Assert.assertTrue( integerMap.entrySet().stream().allMatch(entry -> entry.getKey().equals(entry.getValue()))); }