IsSubsetOfIterable extends TypeSafeMatcher<Iterable<? super K>> { @Override public void describeMismatchSafely(final Iterable<? super K> iterable, final Description mismatchDescription) { mismatchDescription.appendText("iterable was ").appendValueList("[", ", ", "]", listCopy(iterable)) .appendText(", but the following elements ").appendValueList("[", ", ", "]", notContained(iterable, comparisonIterable)) .appendText(" are not in the superset"); } IsSubsetOfIterable(final Iterable<? super K> comparison); static Matcher<Iterable<K>> subsetOf(final Iterable<? super K> comparison); @Override boolean matchesSafely(final Iterable<? super K> actual); @Override void describeMismatchSafely(final Iterable<? super K> iterable, final Description mismatchDescription); @Override void describeTo(final Description description);  }
@Test public void testDescribeMismatchSafely() throws Exception { BaseMatcherTest.assertHasMismatchDescription( "iterable was [<1>, <1>, <3>], but the following elements [<3>] are not in the superset", IsSubsetOfIterable.subsetOf(ImmutableList.of(1, 2)), ImmutableList.of(1, 1, 3)); }