IsClassWithAnnotation extends TypeSafeMatcher<Class> { public static Matcher<Class> hasRuntimeAnnotation(final Class<? extends Annotation> annotation) { return new IsClassWithAnnotation(annotation); } 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 testGivenNullAnnotationThenIllegalArgumentExceptionIsThrown() throws Exception { thrown.expect(NullPointerException.class); IsClassWithAnnotation.hasRuntimeAnnotation(null); fail("NullPointerException expected"); }
@Test public void testGivenNonRuntimeAvailableAnnotationThenIllegalArgumentExceptionIsThrown() throws Exception { thrown.expect(IllegalArgumentException.class); IsClassWithAnnotation.hasRuntimeAnnotation(sourceCodeAnnotation); fail("IllegalArgumentException expected"); }