Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.cosmotech.organization.domain.OrganizationSecurity
import com.cosmotech.runner.domain.*
import com.cosmotech.solution.domain.*
import com.cosmotech.workspace.domain.*
import kotlin.collections.mutableListOf
import org.apache.commons.io.IOUtils
import org.json.JSONObject
import org.springframework.http.MediaType
Expand Down Expand Up @@ -279,9 +280,7 @@ class ControllerTestUtils {
defaultRunTemplateDataset: MutableMap<String, Any> = mutableMapOf(),
datasetCopy: Boolean? = null,
security: WorkspaceSecurity? = null,
url: String = "",
iframes: MutableMap<String, Any> = mutableMapOf(),
options: MutableMap<String, Any> = mutableMapOf(),
additionalData: MutableMap<String, Any> = mutableMapOf(),
tags: MutableList<String> = mutableListOf()
): WorkspaceCreateRequest {
return WorkspaceCreateRequest(
Expand All @@ -299,7 +298,7 @@ class ControllerTestUtils {
datasetCopy = datasetCopy,
security = security,
tags = tags,
webApp = WorkspaceWebApp(url = url, iframes = iframes, options = options))
additionalData = additionalData)
}

@JvmStatic
Expand All @@ -313,9 +312,7 @@ class ControllerTestUtils {
runTemplateFilter: MutableList<String> = mutableListOf(),
defaultRunTemplateDataset: MutableMap<String, Any> = mutableMapOf(),
datasetCopy: Boolean? = null,
url: String = "",
iframes: MutableMap<String, Any> = mutableMapOf(),
options: MutableMap<String, Any> = mutableMapOf(),
additionalData: MutableMap<String, Any> = mutableMapOf(),
tags: MutableList<String> = mutableListOf()
): WorkspaceUpdateRequest {

Expand All @@ -332,7 +329,7 @@ class ControllerTestUtils {
description = description,
datasetCopy = datasetCopy,
tags = tags,
webApp = WorkspaceWebApp(url = url, iframes = iframes, options = options))
additionalData = additionalData)
}
}

Expand Down Expand Up @@ -449,13 +446,15 @@ class ControllerTestUtils {
name = name,
description = DATASET_DESCRIPTION,
tags = mutableListOf("tag1", "tag2"),
additionalData = mutableMapOf("customClient" to "customDatasetData"),
runnerId = "r-12345678910",
parts =
mutableListOf(
DatasetPartCreateRequest(
name = datasetPartName,
description = DATASET_PART_DESCRIPTION,
tags = mutableListOf("tag_part1", "tag_part2"),
additionalData = mutableMapOf("customClient" to "customDatasetPartData"),
type = type,
sourceName = sourceName)),
security = security)
Expand All @@ -469,6 +468,7 @@ class ControllerTestUtils {
name = name,
description = DATASET_PART_DESCRIPTION,
tags = mutableListOf("tag_part1", "tag_part3"),
additionalData = mutableMapOf("customClient" to "customDatasetPartData"),
type = type,
sourceName = TEST_FILE_NAME)
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,16 @@ class WorkspaceControllerTests : ControllerTestBase() {
fun create_workspace() {

val description = "here_is_workspace_description"
val url = "https://portal.cosmotech.com/"
val version = "1.0.0"
val datasetCopy = false
val runTemplateFilter = mutableListOf("runtemplateId1,runtemplateId2")
val tags = mutableListOf("tag1,tag2")
val defaultRunTemplateDataset =
mutableMapOf<String, Any>(
"runtemplateId1" to "datasetId1", "runtemplateId2" to "datasetId2")
val iframes =
val additionalData =
mutableMapOf(
"you_can_put" to "whatever_you_want_here",
"even" to JSONObject(mapOf("object" to "if_you_want")))
val options =
mutableMapOf(
"you_can_put" to "whatever_you_want_here",
"even" to JSONObject(mapOf("object" to "if_you_want")))
"you_can_put" to "whatever_you_want_here", "even" to mapOf("object" to "if_you_want"))
val workspaceSecurity =
WorkspaceSecurity(
default = ROLE_NONE,
Expand Down Expand Up @@ -101,9 +95,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
defaultRunTemplateDataset,
datasetCopy,
workspaceSecurity,
url,
iframes,
options,
additionalData,
tags))
.toString())
.accept(MediaType.APPLICATION_JSON)
Expand All @@ -127,7 +119,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
.value("solution_parameter2_defaultValue"))
.andExpect(jsonPath("$.datasetCopy").value(datasetCopy))
.andExpect(jsonPath("$.tags").value(tags))
.andExpect(jsonPath("$.webApp.url").value(url))
.andExpect(jsonPath("$.additionalData").value(additionalData))
.andExpect(jsonPath("$.organizationId").value(organizationId))
.andExpect(jsonPath("$.solution.solutionId").value(solutionId))
.andExpect(jsonPath("$.security.default").value(ROLE_NONE))
Expand All @@ -147,21 +139,15 @@ class WorkspaceControllerTests : ControllerTestBase() {
createWorkspaceAndReturnId(mvc, organizationId, WORKSPACE_KEY, WORKSPACE_NAME, solutionId)

val description = "here_is_workspace_description"
val url = "https://portal.cosmotech.com/"
val datasetCopy = false
val runTemplateFilter = mutableListOf("runtemplateId1,runtemplateId2")
val tags = mutableListOf("tag1,tag2")
val defaultRunTemplateDataset =
mutableMapOf<String, Any>(
"runtemplateId1" to "datasetId1", "runtemplateId2" to "datasetId2")
val iframes =
mutableMapOf(
"you_can_put" to "whatever_you_want_here",
"even" to JSONObject(mapOf("object" to "if_you_want")))
val options =
val additionalData =
mutableMapOf(
"you_can_put" to "whatever_you_want_here",
"even" to JSONObject(mapOf("object" to "if_you_want")))
"you_can_put" to "whatever_you_want_here", "even" to mapOf("object" to "if_you_want"))

val workspaceDatasetId = "d-12345678910"
mvc.perform(
Expand All @@ -181,9 +167,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
runTemplateFilter,
defaultRunTemplateDataset,
datasetCopy,
url,
iframes,
options,
additionalData,
tags))
.toString())
.accept(MediaType.APPLICATION_JSON)
Expand All @@ -206,7 +190,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
.value("solution_parameter2_defaultValue"))
.andExpect(jsonPath("$.datasetCopy").value(datasetCopy))
.andExpect(jsonPath("$.tags").value(tags))
.andExpect(jsonPath("$.webApp.url").value(url))
.andExpect(jsonPath("$.additionalData").value(additionalData))
.andExpect(jsonPath("$.organizationId").value(organizationId))
.andExpect(jsonPath("$.solution.solutionId").value(solutionId))
.andExpect(jsonPath("$.security.default").value(ROLE_NONE))
Expand Down Expand Up @@ -280,22 +264,16 @@ class WorkspaceControllerTests : ControllerTestBase() {
fun get_workspace() {

val description = "here_is_workspace_description"
val url = "https://portal.cosmotech.com/"
val version = "1.0.0"
val datasetCopy = false
val runTemplateFilter = mutableListOf("runtemplateId1,runtemplateId2")
val tags = mutableListOf("tag1,tag2")
val defaultRunTemplateDataset =
mutableMapOf<String, Any>(
"runtemplateId1" to "datasetId1", "runtemplateId2" to "datasetId2")
val iframes =
mutableMapOf(
"you_can_put" to "whatever_you_want_here",
"even" to JSONObject(mapOf("object" to "if_you_want")))
val options =
val additionalData =
mutableMapOf(
"you_can_put" to "whatever_you_want_here",
"even" to JSONObject(mapOf("object" to "if_you_want")))
"you_can_put" to "whatever_you_want_here", "even" to mapOf("object" to "if_you_want"))

val workspaceDatasetId = "d-12345678910"
val workspaceSecurity =
Expand Down Expand Up @@ -323,9 +301,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
defaultRunTemplateDataset,
datasetCopy,
workspaceSecurity,
url,
iframes,
options,
additionalData,
tags))

mvc.perform(
Expand All @@ -343,7 +319,7 @@ class WorkspaceControllerTests : ControllerTestBase() {
jsonPath("$.solution.defaultRunTemplateDataset").value(defaultRunTemplateDataset))
.andExpect(jsonPath("$.datasetCopy").value(datasetCopy))
.andExpect(jsonPath("$.tags").value(tags))
.andExpect(jsonPath("$.webApp.url").value(url))
.andExpect(jsonPath("$.additionalData").value(additionalData))
.andExpect(jsonPath("$.organizationId").value(organizationId))
.andExpect(jsonPath("$.solution.solutionId").value(solutionId))
.andExpect(jsonPath("$.solution.datasetId").value(workspaceDatasetId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,28 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
val datasetPartName = "Customers list"
val datasetPartDescription = "List of customers"
val datasetPartTags = mutableListOf("part", "public", "customers")
val datasetPartAdditionalData =
mutableMapOf("part" to "data", "complex" to mutableMapOf("nested" to "data"))
val datasetPartCreateRequest =
DatasetPartCreateRequest(
name = datasetPartName,
sourceName = CUSTOMER_SOURCE_FILE_NAME,
description = datasetPartDescription,
tags = datasetPartTags,
additionalData = datasetPartAdditionalData,
type = DatasetPartTypeEnum.File)

val datasetName = "Customer Dataset"
val datasetDescription = "Dataset for customers"
val datasetTags = mutableListOf("dataset", "public", "customers")
val datasetAdditionalData =
mutableMapOf("dataset" to "data", "complex" to mutableMapOf("nested" to "data"))
val datasetCreateRequest =
DatasetCreateRequest(
name = datasetName,
description = datasetDescription,
tags = datasetTags,
additionalData = datasetAdditionalData,
parts = mutableListOf(datasetPartCreateRequest))

val resourceTestFile = resourceLoader.getResource("classpath:/$CUSTOMER_SOURCE_FILE_NAME").file
Expand Down Expand Up @@ -218,12 +224,14 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
assertEquals(datasetName, createdDataset.name)
assertEquals(datasetDescription, createdDataset.description)
assertEquals(datasetTags, createdDataset.tags)
assertEquals(datasetAdditionalData, createdDataset.additionalData)
assertEquals(1, createdDataset.parts.size)
val createdDatasetPart = createdDataset.parts[0]
assertNotNull(createdDatasetPart)
assertEquals(datasetPartName, createdDatasetPart.name)
assertEquals(datasetPartDescription, createdDatasetPart.description)
assertEquals(datasetPartTags, createdDatasetPart.tags)
assertEquals(datasetPartAdditionalData, createdDatasetPart.additionalData)
assertEquals(CUSTOMER_SOURCE_FILE_NAME, createdDatasetPart.sourceName)
assertEquals(DatasetPartTypeEnum.File, createdDatasetPart.type)
}
Expand Down Expand Up @@ -980,6 +988,8 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
val datasetPartName = "Customer list"
val datasetPartDescription = "List of customers"
val datasetPartTags = mutableListOf("part", "public", "customers")
val datasetPartAdditionalData =
mutableMapOf("part" to "data", "complex" to mutableMapOf("nested" to "data"))

val createDatasetPart =
datasetApiService.createDatasetPart(
Expand All @@ -992,12 +1002,14 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
sourceName = CUSTOMER_SOURCE_FILE_NAME,
description = datasetPartDescription,
tags = datasetPartTags,
additionalData = datasetPartAdditionalData,
type = DatasetPartTypeEnum.File))

assertNotNull(createDatasetPart)
assertEquals(datasetPartName, createDatasetPart.name)
assertEquals(datasetPartDescription, createDatasetPart.description)
assertEquals(datasetPartTags, createDatasetPart.tags)
assertEquals(datasetPartAdditionalData, createDatasetPart.additionalData)
assertEquals(CUSTOMER_SOURCE_FILE_NAME, createDatasetPart.sourceName)

val retrievedDataset =
Expand Down Expand Up @@ -1882,22 +1894,28 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
val datasetPartName = "Customers list"
val datasetPartDescription = "List of customers"
val datasetPartTags = mutableListOf("part", "public", "customers")
val datasetPartAdditionalData =
mutableMapOf("part" to "data", "complex" to mutableMapOf("nested" to "data"))
val datasetPartCreateRequest =
DatasetPartCreateRequest(
name = datasetPartName,
sourceName = CUSTOMER_SOURCE_FILE_NAME,
description = datasetPartDescription,
tags = datasetPartTags,
additionalData = datasetPartAdditionalData,
type = DatasetPartTypeEnum.File)

val datasetName = "Customer Dataset"
val datasetDescription = "Dataset for customers"
val datasetTags = mutableListOf("dataset", "public", "customers")
val datasetAdditionalData =
mutableMapOf("dataset" to "data", "complex" to mutableMapOf("nested" to "data"))
val datasetCreateRequest =
DatasetCreateRequest(
name = datasetName,
description = datasetDescription,
tags = datasetTags,
additionalData = datasetAdditionalData,
parts = mutableListOf(datasetPartCreateRequest))

val resourceTestFile = resourceLoader.getResource("classpath:/$CUSTOMER_SOURCE_FILE_NAME").file
Expand All @@ -1922,17 +1940,20 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
val newDatasetPartName = "Product list"
val newDatasetPartDescription = "List of Product"
val newDatasetPartTags = mutableListOf("part", "public", "product")
val newDatasetPartAdditionalData = mutableMapOf<String, Any>("part" to "new data")
val newDatasetPartCreateRequest =
DatasetPartCreateRequest(
name = newDatasetPartName,
sourceName = INVENTORY_SOURCE_FILE_NAME,
description = newDatasetPartDescription,
tags = newDatasetPartTags,
additionalData = newDatasetPartAdditionalData,
type = DatasetPartTypeEnum.File)

val newDatasetName = "Shop Dataset"
val newDatasetDescription = "Dataset for shop"
val newDatasetTags = mutableListOf("dataset", "public", "shop")
val newDatasetAdditionalData = mutableMapOf<String, Any>("dataset" to "new data")
val newDatasetSecurity =
DatasetSecurity(
default = ROLE_NONE,
Expand All @@ -1945,6 +1966,7 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
name = newDatasetName,
description = newDatasetDescription,
tags = newDatasetTags,
additionalData = newDatasetAdditionalData,
parts = mutableListOf(newDatasetPartCreateRequest),
security = newDatasetSecurity)

Expand Down Expand Up @@ -2256,12 +2278,15 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
val customerPartName = "Customers list"
val customerPartDescription = "List of customers"
val customerPartTags = mutableListOf("part", "public", "customers")
val customerPartAdditionalData =
mutableMapOf("part" to "data", "complex" to mutableMapOf("nested" to "data"))
val customerPartCreateRequest =
DatasetPartCreateRequest(
name = customerPartName,
sourceName = CUSTOMER_SOURCE_FILE_NAME,
description = customerPartDescription,
tags = customerPartTags,
additionalData = customerPartAdditionalData,
type = DatasetPartTypeEnum.File)

val datasetName = "Shop Dataset"
Expand Down Expand Up @@ -2315,18 +2340,21 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
assertEquals(customerPartName, datasetPartToReplace.name)
assertEquals(customerPartDescription, datasetPartToReplace.description)
assertEquals(customerPartTags, datasetPartToReplace.tags)
assertEquals(customerPartAdditionalData, datasetPartToReplace.additionalData)
assertEquals(CUSTOMER_SOURCE_FILE_NAME, datasetPartToReplace.sourceName)
assertEquals(DatasetPartTypeEnum.File, datasetPartToReplace.type)

// New Part to replace the existing one in the dataset
val newDatasetSourceName = "updatedResourceFile.csv"
val newDatasetPartDescription = "New Data for customer list"
val newDatasetPartTags = mutableListOf("part", "public", "new", "customer")
val newDatasetPartAdditionalData = mutableMapOf<String, Any>("part" to "new data")
val datasetPartUpdateRequest =
DatasetPartUpdateRequest(
sourceName = newDatasetSourceName,
description = newDatasetPartDescription,
tags = newDatasetPartTags,
additionalData = newDatasetPartAdditionalData,
)

val replacedDatasetPart =
Expand All @@ -2347,6 +2375,7 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
assertEquals(newDatasetSourceName, replacedDatasetPart.sourceName)
assertEquals(newDatasetPartDescription, replacedDatasetPart.description)
assertEquals(newDatasetPartTags, replacedDatasetPart.tags)
assertEquals(newDatasetPartAdditionalData, replacedDatasetPart.additionalData)
assertEquals(newDatasetSourceName, replacedDatasetPart.sourceName)
assertEquals(DatasetPartTypeEnum.File, replacedDatasetPart.type)

Expand Down
Loading