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"))); } }