IsClassWithAnnotation extends TypeSafeMatcher<Class> { @Override protected void describeMismatchSafely(final Class aClass, final Description mismatchDescription) { mismatchDescription.appendValue(aClass).appendText(" has not given annotation ").appendValue(annotation.toString()); } private  IsClassWithAnnotation(final Class<? extends Annotation> annotation); static Matcher<Class> hasRuntimeAnnotation(final Class<? extends Annotation> annotation); @Override void describeTo(final Description description);  }
@Test public void testDescribeMismatchSafely() throws Exception { assertHasMismatchDescription(format("<%s> has not given annotation \"%s\"", nonValidClass, runtimeAnnotation.toString()), isClassWithAnnotationMatcher, nonValidClass); }