public void testNewSortedSetMultimap() { CountingSupplier<TreeSet<Integer>> factory = new SortedSetSupplier(); Map<Color, Collection<Integer>> map = Maps.newEnumMap(Color.class); SortedSetMultimap<Color, Integer> multimap = Multimaps.newSortedSetMultimap(map, factory); // newSortedSetMultimap calls the factory once to determine the comparator. assertEquals(1, factory.count); multimap.putAll(Color.BLUE, asList(3, 1, 4)); assertEquals(2, factory.count); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); assertEquals(3, factory.count); assertEquals("[4, 3, 1]", multimap.get(Color.BLUE).toString()); assertEquals(INT_COMPARATOR, multimap.valueComparator()); }
public void testNewSortedSetMultimap() { CountingSupplier<TreeSet<Integer>> factory = new SortedSetSupplier(); Map<Color, Collection<Integer>> map = Maps.newEnumMap(Color.class); SortedSetMultimap<Color, Integer> multimap = Multimaps.newSortedSetMultimap(map, factory); // newSortedSetMultimap calls the factory once to determine the comparator. assertEquals(1, factory.count); multimap.putAll(Color.BLUE, asList(3, 1, 4)); assertEquals(2, factory.count); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); assertEquals(3, factory.count); assertEquals("[4, 3, 1]", multimap.get(Color.BLUE).toString()); assertEquals(INT_COMPARATOR, multimap.valueComparator()); }
@GwtIncompatible // SerializableTester public void testNewSortedSetMultimapSerialization() { CountingSupplier<TreeSet<Integer>> factory = new SortedSetSupplier(); Map<Color, Collection<Integer>> map = Maps.newEnumMap(Color.class); SortedSetMultimap<Color, Integer> multimap = Multimaps.newSortedSetMultimap(map, factory); multimap.putAll(Color.BLUE, asList(3, 1, 4)); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); SerializableTester.reserializeAndAssert(multimap); assertEquals(INT_COMPARATOR, multimap.valueComparator()); }
public void testNewMultimapValueCollectionMatchesNavigableSet() { Supplier<TreeSet<Integer>> factory = new SortedSetSupplier(); Map<Color, Collection<Integer>> map = Maps.newEnumMap(Color.class); Multimap<Color, Integer> multimap = Multimaps.newMultimap(map, factory); assertTrue(multimap.get(Color.BLUE) instanceof NavigableSet); }
@GwtIncompatible // SerializableTester public void testNewSortedSetMultimapSerialization() { CountingSupplier<TreeSet<Integer>> factory = new SortedSetSupplier(); Map<Color, Collection<Integer>> map = Maps.newEnumMap(Color.class); SortedSetMultimap<Color, Integer> multimap = Multimaps.newSortedSetMultimap(map, factory); multimap.putAll(Color.BLUE, asList(3, 1, 4)); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); SerializableTester.reserializeAndAssert(multimap); assertEquals(INT_COMPARATOR, multimap.valueComparator()); }