@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.MemberCategory ;
import org.springframework.aot.hint.MemberCategory ;
import org.springframework.aot.hint.ReflectionHints ;
import org.springframework.aot.hint.ReflectionHints ;
import org.springframework.aot.hint.RuntimeHints ;
import org.springframework.aot.hint.RuntimeHints ;
import org.springframework.aot.hint.TypeHint ;
import org.springframework.aot.hint.TypeReference ;
import org.springframework.aot.hint.TypeReference ;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates ;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates ;
import org.springframework.core.annotation.AliasFor ;
import org.springframework.core.annotation.AliasFor ;
@ -40,6 +41,7 @@ import static org.mockito.Mockito.verifyNoInteractions;
* Tests for { @link ReflectiveRuntimeHintsRegistrar } .
* Tests for { @link ReflectiveRuntimeHintsRegistrar } .
*
*
* @author Stephane Nicoll
* @author Stephane Nicoll
* @author Andy Wilkinson
* /
* /
class ReflectiveRuntimeHintsRegistrarTests {
class ReflectiveRuntimeHintsRegistrarTests {
@ -61,6 +63,14 @@ class ReflectiveRuntimeHintsRegistrarTests {
. isNotNull ( ) ;
. isNotNull ( ) ;
}
}
@Test
void shouldProcessWithMultipleProcessorsWithAnnotationOnType ( ) {
process ( SampleMultipleCustomProcessors . class ) ;
TypeHint typeHint = this . runtimeHints . reflection ( ) . getTypeHint ( SampleMultipleCustomProcessors . class ) ;
assertThat ( typeHint ) . isNotNull ( ) ;
assertThat ( typeHint . getMemberCategories ( ) ) . containsExactly ( MemberCategory . INVOKE_DECLARED_METHODS ) ;
}
@Test
@Test
void shouldProcessAnnotationOnConstructor ( ) {
void shouldProcessAnnotationOnConstructor ( ) {
process ( SampleConstructorAnnotatedBean . class ) ;
process ( SampleConstructorAnnotatedBean . class ) ;
@ -236,6 +246,14 @@ class ReflectiveRuntimeHintsRegistrarTests {
}
}
@Target ( { ElementType . TYPE } )
@Retention ( RetentionPolicy . RUNTIME )
@Documented
@Reflective ( TestTypeHintReflectiveProcessor . class )
@interface ReflectiveWithCustomProcessor {
}
interface SampleInterface {
interface SampleInterface {
@Reflective
@Reflective
@ -251,14 +269,24 @@ class ReflectiveRuntimeHintsRegistrarTests {
static class SampleCustomProcessor {
static class SampleCustomProcessor {
@Reflective ( TestReflectiveProcessor . class )
@Reflective ( TestMethodHintReflectiveProcessor . class )
public String managed ( ) {
return "test" ;
}
}
@Reflective
@ReflectiveWithCustomProcessor
static class SampleMultipleCustomProcessors {
public String managed ( ) {
public String managed ( ) {
return "test" ;
return "test" ;
}
}
}
}
private static class TestReflectiveProcessor extends SimpleReflectiveProcessor {
private static class TestMethodHint ReflectiveProcessor extends SimpleReflectiveProcessor {
@Override
@Override
protected void registerMethodHint ( ReflectionHints hints , Method method ) {
protected void registerMethodHint ( ReflectionHints hints , Method method ) {
@ -268,4 +296,14 @@ class ReflectiveRuntimeHintsRegistrarTests {
}
}
private static class TestTypeHintReflectiveProcessor extends SimpleReflectiveProcessor {
@Override
protected void registerTypeHint ( ReflectionHints hints , Class < ? > type ) {
super . registerTypeHint ( hints , type ) ;
hints . registerType ( type , MemberCategory . INVOKE_DECLARED_METHODS ) ;
}
}
}
}