public void testConstrainedTypePreservingSortedSet() { Comparator<Integer> comparator = Collections.reverseOrder(); SortedSetMultimap<String, Integer> delegate = TreeMultimap.create(Ordering.<String>natural(), comparator); SortedSetMultimap<String, Integer> multimap = MapConstraints.constrainedSortedSetMultimap(delegate, TEST_CONSTRAINT); multimap.put("foo", 1); Map.Entry<String, Collection<Integer>> entry = multimap.asMap().entrySet().iterator().next(); assertTrue(entry.getValue() instanceof SortedSet); assertSame(comparator, multimap.valueComparator()); assertSame(comparator, multimap.get("foo").comparator()); }