fix chat session traces and document paths
This commit is contained in:
@@ -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")));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user