Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.springframework.aot.hint.RuntimeHints;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.springframework.aot.hint.predicate.RuntimeHintsPredicates.resource;

public class VectorStoreRuntimeHintsTests {
Expand All @@ -34,4 +35,39 @@ void vectorStoreRuntimeHints() {
.matches(resource().forResource("antlr4/org/springframework/ai/vectorstore/filter/antlr4/Filters.g4"));
}

@Test
void registerHintsWithNullClassLoader() {
var runtimeHints = new RuntimeHints();
var vectorStoreHints = new VectorStoreRuntimeHints();

// Should not throw exception with null ClassLoader
assertThatCode(() -> vectorStoreHints.registerHints(runtimeHints, null)).doesNotThrowAnyException();
}

@Test
void ensureResourceHintsAreRegistered() {
var runtimeHints = new RuntimeHints();
var vectorStoreHints = new VectorStoreRuntimeHints();
vectorStoreHints.registerHints(runtimeHints, null);

// Ensure the specific ANTLR resource is registered
assertThat(runtimeHints)
.matches(resource().forResource("antlr4/org/springframework/ai/vectorstore/filter/antlr4/Filters.g4"));
}

@Test
void verifyResourceHintsForDifferentPaths() {
var runtimeHints = new RuntimeHints();
var vectorStoreHints = new VectorStoreRuntimeHints();
vectorStoreHints.registerHints(runtimeHints, null);

// Test that the exact resource path is registered
assertThat(runtimeHints)
.matches(resource().forResource("antlr4/org/springframework/ai/vectorstore/filter/antlr4/Filters.g4"));

// Verify that similar but incorrect paths are not matched
assertThat(runtimeHints).doesNotMatch(resource().forResource("antlr4/Filters.g4"));
assertThat(runtimeHints).doesNotMatch(resource().forResource("org/springframework/ai/vectorstore/Filters.g4"));
}

}