|
|
|
@ -38,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; |
|
|
|
* Tests for {@link RegisterReflectionReflectiveProcessor}. |
|
|
|
* Tests for {@link RegisterReflectionReflectiveProcessor}. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Stephane Nicoll |
|
|
|
* @author Stephane Nicoll |
|
|
|
|
|
|
|
* @since 6.2 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class RegisterReflectionReflectiveProcessorTests { |
|
|
|
class RegisterReflectionReflectiveProcessorTests { |
|
|
|
|
|
|
|
|
|
|
|
@ -47,6 +48,7 @@ class RegisterReflectionReflectiveProcessorTests { |
|
|
|
|
|
|
|
|
|
|
|
private final RuntimeHints hints = new RuntimeHints(); |
|
|
|
private final RuntimeHints hints = new RuntimeHints(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nested |
|
|
|
@Nested |
|
|
|
class AnnotatedTypeTests { |
|
|
|
class AnnotatedTypeTests { |
|
|
|
|
|
|
|
|
|
|
|
@ -73,6 +75,7 @@ class RegisterReflectionReflectiveProcessorTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nested |
|
|
|
@Nested |
|
|
|
class AnnotatedMethodTests { |
|
|
|
class AnnotatedMethodTests { |
|
|
|
|
|
|
|
|
|
|
|
@ -88,11 +91,12 @@ class RegisterReflectionReflectiveProcessorTests { |
|
|
|
Method method = RegistrationMethodWithoutTarget.class.getDeclaredMethod("doReflection"); |
|
|
|
Method method = RegistrationMethodWithoutTarget.class.getDeclaredMethod("doReflection"); |
|
|
|
assertThatIllegalStateException() |
|
|
|
assertThatIllegalStateException() |
|
|
|
.isThrownBy(() -> registerReflectionHints(method)) |
|
|
|
.isThrownBy(() -> registerReflectionHints(method)) |
|
|
|
.withMessageContaining("At least one class must be specified, could not detect target from '") |
|
|
|
.withMessageContaining("At least one class must be specified") |
|
|
|
.withMessageContaining(method.toString()); |
|
|
|
.withMessageContaining(method.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void assertBasicTypeHint(Class<?> type, List<String> methodNames, List<MemberCategory> memberCategories) { |
|
|
|
private void assertBasicTypeHint(Class<?> type, List<String> methodNames, List<MemberCategory> memberCategories) { |
|
|
|
TypeHint typeHint = getTypeHint(type); |
|
|
|
TypeHint typeHint = getTypeHint(type); |
|
|
|
assertThat(typeHint.methods()).map(ExecutableHint::getName).hasSameElementsAs(methodNames); |
|
|
|
assertThat(typeHint.methods()).map(ExecutableHint::getName).hasSameElementsAs(methodNames); |
|
|
|
@ -120,31 +124,32 @@ class RegisterReflectionReflectiveProcessorTests { |
|
|
|
this.processor.registerReflectionHints(this.hints.reflection(), annotatedElement); |
|
|
|
this.processor.registerReflectionHints(this.hints.reflection(), annotatedElement); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RegisterReflection(classes = SimplePojo.class, memberCategories = MemberCategory.INVOKE_PUBLIC_METHODS) |
|
|
|
@RegisterReflection(classes = SimplePojo.class, memberCategories = MemberCategory.INVOKE_PUBLIC_METHODS) |
|
|
|
static class RegistrationSimple {} |
|
|
|
static class RegistrationSimple { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RegisterReflection(classes = { Number.class, Double.class }, |
|
|
|
@RegisterReflection(classes = { Number.class, Double.class }, |
|
|
|
classNames = { "java.lang.Integer", "java.lang.Float" }, memberCategories = MemberCategory.INVOKE_PUBLIC_METHODS) |
|
|
|
classNames = { "java.lang.Integer", "java.lang.Float" }, memberCategories = MemberCategory.INVOKE_PUBLIC_METHODS) |
|
|
|
static class RegistrationMultipleTargets { |
|
|
|
static class RegistrationMultipleTargets { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class RegistrationMethod { |
|
|
|
static class RegistrationMethod { |
|
|
|
|
|
|
|
|
|
|
|
@RegisterReflection(classes = SimplePojo.class, memberCategories = MemberCategory.INVOKE_DECLARED_METHODS) |
|
|
|
@RegisterReflection(classes = SimplePojo.class, memberCategories = MemberCategory.INVOKE_DECLARED_METHODS) |
|
|
|
private void doReflection() { |
|
|
|
private void doReflection() { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class RegistrationMethodWithoutTarget { |
|
|
|
static class RegistrationMethodWithoutTarget { |
|
|
|
|
|
|
|
|
|
|
|
@RegisterReflection(memberCategories = MemberCategory.INVOKE_DECLARED_CONSTRUCTORS) |
|
|
|
@RegisterReflection(memberCategories = MemberCategory.INVOKE_DECLARED_CONSTRUCTORS) |
|
|
|
private void doReflection() { |
|
|
|
private void doReflection() { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -171,6 +176,7 @@ class RegisterReflectionReflectiveProcessorTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RegisterReflection(memberCategories = MemberCategory.INVOKE_DECLARED_CONSTRUCTORS) |
|
|
|
@RegisterReflection(memberCategories = MemberCategory.INVOKE_DECLARED_CONSTRUCTORS) |
|
|
|
static class AnnotatedSimplePojo { |
|
|
|
static class AnnotatedSimplePojo { |
|
|
|
|
|
|
|
|
|
|
|
@ -179,8 +185,6 @@ class RegisterReflectionReflectiveProcessorTests { |
|
|
|
AnnotatedSimplePojo(String test) { |
|
|
|
AnnotatedSimplePojo(String test) { |
|
|
|
this.test = test; |
|
|
|
this.test = test; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|