Polish RuntimeHintsPredicates

This commit adds a method variant checking that all `MemberCategory` are
supported by the `RuntimeHints` for a given type hint.

See gh-28555
This commit is contained in:
Brian Clozel
2022-06-13 18:27:45 +02:00
parent dc3ec5b665
commit 15b69a3ede
2 changed files with 25 additions and 0 deletions

View File

@@ -98,6 +98,21 @@ class ReflectionHintsPredicatesTests {
assertPredicateDoesNotMatch(reflection.onType(SampleClass.class).withMemberCategory(MemberCategory.INVOKE_PUBLIC_METHODS));
}
@Test
void typeWithMemberCategoriesMatchesCategories() {
runtimeHints.reflection().registerType(SampleClass.class, builder ->
builder.withMembers(MemberCategory.INTROSPECT_PUBLIC_CONSTRUCTORS, MemberCategory.INTROSPECT_PUBLIC_METHODS));
assertPredicateMatches(reflection.onType(SampleClass.class)
.withMemberCategories(MemberCategory.INTROSPECT_PUBLIC_CONSTRUCTORS, MemberCategory.INTROSPECT_PUBLIC_METHODS));
}
@Test
void typeWithMemberCategoriesDoesNotMatchMissingCategory() {
runtimeHints.reflection().registerType(SampleClass.class, builder -> builder.withMembers(MemberCategory.INTROSPECT_PUBLIC_METHODS));
assertPredicateDoesNotMatch(reflection.onType(SampleClass.class)
.withMemberCategories(MemberCategory.INTROSPECT_PUBLIC_CONSTRUCTORS, MemberCategory.INTROSPECT_PUBLIC_METHODS));
}
@Test
void typeWithAnyMemberCategoryFailsWithNullCategories() {
runtimeHints.reflection().registerType(SampleClass.class, builder -> builder.withMembers(MemberCategory.INTROSPECT_PUBLIC_METHODS));