fix chat session traces and document paths

This commit is contained in:
zhuyongxin
2026-07-03 13:53:16 +08:00
parent fd89d84fc0
commit 1ff7f09d25
11 changed files with 492 additions and 248 deletions
@@ -0,0 +1,41 @@
package com.superbiz.agent.service;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.util.ReflectionTestUtils;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
class DocumentManagementServiceTest {
@TempDir
Path tempDir;
@Test
void saveToLocalStoresRelativePathUnderKnowledgeBase() throws Exception {
DocumentManagementService service = new DocumentManagementService();
ReflectionTestUtils.setField(service, "knowledgeBasePath", tempDir.toString());
MockMultipartFile file = new MockMultipartFile(
"file",
"runbook.md",
"text/markdown",
"runbook content".getBytes()
);
String storedPath = ReflectionTestUtils.invokeMethod(
service,
"saveToLocal",
file,
"runbook.md",
"payment"
);
assertEquals("payment/runbook.md", storedPath);
assertTrue(Files.exists(tempDir.resolve("payment").resolve("runbook.md")));
}
}