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 @@ -56,4 +56,66 @@ void registerHints() {
assertThat(registeredTypes.contains(TypeReference.of(MistralAiEmbeddingOptions.class))).isTrue();
}

@Test
void registerHintsWithNullClassLoader() {
RuntimeHints runtimeHints = new RuntimeHints();
MistralAiRuntimeHints mistralAiRuntimeHints = new MistralAiRuntimeHints();

// Should not throw exception with null classLoader
mistralAiRuntimeHints.registerHints(runtimeHints, null);

// Verify hints were registered
assertThat(runtimeHints.reflection().typeHints().count()).isGreaterThan(0);
}

@Test
void registerHintsWithValidClassLoader() {
RuntimeHints runtimeHints = new RuntimeHints();
MistralAiRuntimeHints mistralAiRuntimeHints = new MistralAiRuntimeHints();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

mistralAiRuntimeHints.registerHints(runtimeHints, classLoader);

// Verify hints were registered
assertThat(runtimeHints.reflection().typeHints().count()).isGreaterThan(0);
}

@Test
void registerHintsIsIdempotent() {
RuntimeHints runtimeHints = new RuntimeHints();
MistralAiRuntimeHints mistralAiRuntimeHints = new MistralAiRuntimeHints();

// Register hints twice
mistralAiRuntimeHints.registerHints(runtimeHints, null);
long firstCount = runtimeHints.reflection().typeHints().count();

mistralAiRuntimeHints.registerHints(runtimeHints, null);
long secondCount = runtimeHints.reflection().typeHints().count();

// Should have same number of hints
assertThat(firstCount).isEqualTo(secondCount);
}

@Test
void verifyExpectedTypesAreRegistered() {
RuntimeHints runtimeHints = new RuntimeHints();
MistralAiRuntimeHints mistralAiRuntimeHints = new MistralAiRuntimeHints();
mistralAiRuntimeHints.registerHints(runtimeHints, null);

Set<TypeReference> registeredTypes = new HashSet<>();
runtimeHints.reflection().typeHints().forEach(typeHint -> registeredTypes.add(typeHint.getType()));

// Verify some expected types are registered (adjust class names as needed)
assertThat(registeredTypes.stream().anyMatch(tr -> tr.getName().contains("MistralAi"))).isTrue();
assertThat(registeredTypes.stream().anyMatch(tr -> tr.getName().contains("ChatCompletion"))).isTrue();
}

@Test
void verifyPackageScanningWorks() {
Set<TypeReference> jsonAnnotatedClasses = findJsonAnnotatedClassesInPackage("org.springframework.ai.mistralai");

// Verify package scanning found classes
assertThat(jsonAnnotatedClasses.size()).isGreaterThan(0);
}

}