@Test public void markerClassSupport() { ControllerAdviceBean bean = new ControllerAdviceBean(new MarkerClassSupport()); assertApplicable("base package class support", bean, AnnotatedController.class); assertApplicable("base package class support", bean, ImplementationController.class); assertApplicable("base package class support", bean, InheritanceController.class); assertNotApplicable("bean not in package", bean, String.class); }
@Test public void shouldNotMatch() { ControllerAdviceBean bean = new ControllerAdviceBean(new ShouldNotMatch()); assertNotApplicable("should not match", bean, AnnotatedController.class); assertNotApplicable("should not match", bean, ImplementationController.class); assertNotApplicable("should not match", bean, InheritanceController.class); assertNotApplicable("should not match", bean, String.class); }
@Test public void shouldMatchAll() { ControllerAdviceBean bean = new ControllerAdviceBean(new SimpleControllerAdvice()); assertApplicable("should match all", bean, AnnotatedController.class); assertApplicable("should match all", bean, ImplementationController.class); assertApplicable("should match all", bean, InheritanceController.class); assertApplicable("should match all", bean, String.class); }
@Test public void basePackageSupport() { ControllerAdviceBean bean = new ControllerAdviceBean(new BasePackageSupport()); assertApplicable("base package support", bean, AnnotatedController.class); assertApplicable("base package support", bean, ImplementationController.class); assertApplicable("base package support", bean, InheritanceController.class); assertNotApplicable("bean not in package", bean, String.class); }
@Test public void basePackageValueSupport() { ControllerAdviceBean bean = new ControllerAdviceBean(new BasePackageValueSupport()); assertApplicable("base package support", bean, AnnotatedController.class); assertApplicable("base package support", bean, ImplementationController.class); assertApplicable("base package support", bean, InheritanceController.class); assertNotApplicable("bean not in package", bean, String.class); }
@Test public void assignableTypesSupport() { ControllerAdviceBean bean = new ControllerAdviceBean(new AssignableTypesSupport()); assertApplicable("controller implements assignable", bean, ImplementationController.class); assertApplicable("controller inherits assignable", bean, InheritanceController.class); assertNotApplicable("not assignable", bean, AnnotatedController.class); assertNotApplicable("not assignable", bean, String.class); }
@Test public void multipleMatch() { ControllerAdviceBean bean = new ControllerAdviceBean(new MultipleSelectorsSupport()); assertApplicable("controller implements assignable", bean, ImplementationController.class); assertApplicable("controller is annotated", bean, AnnotatedController.class); assertNotApplicable("should not match", bean, InheritanceController.class); }
@Test public void annotationSupport() { ControllerAdviceBean bean = new ControllerAdviceBean(new AnnotationSupport()); assertApplicable("annotation support", bean, AnnotatedController.class); assertNotApplicable("this bean is not annotated", bean, InheritanceController.class); }