Skip to content

Commit df228f6

Browse files
committed
Merge branch 'generic_additional_data_PROD-14915'
2 parents 9148f12 + df8b5b7 commit df228f6

File tree

31 files changed

+255
-232
lines changed

31 files changed

+255
-232
lines changed

api/src/integrationTest/kotlin/com/cosmotech/api/home/ControllerTestUtils.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.cosmotech.organization.domain.OrganizationSecurity
2525
import com.cosmotech.runner.domain.*
2626
import com.cosmotech.solution.domain.*
2727
import com.cosmotech.workspace.domain.*
28+
import kotlin.collections.mutableListOf
2829
import org.apache.commons.io.IOUtils
2930
import org.json.JSONObject
3031
import org.springframework.http.MediaType
@@ -279,9 +280,7 @@ class ControllerTestUtils {
279280
defaultRunTemplateDataset: MutableMap<String, Any> = mutableMapOf(),
280281
datasetCopy: Boolean? = null,
281282
security: WorkspaceSecurity? = null,
282-
url: String = "",
283-
iframes: MutableMap<String, Any> = mutableMapOf(),
284-
options: MutableMap<String, Any> = mutableMapOf(),
283+
additionalData: MutableMap<String, Any> = mutableMapOf(),
285284
tags: MutableList<String> = mutableListOf()
286285
): WorkspaceCreateRequest {
287286
return WorkspaceCreateRequest(
@@ -299,7 +298,7 @@ class ControllerTestUtils {
299298
datasetCopy = datasetCopy,
300299
security = security,
301300
tags = tags,
302-
webApp = WorkspaceWebApp(url = url, iframes = iframes, options = options))
301+
additionalData = additionalData)
303302
}
304303

305304
@JvmStatic
@@ -313,9 +312,7 @@ class ControllerTestUtils {
313312
runTemplateFilter: MutableList<String> = mutableListOf(),
314313
defaultRunTemplateDataset: MutableMap<String, Any> = mutableMapOf(),
315314
datasetCopy: Boolean? = null,
316-
url: String = "",
317-
iframes: MutableMap<String, Any> = mutableMapOf(),
318-
options: MutableMap<String, Any> = mutableMapOf(),
315+
additionalData: MutableMap<String, Any> = mutableMapOf(),
319316
tags: MutableList<String> = mutableListOf()
320317
): WorkspaceUpdateRequest {
321318

@@ -332,7 +329,7 @@ class ControllerTestUtils {
332329
description = description,
333330
datasetCopy = datasetCopy,
334331
tags = tags,
335-
webApp = WorkspaceWebApp(url = url, iframes = iframes, options = options))
332+
additionalData = additionalData)
336333
}
337334
}
338335

@@ -449,13 +446,15 @@ class ControllerTestUtils {
449446
name = name,
450447
description = DATASET_DESCRIPTION,
451448
tags = mutableListOf("tag1", "tag2"),
449+
additionalData = mutableMapOf("customClient" to "customDatasetData"),
452450
runnerId = "r-12345678910",
453451
parts =
454452
mutableListOf(
455453
DatasetPartCreateRequest(
456454
name = datasetPartName,
457455
description = DATASET_PART_DESCRIPTION,
458456
tags = mutableListOf("tag_part1", "tag_part2"),
457+
additionalData = mutableMapOf("customClient" to "customDatasetPartData"),
459458
type = type,
460459
sourceName = sourceName)),
461460
security = security)
@@ -469,6 +468,7 @@ class ControllerTestUtils {
469468
name = name,
470469
description = DATASET_PART_DESCRIPTION,
471470
tags = mutableListOf("tag_part1", "tag_part3"),
471+
additionalData = mutableMapOf("customClient" to "customDatasetPartData"),
472472
type = type,
473473
sourceName = TEST_FILE_NAME)
474474
}

api/src/integrationTest/kotlin/com/cosmotech/api/home/solution/SolutionControllerTests.kt

Lines changed: 54 additions & 48 deletions
Large diffs are not rendered by default.

api/src/integrationTest/kotlin/com/cosmotech/api/home/workspace/WorkspaceControllerTests.kt

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,16 @@ class WorkspaceControllerTests : ControllerTestBase() {
5757
fun create_workspace() {
5858

5959
val description = "here_is_workspace_description"
60-
val url = "https://portal.cosmotech.com/"
6160
val version = "1.0.0"
6261
val datasetCopy = false
6362
val runTemplateFilter = mutableListOf("runtemplateId1,runtemplateId2")
6463
val tags = mutableListOf("tag1,tag2")
6564
val defaultRunTemplateDataset =
6665
mutableMapOf<String, Any>(
6766
"runtemplateId1" to "datasetId1", "runtemplateId2" to "datasetId2")
68-
val iframes =
67+
val additionalData =
6968
mutableMapOf(
70-
"you_can_put" to "whatever_you_want_here",
71-
"even" to JSONObject(mapOf("object" to "if_you_want")))
72-
val options =
73-
mutableMapOf(
74-
"you_can_put" to "whatever_you_want_here",
75-
"even" to JSONObject(mapOf("object" to "if_you_want")))
69+
"you_can_put" to "whatever_you_want_here", "even" to mapOf("object" to "if_you_want"))
7670
val workspaceSecurity =
7771
WorkspaceSecurity(
7872
default = ROLE_NONE,
@@ -101,9 +95,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
10195
defaultRunTemplateDataset,
10296
datasetCopy,
10397
workspaceSecurity,
104-
url,
105-
iframes,
106-
options,
98+
additionalData,
10799
tags))
108100
.toString())
109101
.accept(MediaType.APPLICATION_JSON)
@@ -127,7 +119,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
127119
.value("solution_parameter2_defaultValue"))
128120
.andExpect(jsonPath("$.datasetCopy").value(datasetCopy))
129121
.andExpect(jsonPath("$.tags").value(tags))
130-
.andExpect(jsonPath("$.webApp.url").value(url))
122+
.andExpect(jsonPath("$.additionalData").value(additionalData))
131123
.andExpect(jsonPath("$.organizationId").value(organizationId))
132124
.andExpect(jsonPath("$.solution.solutionId").value(solutionId))
133125
.andExpect(jsonPath("$.security.default").value(ROLE_NONE))
@@ -147,21 +139,15 @@ class WorkspaceControllerTests : ControllerTestBase() {
147139
createWorkspaceAndReturnId(mvc, organizationId, WORKSPACE_KEY, WORKSPACE_NAME, solutionId)
148140

149141
val description = "here_is_workspace_description"
150-
val url = "https://portal.cosmotech.com/"
151142
val datasetCopy = false
152143
val runTemplateFilter = mutableListOf("runtemplateId1,runtemplateId2")
153144
val tags = mutableListOf("tag1,tag2")
154145
val defaultRunTemplateDataset =
155146
mutableMapOf<String, Any>(
156147
"runtemplateId1" to "datasetId1", "runtemplateId2" to "datasetId2")
157-
val iframes =
158-
mutableMapOf(
159-
"you_can_put" to "whatever_you_want_here",
160-
"even" to JSONObject(mapOf("object" to "if_you_want")))
161-
val options =
148+
val additionalData =
162149
mutableMapOf(
163-
"you_can_put" to "whatever_you_want_here",
164-
"even" to JSONObject(mapOf("object" to "if_you_want")))
150+
"you_can_put" to "whatever_you_want_here", "even" to mapOf("object" to "if_you_want"))
165151

166152
val workspaceDatasetId = "d-12345678910"
167153
mvc.perform(
@@ -181,9 +167,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
181167
runTemplateFilter,
182168
defaultRunTemplateDataset,
183169
datasetCopy,
184-
url,
185-
iframes,
186-
options,
170+
additionalData,
187171
tags))
188172
.toString())
189173
.accept(MediaType.APPLICATION_JSON)
@@ -206,7 +190,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
206190
.value("solution_parameter2_defaultValue"))
207191
.andExpect(jsonPath("$.datasetCopy").value(datasetCopy))
208192
.andExpect(jsonPath("$.tags").value(tags))
209-
.andExpect(jsonPath("$.webApp.url").value(url))
193+
.andExpect(jsonPath("$.additionalData").value(additionalData))
210194
.andExpect(jsonPath("$.organizationId").value(organizationId))
211195
.andExpect(jsonPath("$.solution.solutionId").value(solutionId))
212196
.andExpect(jsonPath("$.security.default").value(ROLE_NONE))
@@ -280,22 +264,16 @@ class WorkspaceControllerTests : ControllerTestBase() {
280264
fun get_workspace() {
281265

282266
val description = "here_is_workspace_description"
283-
val url = "https://portal.cosmotech.com/"
284267
val version = "1.0.0"
285268
val datasetCopy = false
286269
val runTemplateFilter = mutableListOf("runtemplateId1,runtemplateId2")
287270
val tags = mutableListOf("tag1,tag2")
288271
val defaultRunTemplateDataset =
289272
mutableMapOf<String, Any>(
290273
"runtemplateId1" to "datasetId1", "runtemplateId2" to "datasetId2")
291-
val iframes =
292-
mutableMapOf(
293-
"you_can_put" to "whatever_you_want_here",
294-
"even" to JSONObject(mapOf("object" to "if_you_want")))
295-
val options =
274+
val additionalData =
296275
mutableMapOf(
297-
"you_can_put" to "whatever_you_want_here",
298-
"even" to JSONObject(mapOf("object" to "if_you_want")))
276+
"you_can_put" to "whatever_you_want_here", "even" to mapOf("object" to "if_you_want"))
299277

300278
val workspaceDatasetId = "d-12345678910"
301279
val workspaceSecurity =
@@ -323,9 +301,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
323301
defaultRunTemplateDataset,
324302
datasetCopy,
325303
workspaceSecurity,
326-
url,
327-
iframes,
328-
options,
304+
additionalData,
329305
tags))
330306

331307
mvc.perform(
@@ -343,7 +319,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
343319
jsonPath("$.solution.defaultRunTemplateDataset").value(defaultRunTemplateDataset))
344320
.andExpect(jsonPath("$.datasetCopy").value(datasetCopy))
345321
.andExpect(jsonPath("$.tags").value(tags))
346-
.andExpect(jsonPath("$.webApp.url").value(url))
322+
.andExpect(jsonPath("$.additionalData").value(additionalData))
347323
.andExpect(jsonPath("$.organizationId").value(organizationId))
348324
.andExpect(jsonPath("$.solution.solutionId").value(solutionId))
349325
.andExpect(jsonPath("$.solution.datasetId").value(workspaceDatasetId))

dataset/src/integrationTest/kotlin/com/cosmotech/dataset/service/DatasetServiceIntegrationTest.kt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,28 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
169169
val datasetPartName = "Customers list"
170170
val datasetPartDescription = "List of customers"
171171
val datasetPartTags = mutableListOf("part", "public", "customers")
172+
val datasetPartAdditionalData =
173+
mutableMapOf("part" to "data", "complex" to mutableMapOf("nested" to "data"))
172174
val datasetPartCreateRequest =
173175
DatasetPartCreateRequest(
174176
name = datasetPartName,
175177
sourceName = CUSTOMER_SOURCE_FILE_NAME,
176178
description = datasetPartDescription,
177179
tags = datasetPartTags,
180+
additionalData = datasetPartAdditionalData,
178181
type = DatasetPartTypeEnum.File)
179182

180183
val datasetName = "Customer Dataset"
181184
val datasetDescription = "Dataset for customers"
182185
val datasetTags = mutableListOf("dataset", "public", "customers")
186+
val datasetAdditionalData =
187+
mutableMapOf("dataset" to "data", "complex" to mutableMapOf("nested" to "data"))
183188
val datasetCreateRequest =
184189
DatasetCreateRequest(
185190
name = datasetName,
186191
description = datasetDescription,
187192
tags = datasetTags,
193+
additionalData = datasetAdditionalData,
188194
parts = mutableListOf(datasetPartCreateRequest))
189195

190196
val resourceTestFile = resourceLoader.getResource("classpath:/$CUSTOMER_SOURCE_FILE_NAME").file
@@ -218,12 +224,14 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
218224
assertEquals(datasetName, createdDataset.name)
219225
assertEquals(datasetDescription, createdDataset.description)
220226
assertEquals(datasetTags, createdDataset.tags)
227+
assertEquals(datasetAdditionalData, createdDataset.additionalData)
221228
assertEquals(1, createdDataset.parts.size)
222229
val createdDatasetPart = createdDataset.parts[0]
223230
assertNotNull(createdDatasetPart)
224231
assertEquals(datasetPartName, createdDatasetPart.name)
225232
assertEquals(datasetPartDescription, createdDatasetPart.description)
226233
assertEquals(datasetPartTags, createdDatasetPart.tags)
234+
assertEquals(datasetPartAdditionalData, createdDatasetPart.additionalData)
227235
assertEquals(CUSTOMER_SOURCE_FILE_NAME, createdDatasetPart.sourceName)
228236
assertEquals(DatasetPartTypeEnum.File, createdDatasetPart.type)
229237
}
@@ -980,6 +988,8 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
980988
val datasetPartName = "Customer list"
981989
val datasetPartDescription = "List of customers"
982990
val datasetPartTags = mutableListOf("part", "public", "customers")
991+
val datasetPartAdditionalData =
992+
mutableMapOf("part" to "data", "complex" to mutableMapOf("nested" to "data"))
983993

984994
val createDatasetPart =
985995
datasetApiService.createDatasetPart(
@@ -992,12 +1002,14 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
9921002
sourceName = CUSTOMER_SOURCE_FILE_NAME,
9931003
description = datasetPartDescription,
9941004
tags = datasetPartTags,
1005+
additionalData = datasetPartAdditionalData,
9951006
type = DatasetPartTypeEnum.File))
9961007

9971008
assertNotNull(createDatasetPart)
9981009
assertEquals(datasetPartName, createDatasetPart.name)
9991010
assertEquals(datasetPartDescription, createDatasetPart.description)
10001011
assertEquals(datasetPartTags, createDatasetPart.tags)
1012+
assertEquals(datasetPartAdditionalData, createDatasetPart.additionalData)
10011013
assertEquals(CUSTOMER_SOURCE_FILE_NAME, createDatasetPart.sourceName)
10021014

10031015
val retrievedDataset =
@@ -1882,22 +1894,28 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
18821894
val datasetPartName = "Customers list"
18831895
val datasetPartDescription = "List of customers"
18841896
val datasetPartTags = mutableListOf("part", "public", "customers")
1897+
val datasetPartAdditionalData =
1898+
mutableMapOf("part" to "data", "complex" to mutableMapOf("nested" to "data"))
18851899
val datasetPartCreateRequest =
18861900
DatasetPartCreateRequest(
18871901
name = datasetPartName,
18881902
sourceName = CUSTOMER_SOURCE_FILE_NAME,
18891903
description = datasetPartDescription,
18901904
tags = datasetPartTags,
1905+
additionalData = datasetPartAdditionalData,
18911906
type = DatasetPartTypeEnum.File)
18921907

18931908
val datasetName = "Customer Dataset"
18941909
val datasetDescription = "Dataset for customers"
18951910
val datasetTags = mutableListOf("dataset", "public", "customers")
1911+
val datasetAdditionalData =
1912+
mutableMapOf("dataset" to "data", "complex" to mutableMapOf("nested" to "data"))
18961913
val datasetCreateRequest =
18971914
DatasetCreateRequest(
18981915
name = datasetName,
18991916
description = datasetDescription,
19001917
tags = datasetTags,
1918+
additionalData = datasetAdditionalData,
19011919
parts = mutableListOf(datasetPartCreateRequest))
19021920

19031921
val resourceTestFile = resourceLoader.getResource("classpath:/$CUSTOMER_SOURCE_FILE_NAME").file
@@ -1922,17 +1940,20 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
19221940
val newDatasetPartName = "Product list"
19231941
val newDatasetPartDescription = "List of Product"
19241942
val newDatasetPartTags = mutableListOf("part", "public", "product")
1943+
val newDatasetPartAdditionalData = mutableMapOf<String, Any>("part" to "new data")
19251944
val newDatasetPartCreateRequest =
19261945
DatasetPartCreateRequest(
19271946
name = newDatasetPartName,
19281947
sourceName = INVENTORY_SOURCE_FILE_NAME,
19291948
description = newDatasetPartDescription,
19301949
tags = newDatasetPartTags,
1950+
additionalData = newDatasetPartAdditionalData,
19311951
type = DatasetPartTypeEnum.File)
19321952

19331953
val newDatasetName = "Shop Dataset"
19341954
val newDatasetDescription = "Dataset for shop"
19351955
val newDatasetTags = mutableListOf("dataset", "public", "shop")
1956+
val newDatasetAdditionalData = mutableMapOf<String, Any>("dataset" to "new data")
19361957
val newDatasetSecurity =
19371958
DatasetSecurity(
19381959
default = ROLE_NONE,
@@ -1945,6 +1966,7 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
19451966
name = newDatasetName,
19461967
description = newDatasetDescription,
19471968
tags = newDatasetTags,
1969+
additionalData = newDatasetAdditionalData,
19481970
parts = mutableListOf(newDatasetPartCreateRequest),
19491971
security = newDatasetSecurity)
19501972

@@ -2256,12 +2278,15 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
22562278
val customerPartName = "Customers list"
22572279
val customerPartDescription = "List of customers"
22582280
val customerPartTags = mutableListOf("part", "public", "customers")
2281+
val customerPartAdditionalData =
2282+
mutableMapOf("part" to "data", "complex" to mutableMapOf("nested" to "data"))
22592283
val customerPartCreateRequest =
22602284
DatasetPartCreateRequest(
22612285
name = customerPartName,
22622286
sourceName = CUSTOMER_SOURCE_FILE_NAME,
22632287
description = customerPartDescription,
22642288
tags = customerPartTags,
2289+
additionalData = customerPartAdditionalData,
22652290
type = DatasetPartTypeEnum.File)
22662291

22672292
val datasetName = "Shop Dataset"
@@ -2315,18 +2340,21 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
23152340
assertEquals(customerPartName, datasetPartToReplace.name)
23162341
assertEquals(customerPartDescription, datasetPartToReplace.description)
23172342
assertEquals(customerPartTags, datasetPartToReplace.tags)
2343+
assertEquals(customerPartAdditionalData, datasetPartToReplace.additionalData)
23182344
assertEquals(CUSTOMER_SOURCE_FILE_NAME, datasetPartToReplace.sourceName)
23192345
assertEquals(DatasetPartTypeEnum.File, datasetPartToReplace.type)
23202346

23212347
// New Part to replace the existing one in the dataset
23222348
val newDatasetSourceName = "updatedResourceFile.csv"
23232349
val newDatasetPartDescription = "New Data for customer list"
23242350
val newDatasetPartTags = mutableListOf("part", "public", "new", "customer")
2351+
val newDatasetPartAdditionalData = mutableMapOf<String, Any>("part" to "new data")
23252352
val datasetPartUpdateRequest =
23262353
DatasetPartUpdateRequest(
23272354
sourceName = newDatasetSourceName,
23282355
description = newDatasetPartDescription,
23292356
tags = newDatasetPartTags,
2357+
additionalData = newDatasetPartAdditionalData,
23302358
)
23312359

23322360
val replacedDatasetPart =
@@ -2347,6 +2375,7 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
23472375
assertEquals(newDatasetSourceName, replacedDatasetPart.sourceName)
23482376
assertEquals(newDatasetPartDescription, replacedDatasetPart.description)
23492377
assertEquals(newDatasetPartTags, replacedDatasetPart.tags)
2378+
assertEquals(newDatasetPartAdditionalData, replacedDatasetPart.additionalData)
23502379
assertEquals(newDatasetSourceName, replacedDatasetPart.sourceName)
23512380
assertEquals(DatasetPartTypeEnum.File, replacedDatasetPart.type)
23522381

0 commit comments

Comments
 (0)