// Path: mug/src/main/java/com/google/mu/util/stream/BiCollection.java
// public static <T, L, R> Collector<T, ?, BiCollection<L, R>> toBiCollection(
//     Function<? super T, ? extends L> leftFunction,
//     Function<? super T, ? extends R> rightFunction) {
//   requireNonNull(leftFunction);
//   requireNonNull(rightFunction);
//   Function<T, Map.Entry<L, R>> toEntry = x -> kv(leftFunction.apply(x), rightFunction.apply(x));
//   Collector<T, ?, ? extends Collection<Map.Entry<L, R>>> entryCollector =
//       Collectors.mapping(toEntry, Collectors.toList());
//   return Collectors.collectingAndThen(entryCollector, BiCollection::new);
// }


import static com.google.common.truth.Truth.assertThat;
import static com.google.mu.util.stream.BiCollection.toBiCollection;
import static java.util.Arrays.asList;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import com.google.common.truth.MultimapSubject;
  }

  @Test public void twoPairsSameKey() {
    assertKeyValues(BiCollection.of(1, "1.1", 1, "1.2"))
        .containsExactlyEntriesIn(ImmutableListMultimap.of(1, "1.1", 1, "1.2"))
        .inOrder();
  }

  @Test public void threePairs() {
    assertKeyValues(BiCollection.of(1, "one", 2, "two", 3, "three"))
        .containsExactlyEntriesIn(ImmutableListMultimap.of(1, "one", 2, "two", 3, "three"))
        .inOrder();
  }

  @Test public void fourPairs() {
    assertKeyValues(BiCollection.of(1, "1", 2, "2", 3, "3", 4, "4"))
        .containsExactlyEntriesIn(ImmutableListMultimap.of(1, "1", 2, "2", 3, "3", 4, "4"))
        .inOrder();
  }

  @Test public void fivePairs() {
    assertKeyValues(BiCollection.of(1, "1", 2, "2", 3, "3", 4, "4", 5, "5"))
        .containsExactlyEntriesIn(ImmutableListMultimap.of(1, "1", 2, "2", 3, "3", 4, "4", 5, "5"))
        .inOrder();
  }

  @Test public void toBiCollectionWithoutCollectorStrategy() {
    BiCollection<Integer, String> biCollection = ImmutableMap.of(1, "one", 2, "two")
        .entrySet()
        .stream()
// Path: mug/src/main/java/com/google/mu/util/stream/BiCollection.java
// public static <T, L, R> Collector<T, ?, BiCollection<L, R>> toBiCollection(
//     Function<? super T, ? extends L> leftFunction,
//     Function<? super T, ? extends R> rightFunction) {
//   requireNonNull(leftFunction);
//   requireNonNull(rightFunction);
//   Function<T, Map.Entry<L, R>> toEntry = x -> kv(leftFunction.apply(x), rightFunction.apply(x));
//   Collector<T, ?, ? extends Collection<Map.Entry<L, R>>> entryCollector =
//       Collectors.mapping(toEntry, Collectors.toList());
//   return Collectors.collectingAndThen(entryCollector, BiCollection::new);
// }


// Path: mug/src/test/java/com/google/mu/util/stream/BiCollectionTest.java
import static com.google.common.truth.Truth.assertThat;
import static com.google.mu.util.stream.BiCollection.toBiCollection;
import static java.util.Arrays.asList;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import com.google.common.truth.MultimapSubject;

  }

  @Test public void twoPairsSameKey() {
    assertKeyValues(BiCollection.of(1, "1.1", 1, "1.2"))
        .containsExactlyEntriesIn(ImmutableListMultimap.of(1, "1.1", 1, "1.2"))
        .inOrder();
  }

  @Test public void threePairs() {
    assertKeyValues(BiCollection.of(1, "one", 2, "two", 3, "three"))
        .containsExactlyEntriesIn(ImmutableListMultimap.of(1, "one", 2, "two", 3, "three"))
        .inOrder();
  }

  @Test public void fourPairs() {
    assertKeyValues(BiCollection.of(1, "1", 2, "2", 3, "3", 4, "4"))
        .containsExactlyEntriesIn(ImmutableListMultimap.of(1, "1", 2, "2", 3, "3", 4, "4"))
        .inOrder();
  }

  @Test public void fivePairs() {
    assertKeyValues(BiCollection.of(1, "1", 2, "2", 3, "3", 4, "4", 5, "5"))
        .containsExactlyEntriesIn(ImmutableListMultimap.of(1, "1", 2, "2", 3, "3", 4, "4", 5, "5"))
        .inOrder();
  }

  @Test public void toBiCollectionWithoutCollectorStrategy() {
    BiCollection<Integer, String> biCollection = ImmutableMap.of(1, "one", 2, "two")
        .entrySet()
        .stream()
        .collect(toBiCollection(Map.Entry::getKey, Map.Entry::getValue));