BeanExaminer { static boolean isRestHandler(Object bean) { requireNonNull(bean, "bean to examine must not be null"); return stream(bean.getClass().getAnnotations()) .anyMatch(interestingAnnotation); } private  BeanExaminer();   }
@Test void properlyDetectsRestEndpoints() { @Path("m1") class MyRestClass1 { @GET public void m1(String p1) { } public void m2(String p1) { } } class MyNonRestClass1 { @Path("m1") public void m1(String p1) { } } assertThat(BeanExaminer.isRestHandler(new MyRestClass1()), Matchers.is(true)); assertThat(BeanExaminer.isRestHandler(new MyNonRestClass1()), Matchers.is(false)); }
@Test void needsNonNullBean() throws Exception { Throwable t = Assertions.assertThrows(NullPointerException.class, () -> BeanExaminer.isRestHandler(null) ); MatcherAssert.assertThat(t.getMessage(), Matchers.containsString("bean")); }