IsMultimapWithKeySet extends TypeSafeMatcher<Multimap<K, ?>> { @Override public void describeMismatchSafely(final Multimap<K, ?> multimap, final Description mismatchDescription) { mismatchDescription.appendText("Multimap key set was ").appendValueList("[", ", ", "]", multimap.keySet()); } IsMultimapWithKeySet(final Set<K> comparisonSet); static Matcher<Multimap<K, ?>> hasSameKeySet(final Multimap<K, ?> comparison); static Matcher<Multimap<K, ?>> hasSameKeySet(final Set<K> comparison); @Override boolean matchesSafely(final Multimap<K, ?> actual); @Override void describeMismatchSafely(final Multimap<K, ?> multimap, final Description mismatchDescription); @Override void describeTo(final Description description);  }
@Test public void testDescribeMismatchSafely() throws Exception { BaseMatcherTest.assertHasMismatchDescription("Multimap key set was []", isMultimapWithKeySetByMultimapMatcher, multimap); BaseMatcherTest.assertHasMismatchDescription("Multimap key set was []", isMultimapWithKeySetBySetMatcher, multimap); }