2121import org .springframework .aot .hint .RuntimeHints ;
2222
2323import static org .assertj .core .api .Assertions .assertThat ;
24+ import static org .assertj .core .api .Assertions .assertThatCode ;
2425import static org .springframework .aot .hint .predicate .RuntimeHintsPredicates .resource ;
2526
2627public class VectorStoreRuntimeHintsTests {
@@ -34,4 +35,39 @@ void vectorStoreRuntimeHints() {
3435 .matches (resource ().forResource ("antlr4/org/springframework/ai/vectorstore/filter/antlr4/Filters.g4" ));
3536 }
3637
38+ @ Test
39+ void registerHintsWithNullClassLoader () {
40+ var runtimeHints = new RuntimeHints ();
41+ var vectorStoreHints = new VectorStoreRuntimeHints ();
42+
43+ // Should not throw exception with null ClassLoader
44+ assertThatCode (() -> vectorStoreHints .registerHints (runtimeHints , null )).doesNotThrowAnyException ();
45+ }
46+
47+ @ Test
48+ void ensureResourceHintsAreRegistered () {
49+ var runtimeHints = new RuntimeHints ();
50+ var vectorStoreHints = new VectorStoreRuntimeHints ();
51+ vectorStoreHints .registerHints (runtimeHints , null );
52+
53+ // Ensure the specific ANTLR resource is registered
54+ assertThat (runtimeHints )
55+ .matches (resource ().forResource ("antlr4/org/springframework/ai/vectorstore/filter/antlr4/Filters.g4" ));
56+ }
57+
58+ @ Test
59+ void verifyResourceHintsForDifferentPaths () {
60+ var runtimeHints = new RuntimeHints ();
61+ var vectorStoreHints = new VectorStoreRuntimeHints ();
62+ vectorStoreHints .registerHints (runtimeHints , null );
63+
64+ // Test that the exact resource path is registered
65+ assertThat (runtimeHints )
66+ .matches (resource ().forResource ("antlr4/org/springframework/ai/vectorstore/filter/antlr4/Filters.g4" ));
67+
68+ // Verify that similar but incorrect paths are not matched
69+ assertThat (runtimeHints ).doesNotMatch (resource ().forResource ("antlr4/Filters.g4" ));
70+ assertThat (runtimeHints ).doesNotMatch (resource ().forResource ("org/springframework/ai/vectorstore/Filters.g4" ));
71+ }
72+
3773}
0 commit comments