IsEquivalent extends TypeSafeMatcher<T> { @Override protected void describeMismatchSafely(final T item, final Description mismatchDescription) { mismatchDescription.appendValue(item).appendText(" is not equivalent to "); if (comparison == null) { mismatchDescription.appendText("null value"); } else { mismatchDescription.appendValue(comparison); } mismatchDescription.appendText(" according with Equivalence ").appendValue(equivalence); } IsEquivalent(final T comparison, final Equivalence<T> equivalence); static Matcher<T> equivalentTo(final T expected, final Equivalence<T> equivalence); @Override void describeTo(final Description description);  }
@Test public void testDescribeMismatchSafely() throws Exception { BaseMatcherTest.assertHasMismatchDescription(String.format( "<%s> is not equivalent to null value according with Equivalence <%s>", ASSERTED_OBJECT_TO_STRING_VAL, EQUIVALENCE_TO_STRING), isEquivalentMatcherForNullValue, assertedObject); BaseMatcherTest.assertHasMismatchDescription(String.format( "<%s> is not equivalent to <%s> according with Equivalence <%s>", ASSERTED_OBJECT_TO_STRING_VAL, COMPARISON_OBJECT_TO_STRING_VAL, EQUIVALENCE_TO_STRING), isEquivalentMatcher, assertedObject); }