diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupportTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupportTest.java index 1835955..59c9b47 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupportTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/prompt/AiPromptSupportTest.java @@ -8,6 +8,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; @@ -32,7 +33,11 @@ public void buildPromptRendersFileNameAndSource() { @Test public void buildPromptUsesFullPathWhenFileNameNull() { AiPromptSupport support = new AiPromptSupport(Collections.singletonList(def("summary", "[%s] %s"))); - assertThat(support.buildPrompt("summary", Paths.get("/"), "x"), is("[/] x")); + // A root path has a null getFileName() on every OS, so buildPrompt falls back to the full + // path string. Derive the expected separator from the same Path so the assertion holds on + // Windows too (the root renders with the platform separator: "/" on POSIX, "\" on Windows). + Path root = Paths.get("/"); + assertThat(support.buildPrompt("summary", root, "x"), is("[" + root + "] x")); } @Test diff --git a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProviderTest.java b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProviderTest.java index d319aa9..b1f94b9 100644 --- a/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProviderTest.java +++ b/src/test/java/net/ladenthin/maven/llamacpp/aiindex/provider/MockAiGenerationProviderTest.java @@ -7,6 +7,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import java.io.IOException; +import java.nio.file.Path; import java.nio.file.Paths; import net.ladenthin.maven.llamacpp.aiindex.document.AiGenerationRequest; import net.ladenthin.maven.llamacpp.aiindex.document.AiMdHeader; @@ -30,9 +31,12 @@ public void generateUsesFileNameOnly() throws IOException { @Test public void generateFallsBackToFullPathWhenFileNameNull() throws IOException { - // A root path has a null getFileName(); the provider must use file.toString(). - AiGenerationRequest request = new AiGenerationRequest("summary", Paths.get("/"), "src", HEADER); - assertThat(provider.generate(request), is("Mock summary for /")); + // A root path has a null getFileName(); the provider must use file.toString(). Derive the + // expected separator from the same Path so the assertion holds on Windows too (the root + // renders with the platform separator: "/" on POSIX, "\" on Windows). + Path root = Paths.get("/"); + AiGenerationRequest request = new AiGenerationRequest("summary", root, "src", HEADER); + assertThat(provider.generate(request), is("Mock summary for " + root)); } @Test