### Question:
MoreStreams { public static <T, K, V, R> Collector<T, ?, R> flatMapping( Function<? super T, ? extends BiStream<? extends K, ? extends V>> flattener, BiCollector<K, V, R> downstream) { return BiStream.flatMapping( flattener.andThen(BiStream::mapToEntry), downstream.<Map.Entry<? extends K, ? extends V>>splitting( Map.Entry::getKey, Map.Entry::getValue)); } private  MoreStreams(); static Stream<T> generate(
      T seed, Function<? super T, ? extends Stream<? extends T>> step); static Stream<T> flatten(Stream<? extends Stream<? extends T>> streamOfStream); static Iterable<T> iterateOnce(Stream<T> stream); static void iterateThrough(
      Stream<? extends T> stream, CheckedConsumer<? super T, E> consumer); static Stream<List<T>> dice(Stream<? extends T> stream, int maxSize); static Spliterator<List<T>> dice(Spliterator<? extends T> spliterator, int maxSize); @Deprecated static Collector<Map<K, V>, ?, Map<K, V>> uniqueKeys(); static Collector<T, ?, R> flatMapping(
      Function<? super T, ? extends BiStream<? extends K, ? extends V>> flattener,
      BiCollector<K, V, R> downstream); @Deprecated static Collector<T, ?, R> flattening(
      Function<? super T, ? extends Collection<? extends Map.Entry<? extends K, ? extends V>>> flattener,
      BiCollector<K, V, R> downstream); static Collector<Map<K, V>, ?, R> flatteningMaps(
      BiCollector<K, V, R> downstream); static Collector<T, ?, List<T>> toListAndThen(Consumer<? super List<T>> arranger); static Stream<Integer> indexesFrom(int firstIndex); static Stream<T> whileNotNull(Supplier<? extends T> supplier); static Stream<T> withSideEffect(Stream<T> stream, Consumer<? super T> sideEffect); static Collector<T, ?, R> mapping(
      DualValuedFunction<? super T, ? extends K, ? extends V> mapper,
      BiCollector<K, V, R> downstream);  }### Answer:
@Test public void mergingValues_emptyMaps() { ImmutableList<Translation> translations = ImmutableList.of(new Translation(ImmutableMap.of()), new Translation(ImmutableMap.of())); Map<Integer, String> merged = translations.stream() .map(Translation::dictionary) .collect(flatMapping(BiStream::from, groupingBy((Integer k) -> k, (a, b) -> a + "," + b))) .collect(ImmutableMap::toImmutableMap); assertThat(merged).isEmpty(); }
@Test public void mergingValues_uniqueKeys() { ImmutableList<Translation> translations = ImmutableList.of( new Translation(ImmutableMap.of(1, "one")), new Translation(ImmutableMap.of(2, "two"))); Map<Integer, String> merged = translations.stream() .map(Translation::dictionary) .collect(flatMapping(BiStream::from, groupingBy((Integer k) -> k, (a, b) -> a + "," + b))) .collect(ImmutableMap::toImmutableMap); assertThat(merged) .containsExactly(1, "one", 2, "two") .inOrder(); }
@Test public void mergingValues_duplicateValues() { ImmutableList<Translation> translations = ImmutableList.of( new Translation(ImmutableMap.of(1, "one")), new Translation(ImmutableMap.of(2, "two", 1, "1"))); Map<Integer, String> merged = translations.stream() .map(Translation::dictionary) .collect(flatMapping(BiStream::from, groupingBy((Integer k) -> k, (a, b) -> a + "," + b))) .collect(ImmutableMap::toImmutableMap); assertThat(merged) .containsExactly(1, "one,1", 2, "two") .inOrder(); }