ControllerUtils { public static boolean isControllerMethod(Method method) { boolean isController = AnnotationUtils.getAnnotation(method.getDeclaringClass(), Controller.class) != null || AnnotationUtils.getAnnotation(method, Controller.class) != null; return isController && isRequestMethod(method); } private  ControllerUtils(); static boolean isController(Class<?> clazz); static boolean isControllerMethod(Method method);  }
@Test public void shouldIdentifyControllerMethods() throws NoSuchMethodException { assertThat(ControllerUtils.isControllerMethod(ClassController.class.getMethod("foo")), is(false)); assertThat(ControllerUtils.isControllerMethod(ClassController.class.getMethod("bar")), is(true)); assertThat(ControllerUtils.isControllerMethod(MethodController.class.getMethod("foo")), is(false)); assertThat(ControllerUtils.isControllerMethod(MethodController.class.getMethod("bar")), is(true)); assertThat(ControllerUtils.isControllerMethod(NoController.class.getMethod("foo")), is(false)); assertThat(ControllerUtils.isControllerMethod(NoController.class.getMethod("bar")), is(false)); }