Skip to content

Commit 450cac4

Browse files
authored
test: Add comprehensive test coverage for VectorStore runtime hints registration (#4015)
Signed-off-by: Alex Klimenko <[email protected]>
1 parent dcf4276 commit 450cac4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

spring-ai-vector-store/src/test/java/org/springframework/ai/vectorstore/aot/VectorStoreRuntimeHintsTests.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.springframework.aot.hint.RuntimeHints;
2222

2323
import static org.assertj.core.api.Assertions.assertThat;
24+
import static org.assertj.core.api.Assertions.assertThatCode;
2425
import static org.springframework.aot.hint.predicate.RuntimeHintsPredicates.resource;
2526

2627
public 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

Comments
 (0)