Add RuntimeHints predicates generator
The `RuntimeHints` API allows to describe hints for the reflection, proxies and resources behavior at runtime. The need for a particular behavior can be covered by several types of hints, at different levels. This knowledge can be important in several cases: * before contributing additional hints, infrastructure can check if an existing hint already covers the behavior * this can be used in test suites and test infrastructure This commit adds a new RuntimeHintsPredicates that generates `Predicate` instances for testing `RuntimeHints` against a desired runtime behavior for reflection, resources or proxies. Closes gh-28555
This commit is contained in:
@@ -28,8 +28,8 @@ import javax.lang.model.element.Modifier;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.generate.GeneratedMethods;
|
||||
import org.springframework.aot.hint.ExecutableMode;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsPredicates;
|
||||
import org.springframework.aot.test.generator.compile.Compiled;
|
||||
import org.springframework.aot.test.generator.compile.TestCompiler;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -277,15 +277,8 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
||||
}
|
||||
|
||||
private void assertHasMethodInvokeHints(Class<?> beanType, String... methodNames) {
|
||||
assertThat(this.hints.reflection().getTypeHint(beanType)).satisfies(typeHint -> {
|
||||
for (String methodName : methodNames) {
|
||||
assertThat(typeHint.methods()).anySatisfy(methodHint -> {
|
||||
assertThat(methodHint.getName()).isEqualTo(methodName);
|
||||
assertThat(methodHint.getModes())
|
||||
.containsExactly(ExecutableMode.INVOKE);
|
||||
});
|
||||
}
|
||||
});
|
||||
assertThat(methodNames).allMatch(methodName ->
|
||||
RuntimeHintsPredicates.reflection().onMethod(beanType, methodName).invoke().test(this.hints));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user