IsIterableContained 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("[", ", ", "]", notRepeated(iterable, comparisonIterable)) .appendText(" are not present or repeated with less frequency in the comparison iterable"); } IsIterableContained(final Iterable<? super K> comparison); static Matcher<Iterable<K>> containedIn(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>, <2>], but the following elements [<1>] are not present or repeated with less frequency in the comparison iterable", IsIterableContained.containedIn(ImmutableList.of(1, 2)), ImmutableList.of(1, 1, 2)); }