Exemplo n.º 1
0
 public void testToImmutableBiMap_exceptionOnDuplicateKey() {
   Collector<Entry<String, Integer>, ?, ImmutableBiMap<String, Integer>> collector =
       ImmutableBiMap.toImmutableBiMap(Entry::getKey, Entry::getValue);
   try {
     Stream.of(mapEntry("one", 1), mapEntry("one", 11)).collect(collector);
     fail("Expected IllegalArgumentException");
   } catch (IllegalArgumentException expected) {
   }
 }
Exemplo n.º 2
0
 public void testToImmutableBiMap() {
   Collector<Entry<String, Integer>, ?, ImmutableBiMap<String, Integer>> collector =
       ImmutableBiMap.toImmutableBiMap(Entry::getKey, Entry::getValue);
   Equivalence<ImmutableBiMap<String, Integer>> equivalence =
       Equivalence.equals()
           .<Entry<String, Integer>>pairwise()
           .onResultOf(ImmutableBiMap::entrySet);
   CollectorTester.of(collector, equivalence)
       .expectCollects(
           ImmutableBiMap.of("one", 1, "two", 2, "three", 3),
           mapEntry("one", 1),
           mapEntry("two", 2),
           mapEntry("three", 3));
 }