IsEquivalent extends TypeSafeMatcher<T> { public static <T> Matcher<T> equivalentTo(final T expected, final Equivalence<T> equivalence) { return new IsEquivalent<>(expected, 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 testGivenThatEquivalenceIsNullWhenCreateInstanceThenNullPointerExceptionIsThrown() { thrown.expect(NullPointerException.class); IsEquivalent.equivalentTo("", null); fail("NullPointerException expected but not thrown"); }
@Test public void testGivenThatComparisonIsNullWhenCreateInstanceNothingIsThrown() { final Matcher matcher = IsEquivalent.equivalentTo(null, equivalence); assertThat(matcher, not(is(nullValue()))); }