@@ -54,16 +54,10 @@ import io.mockk.junit5.MockKExtension
54
54
import io.mockk.mockk
55
55
import io.mockk.mockkStatic
56
56
import io.mockk.verify
57
- import java.io.File
58
- import java.nio.file.Files
59
- import java.nio.file.Path
60
57
import java.util.*
61
58
import kotlin.test.Test
62
59
import kotlin.test.assertEquals
63
- import kotlin.test.assertFalse
64
60
import kotlin.test.assertNotNull
65
- import kotlin.test.assertTrue
66
- import org.junit.jupiter.api.AfterEach
67
61
import org.junit.jupiter.api.BeforeEach
68
62
import org.junit.jupiter.api.DynamicTest
69
63
import org.junit.jupiter.api.TestFactory
@@ -90,8 +84,6 @@ class WorkspaceServiceImplTests {
90
84
@Suppress(" unused" ) @RelaxedMockK private lateinit var s3Client: S3Client
91
85
@RelaxedMockK private lateinit var s3Template: S3Template
92
86
93
- private lateinit var blobPersistencePath: String
94
-
95
87
@Suppress(" unused" ) @MockK private var eventPublisher: CsmEventPublisher = mockk(relaxed = true )
96
88
@Suppress(" unused" ) @MockK private var idGenerator: CsmIdGenerator = mockk(relaxed = true )
97
89
@@ -142,16 +134,9 @@ class WorkspaceServiceImplTests {
142
134
every { csmPlatformProperties.s3.bucketName } returns S3_BUCKET_NAME
143
135
every { s3Template.objectExists(any(), any()) } returns false
144
136
145
- blobPersistencePath = Files .createTempDirectory(" cosmotech-api-test-data-" ).toString()
146
-
147
137
MockKAnnotations .init (this )
148
138
}
149
139
150
- @AfterEach
151
- fun afterEach () {
152
- File (blobPersistencePath).deleteRecursively()
153
- }
154
-
155
140
@Test
156
141
fun `In uploadWorkspaceFile, filename is used if no destination set` () {
157
142
val workspace = mockk<Workspace >(relaxed = true )
@@ -167,8 +152,6 @@ class WorkspaceServiceImplTests {
167
152
workspaceServiceImpl.createWorkspaceFile(ORGANIZATION_ID , WORKSPACE_ID , file, false , null )
168
153
assertNotNull(workspaceFile.fileName)
169
154
assertEquals(" my_file.txt" , workspaceFile.fileName)
170
- assertTrue(
171
- Files .exists(Path .of(blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID , " my_file.txt" )))
172
155
}
173
156
174
157
@Test
@@ -188,8 +171,6 @@ class WorkspaceServiceImplTests {
188
171
workspaceServiceImpl.createWorkspaceFile(ORGANIZATION_ID , WORKSPACE_ID , file, false , " " )
189
172
assertNotNull(workspaceFile.fileName)
190
173
assertEquals(" my_file.txt" , workspaceFile.fileName)
191
- assertTrue(
192
- Files .exists(Path .of(blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID , " my_file.txt" )))
193
174
}
194
175
195
176
@Test
@@ -208,10 +189,6 @@ class WorkspaceServiceImplTests {
208
189
ORGANIZATION_ID , WORKSPACE_ID , file, false , " my/destination/" )
209
190
assertNotNull(workspaceFile.fileName)
210
191
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" )))
215
192
}
216
193
217
194
@Test
@@ -230,9 +207,6 @@ class WorkspaceServiceImplTests {
230
207
ORGANIZATION_ID , WORKSPACE_ID , file, false , " my/destination/file" )
231
208
assertNotNull(workspaceFile.fileName)
232
209
assertEquals(" my/destination/file" , workspaceFile.fileName)
233
- assertTrue(
234
- Files .exists(
235
- Path .of(blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID , " my/destination/file" )))
236
210
}
237
211
238
212
@Test
@@ -251,10 +225,6 @@ class WorkspaceServiceImplTests {
251
225
ORGANIZATION_ID , WORKSPACE_ID , file, false , " my//other/destination////////file" )
252
226
assertNotNull(workspaceFile.fileName)
253
227
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" )))
258
228
}
259
229
260
230
@Test
@@ -263,7 +233,6 @@ class WorkspaceServiceImplTests {
263
233
workspaceServiceImpl.createWorkspaceFile(
264
234
ORGANIZATION_ID , WORKSPACE_ID , mockk(), false , " my/../other/destination/../../file" )
265
235
}
266
- assertFalse(Files .exists(Path .of(blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID )))
267
236
}
268
237
269
238
@Test
@@ -272,7 +241,6 @@ class WorkspaceServiceImplTests {
272
241
workspaceServiceImpl.getWorkspaceFile(
273
242
ORGANIZATION_ID , WORKSPACE_ID , " my/../../other/destination/file" )
274
243
}
275
- assertFalse(Files .exists(Path .of(blobPersistencePath, ORGANIZATION_ID , WORKSPACE_ID )))
276
244
}
277
245
278
246
@Test
@@ -442,10 +410,6 @@ class WorkspaceServiceImplTests {
442
410
.map { (role, shouldThrow) ->
443
411
rbacTest(" Test RBAC download workspace file: $role " , role, shouldThrow) {
444
412
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)
449
413
workspaceServiceImpl.getWorkspaceFile(it.organization.id, it.workspace.id, " name" )
450
414
}
451
415
}
0 commit comments