IsMultimapWithKeySetSize extends TypeSafeMatcher<Multimap<K, ?>> { @Override public void describeTo(final Description description) { if (size == 0) { description.appendText("a Multimap with no elements"); } else { description.appendText("a Multimap with ").appendValue(size).appendText(" elements"); } } IsMultimapWithKeySetSize(final int size); static Matcher<Multimap<K, ?>> emptyKeySet(); static Matcher<Multimap<K, ?>> keySetWithSize(final int size); @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 testDescribeTo() throws Exception { BaseMatcherTest.assertIsDescribedTo("a Multimap with no elements", isMultimapElementWithCollectionEmptyMatcher); BaseMatcherTest.assertIsDescribedTo(String.format("a Multimap with <%d> elements", expectedCountGeneralMatcher), isMultimapElementWithCollectionSizeMatcher); }