@@ -54,16 +54,10 @@ import io.mockk.junit5.MockKExtension
5454import io.mockk.mockk
5555import io.mockk.mockkStatic
5656import io.mockk.verify
57- import java.io.File
58- import java.nio.file.Files
59- import java.nio.file.Path
6057import java.util.*
6158import kotlin.test.Test
6259import kotlin.test.assertEquals
63- import kotlin.test.assertFalse
6460import kotlin.test.assertNotNull
65- import kotlin.test.assertTrue
66- import org.junit.jupiter.api.AfterEach
6761import org.junit.jupiter.api.BeforeEach
6862import org.junit.jupiter.api.DynamicTest
6963import org.junit.jupiter.api.TestFactory
@@ -90,8 +84,6 @@ class WorkspaceServiceImplTests {
9084 @Suppress(" unused" ) @RelaxedMockK private lateinit var s3Client: S3Client
9185 @RelaxedMockK private lateinit var s3Template: S3Template
9286
93- private lateinit var blobPersistencePath: String
94-
9587 @Suppress(" unused" ) @MockK private var eventPublisher: CsmEventPublisher = mockk(relaxed = true )
9688 @Suppress(" unused" ) @MockK private var idGenerator: CsmIdGenerator = mockk(relaxed = true )
9789
@@ -142,16 +134,9 @@ class WorkspaceServiceImplTests {
142134 every { csmPlatformProperties.s3.bucketName } returns S3_BUCKET_NAME
143135 every { s3Template.objectExists(any(), any()) } returns false
144136
145- blobPersistencePath = Files .createTempDirectory(" cosmotech-api-test-data-" ).toString()
146-
147137 MockKAnnotations .init (this )
148138 }
149139
150- @AfterEach
151- fun afterEach () {
152- File (blobPersistencePath).deleteRecursively()
153- }
154-
155140 @Test
156141 fun `In uploadWorkspaceFile, filename is used if no destination set` () {
157142 val workspace = mockk<Workspace >(relaxed = true )
@@ -167,8 +152,6 @@ class WorkspaceServiceImplTests {
167152 workspaceServiceImpl.createWorkspaceFile(ORGANIZATION_ID , WORKSPACE_ID , file, false , null )
168153 assertNotNull(workspaceFile.fileName)
169154 assertEquals(" my_file.txt" , workspaceFile.fileName)
170- assertTrue(
171- Files .exists(Path .of(blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID , " my_file.txt" )))
172155 }
173156
174157 @Test
@@ -188,8 +171,6 @@ class WorkspaceServiceImplTests {
188171 workspaceServiceImpl.createWorkspaceFile(ORGANIZATION_ID , WORKSPACE_ID , file, false , " " )
189172 assertNotNull(workspaceFile.fileName)
190173 assertEquals(" my_file.txt" , workspaceFile.fileName)
191- assertTrue(
192- Files .exists(Path .of(blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID , " my_file.txt" )))
193174 }
194175
195176 @Test
@@ -208,10 +189,6 @@ class WorkspaceServiceImplTests {
208189 ORGANIZATION_ID , WORKSPACE_ID , file, false , " my/destination/" )
209190 assertNotNull(workspaceFile.fileName)
210191 assertEquals(" my/destination/my_file.txt" , workspaceFile.fileName)
211- assertTrue(
212- Files .exists(
213- Path .of(
214- blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID , " my/destination/my_file.txt" )))
215192 }
216193
217194 @Test
@@ -230,9 +207,6 @@ class WorkspaceServiceImplTests {
230207 ORGANIZATION_ID , WORKSPACE_ID , file, false , " my/destination/file" )
231208 assertNotNull(workspaceFile.fileName)
232209 assertEquals(" my/destination/file" , workspaceFile.fileName)
233- assertTrue(
234- Files .exists(
235- Path .of(blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID , " my/destination/file" )))
236210 }
237211
238212 @Test
@@ -251,10 +225,6 @@ class WorkspaceServiceImplTests {
251225 ORGANIZATION_ID , WORKSPACE_ID , file, false , " my//other/destination////////file" )
252226 assertNotNull(workspaceFile.fileName)
253227 assertEquals(" my/other/destination/file" , workspaceFile.fileName)
254- assertTrue(
255- Files .exists(
256- Path .of(
257- blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID , " my/other/destination/file" )))
258228 }
259229
260230 @Test
@@ -263,7 +233,6 @@ class WorkspaceServiceImplTests {
263233 workspaceServiceImpl.createWorkspaceFile(
264234 ORGANIZATION_ID , WORKSPACE_ID , mockk(), false , " my/../other/destination/../../file" )
265235 }
266- assertFalse(Files .exists(Path .of(blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID )))
267236 }
268237
269238 @Test
@@ -272,7 +241,6 @@ class WorkspaceServiceImplTests {
272241 workspaceServiceImpl.getWorkspaceFile(
273242 ORGANIZATION_ID , WORKSPACE_ID , " my/../../other/destination/file" )
274243 }
275- assertFalse(Files .exists(Path .of(blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID )))
276244 }
277245
278246 @Test
@@ -442,10 +410,6 @@ class WorkspaceServiceImplTests {
442410 .map { (role, shouldThrow) ->
443411 rbacTest(" Test RBAC download workspace file: $role " , role, shouldThrow) {
444412 every { workspaceRepository.findBy(any(), any()) } returns Optional .of(it.workspace)
445- val filePath =
446- Path .of(blobPersistencePath, it.organization.id, it.workspace.id, " name" )
447- Files .createDirectories(filePath.getParent())
448- Files .createFile(filePath)
449413 workspaceServiceImpl.getWorkspaceFile(it.organization.id, it.workspace.id, " name" )
450414 }
451415 }
0 commit comments