21
21
import org .springframework .aot .hint .RuntimeHints ;
22
22
23
23
import static org .assertj .core .api .Assertions .assertThat ;
24
+ import static org .assertj .core .api .Assertions .assertThatCode ;
24
25
import static org .springframework .aot .hint .predicate .RuntimeHintsPredicates .resource ;
25
26
26
27
public class VectorStoreRuntimeHintsTests {
@@ -34,4 +35,39 @@ void vectorStoreRuntimeHints() {
34
35
.matches (resource ().forResource ("antlr4/org/springframework/ai/vectorstore/filter/antlr4/Filters.g4" ));
35
36
}
36
37
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
+
37
73
}
0 commit comments