Skip to content

Commit b50f34e

Browse files
apply corrections from pull request feedbacks
1 parent ebe6471 commit b50f34e

File tree

8 files changed

+261
-163
lines changed

8 files changed

+261
-163
lines changed

doc/Models/Workspace.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
| **ownerId** | **String** | the user id which own this workspace. set by the API from Authentification service receved id | [default to null] |
1515
| **solution** | [**WorkspaceSolution**](WorkspaceSolution.md) | | [default to null] |
1616
| **webApp** | [**WorkspaceWebApp**](WorkspaceWebApp.md) | | [optional] [default to null] |
17-
| **sendInputToDataWarehouse** | **Boolean** | default setting for all Scenarios and Run Templates to set whether or not the Dataset values and the input parameters values are send to the DataWarehouse prior to the ScenarioRun | [optional] [default to null] |
18-
| **useDedicatedEventHubNamespace** | **Boolean** | Set this property to true to use a dedicated Azure Event Hub Namespace for this Workspace. The Event Hub Namespace must be named \\'<organization_id\\>-<workspace_id\\>\\' (in lower case). This Namespace must also contain two Event Hubs named \\'probesmeasures\\' and \\'scenariorun\\'. | [optional] [default to false] |
19-
| **dedicatedEventHubSasKeyName** | **String** | the Dedicated Event Hub SAS key name, default to RootManageSharedAccessKey. Ask you DevOps Team to add the associated value to your Workspace Secret | [optional] [default to null] |
20-
| **dedicatedEventHubAuthenticationStrategy** | **String** | the Event Hub authentication strategy, SHARED_ACCESS_POLICY or TENANT_CLIENT_CREDENTIALS. Default to the one defined for the tenant. | [optional] [default to null] |
21-
| **sendScenarioRunToEventHub** | **Boolean** | default setting for all Scenarios and Run Templates to set whether or not the ScenarioRun is send to the Event Hub | [optional] [default to true] |
22-
| **sendScenarioMetadataToEventHub** | **Boolean** | Set this property to false to not send scenario metada to Azure Event Hub Namespace for this Workspace. The Event Hub Namespace must be named \\'<organization_id\\>-<workspace_id\\>\\' (in lower case). This Namespace must also contain two Event Hubs named \\'scenariometadata\\' and \\'scenariorunmetadata\\'. | [optional] [default to false] |
2317
| **datasetCopy** | **Boolean** | Activate the copy of dataset on scenario creation, meaning that each scenario created in this workspace will make this copy. when false, scenario use directly the dataset specified. | [optional] [default to true] |
2418
| **security** | [**WorkspaceSecurity**](WorkspaceSecurity.md) | | [default to null] |
2519

doc/Models/WorkspaceCreateRequest.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
| **tags** | **List** | the list of tags | [optional] [default to null] |
1111
| **solution** | [**WorkspaceSolution**](WorkspaceSolution.md) | | [default to null] |
1212
| **webApp** | [**WorkspaceWebApp**](WorkspaceWebApp.md) | | [optional] [default to null] |
13-
| **sendInputToDataWarehouse** | **Boolean** | default setting for all Scenarios and Run Templates to set whether or not the Dataset values and the input parameters values are send to the DataWarehouse prior to the ScenarioRun | [optional] [default to null] |
14-
| **useDedicatedEventHubNamespace** | **Boolean** | Set this property to true to use a dedicated Azure Event Hub Namespace for this Workspace. | [optional] [default to false] |
15-
| **dedicatedEventHubSasKeyName** | **String** | the Dedicated Event Hub SAS key name, default to RootManageSharedAccessKey | [optional] [default to null] |
16-
| **dedicatedEventHubAuthenticationStrategy** | **String** | the Event Hub authentication strategy | [optional] [default to null] |
17-
| **sendScenarioRunToEventHub** | **Boolean** | default setting for all Scenarios and Run Templates | [optional] [default to true] |
18-
| **sendScenarioMetadataToEventHub** | **Boolean** | Set this property to false to not send scenario metada | [optional] [default to false] |
1913
| **datasetCopy** | **Boolean** | Activate the copy of dataset on scenario creation | [optional] [default to true] |
2014
| **security** | [**WorkspaceSecurity**](WorkspaceSecurity.md) | | [optional] [default to null] |
2115

doc/Models/WorkspaceUpdateRequest.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33

44
| Name | Type | Description | Notes |
55
|------------ | ------------- | ------------- | -------------|
6-
| **key** | **String** | technical key for resource name convention and version grouping. Must be unique | [default to null] |
7-
| **name** | **String** | Workspace name | [default to null] |
6+
| **key** | **String** | technical key for resource name convention and version grouping. Must be unique | [optional] [default to null] |
7+
| **name** | **String** | Workspace name | [optional] [default to null] |
88
| **description** | **String** | the Workspace description | [optional] [default to null] |
99
| **tags** | **List** | the list of tags | [optional] [default to null] |
1010
| **solution** | [**WorkspaceSolution**](WorkspaceSolution.md) | | [optional] [default to null] |
1111
| **webApp** | [**WorkspaceWebApp**](WorkspaceWebApp.md) | | [optional] [default to null] |
12-
| **sendInputToDataWarehouse** | **Boolean** | default setting for all Scenarios and Run Templates | [optional] [default to null] |
13-
| **useDedicatedEventHubNamespace** | **Boolean** | Set this property to true to use a dedicated Azure Event Hub Namespace | [optional] [default to null] |
14-
| **dedicatedEventHubSasKeyName** | **String** | the Dedicated Event Hub SAS key name | [optional] [default to null] |
15-
| **dedicatedEventHubAuthenticationStrategy** | **String** | the Event Hub authentication strategy | [optional] [default to null] |
16-
| **sendScenarioRunToEventHub** | **Boolean** | default setting for all Scenarios and Run Templates | [optional] [default to null] |
17-
| **sendScenarioMetadataToEventHub** | **Boolean** | Set this property to false to not send scenario metadata | [optional] [default to null] |
1812
| **datasetCopy** | **Boolean** | Activate the copy of dataset on scenario creation | [optional] [default to null] |
1913

2014
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

openapi/plantuml/schemas.plantuml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,6 @@ entity Workspace {
496496
* ownerId: String
497497
* solution: WorkspaceSolution
498498
webApp: WorkspaceWebApp
499-
sendInputToDataWarehouse: Boolean
500-
useDedicatedEventHubNamespace: Boolean
501-
dedicatedEventHubSasKeyName: String
502-
dedicatedEventHubAuthenticationStrategy: String
503-
sendScenarioRunToEventHub: Boolean
504-
sendScenarioMetadataToEventHub: Boolean
505499
datasetCopy: Boolean
506500
* security: WorkspaceSecurity
507501
}
@@ -519,12 +513,6 @@ entity WorkspaceCreateRequest {
519513
tags: List<String>
520514
* solution: WorkspaceSolution
521515
webApp: WorkspaceWebApp
522-
sendInputToDataWarehouse: Boolean
523-
useDedicatedEventHubNamespace: Boolean
524-
dedicatedEventHubSasKeyName: String
525-
dedicatedEventHubAuthenticationStrategy: String
526-
sendScenarioRunToEventHub: Boolean
527-
sendScenarioMetadataToEventHub: Boolean
528516
datasetCopy: Boolean
529517
security: WorkspaceSecurity
530518
}
@@ -549,18 +537,12 @@ entity WorkspaceSolution {
549537
}
550538

551539
entity WorkspaceUpdateRequest {
552-
* key: String
553-
* name: String
540+
key: String
541+
name: String
554542
description: String
555543
tags: List<String>
556544
solution: WorkspaceSolution
557545
webApp: WorkspaceWebApp
558-
sendInputToDataWarehouse: Boolean
559-
useDedicatedEventHubNamespace: Boolean
560-
dedicatedEventHubSasKeyName: String
561-
dedicatedEventHubAuthenticationStrategy: String
562-
sendScenarioRunToEventHub: Boolean
563-
sendScenarioMetadataToEventHub: Boolean
564546
datasetCopy: Boolean
565547
}
566548

run/src/test/kotlin/com/cosmotech/run/ContainerFactoryTests.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,6 @@ class ContainerFactoryTests {
249249
}
250250

251251
private fun getWorkspace(
252-
dedicatedEventHubNamespace: Boolean? = null,
253-
sendToScenarioRun: Boolean? = true,
254-
sasAuthentication: String? = null,
255-
sasName: String? = null
256252
): Workspace {
257253
return Workspace(
258254
id = "Workspaceid",
@@ -266,10 +262,6 @@ class ContainerFactoryTests {
266262
WorkspaceSolution(
267263
solutionId = "1",
268264
),
269-
useDedicatedEventHubNamespace = dedicatedEventHubNamespace,
270-
sendScenarioRunToEventHub = sendToScenarioRun,
271-
dedicatedEventHubAuthenticationStrategy = sasAuthentication,
272-
dedicatedEventHubSasKeyName = sasName,
273265
security = WorkspaceSecurity(default = ROLE_ADMIN, accessControlList = mutableListOf())
274266
)
275267
}

workspace/src/integrationTest/kotlin/com/cosmotech/workspace/service/WorkspaceServiceIntegrationTest.kt

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import com.cosmotech.workspace.domain.WorkspaceRole
3939
import com.cosmotech.workspace.domain.WorkspaceSecurity
4040
import com.cosmotech.workspace.domain.WorkspaceSolution
4141
import com.cosmotech.workspace.domain.WorkspaceUpdateRequest
42+
import com.cosmotech.workspace.domain.WorkspaceWebApp
4243
import com.redis.om.spring.RediSearchIndexer
4344
import io.mockk.every
4445
import io.mockk.junit5.MockKExtension
@@ -489,6 +490,227 @@ class WorkspaceServiceIntegrationTest : CsmRedisTestBase() {
489490
}
490491
}
491492

493+
@Test
494+
fun `assert createWorkspace take all infos in considerations`(){
495+
val workspaceToCreate = Workspace(
496+
id = "id",
497+
organizationId = organizationSaved.id,
498+
key = "key",
499+
name = "name",
500+
ownerId = "ownerId",
501+
solution = WorkspaceSolution(solutionSaved.id!!),
502+
description = "description",
503+
linkedDatasetIdList = null,
504+
version = "1.0.0",
505+
tags = mutableListOf("tag1", "tag2"),
506+
webApp = WorkspaceWebApp(url = "url"),
507+
datasetCopy = true,
508+
security = WorkspaceSecurity(
509+
default = ROLE_NONE,
510+
accessControlList = mutableListOf(WorkspaceAccessControl("id", ROLE_ADMIN))),
511+
)
512+
val workspaceCreateRequest = WorkspaceCreateRequest(
513+
key = workspaceToCreate.key,
514+
name = workspaceToCreate.name,
515+
solution = workspaceToCreate.solution,
516+
description = workspaceToCreate.description,
517+
version = workspaceToCreate.version,
518+
tags = workspaceToCreate.tags,
519+
webApp = workspaceToCreate.webApp,
520+
datasetCopy = workspaceToCreate.datasetCopy,
521+
security = workspaceToCreate.security
522+
)
523+
524+
workspaceSaved = workspaceApiService.createWorkspace(organizationSaved.id, workspaceCreateRequest)
525+
526+
workspaceToCreate.id = workspaceSaved.id
527+
workspaceToCreate.ownerId = workspaceSaved.ownerId
528+
assertEquals(workspaceToCreate, workspaceSaved)
529+
}
530+
531+
@Test
532+
fun `assert updateWorkspace take all infos in considerations`() {
533+
var workspaceToCreate = Workspace(
534+
id = "id",
535+
organizationId = organizationSaved.id,
536+
key = "key",
537+
name = "name",
538+
ownerId = "ownerId",
539+
solution = WorkspaceSolution(solutionSaved.id!!),
540+
description = "description",
541+
linkedDatasetIdList = null,
542+
version = "1.0.0",
543+
tags = mutableListOf("tag1", "tag2"),
544+
webApp = WorkspaceWebApp(url = "url"),
545+
datasetCopy = true,
546+
security = WorkspaceSecurity(
547+
default = ROLE_ADMIN,
548+
accessControlList = mutableListOf(WorkspaceAccessControl("id", ROLE_ADMIN))),
549+
)
550+
val workspaceCreateRequest = WorkspaceCreateRequest(
551+
key = workspaceToCreate.key,
552+
name = workspaceToCreate.name,
553+
solution = workspaceToCreate.solution,
554+
description = workspaceToCreate.description,
555+
version = workspaceToCreate.version,
556+
tags = workspaceToCreate.tags,
557+
webApp = workspaceToCreate.webApp,
558+
datasetCopy = workspaceToCreate.datasetCopy,
559+
security = workspaceToCreate.security
560+
)
561+
workspaceSaved = workspaceApiService.createWorkspace(organizationSaved.id, workspaceCreateRequest)
562+
solutionSaved = solutionApiService.createSolution(organizationSaved.id, solution)
563+
val workspaceUpdateRequest = WorkspaceUpdateRequest(
564+
key = "new key",
565+
name = "new name",
566+
solution = WorkspaceSolution(solutionSaved.id!!),
567+
description = "new description",
568+
tags = mutableListOf("newTag1", "newTag2"),
569+
webApp = WorkspaceWebApp(url = "new url"),
570+
datasetCopy = false,
571+
)
572+
workspaceToCreate = workspaceToCreate.copy(
573+
id = workspaceSaved.id,
574+
key = workspaceUpdateRequest.key!!,
575+
name = workspaceUpdateRequest.name!!,
576+
ownerId = workspaceSaved.ownerId,
577+
solution = workspaceUpdateRequest.solution!!,
578+
description = workspaceUpdateRequest.description,
579+
tags = workspaceUpdateRequest.tags,
580+
webApp = workspaceUpdateRequest.webApp,
581+
datasetCopy = workspaceUpdateRequest.datasetCopy
582+
)
583+
584+
workspaceSaved = workspaceApiService.updateWorkspace(organizationSaved.id, workspaceSaved.id, workspaceUpdateRequest)
585+
586+
assertEquals(workspaceToCreate, workspaceSaved)
587+
}
588+
589+
@Test
590+
fun `test createWorkspace with insufficient parameters`() {
591+
logger.info("should fail when creating workspace with missing key")
592+
val noKeyRequest = WorkspaceCreateRequest(
593+
key = "", // Empty key
594+
name = "Test Workspace",
595+
solution = WorkspaceSolution(solutionSaved.id!!)
596+
)
597+
assertThrows<IllegalArgumentException> {
598+
workspaceApiService.createWorkspace(organizationSaved.id, noKeyRequest)
599+
}
600+
601+
logger.info("should fail when creating workspace with missing name")
602+
val noNameRequest = WorkspaceCreateRequest(
603+
key = "test-key",
604+
name = "", // Empty name
605+
solution = WorkspaceSolution(solutionSaved.id!!)
606+
)
607+
assertThrows<IllegalArgumentException> {
608+
workspaceApiService.createWorkspace(organizationSaved.id, noNameRequest)
609+
}
610+
611+
logger.info("should fail when creating workspace with invalid solution")
612+
val invalidSolutionRequest = WorkspaceCreateRequest(
613+
key = "test-key",
614+
name = "Test Workspace",
615+
solution = WorkspaceSolution("") // Empty solution ID
616+
)
617+
assertThrows<IllegalArgumentException> {
618+
workspaceApiService.createWorkspace(organizationSaved.id, invalidSolutionRequest)
619+
}
620+
}
621+
622+
@Test
623+
fun `test updateWorkspace apply only specified changes`() {
624+
val workspace = makeWorkspaceCreateRequest()
625+
workspaceSaved = workspaceApiService.createWorkspace(organizationSaved.id, workspace)
626+
627+
workspaceSaved = workspaceApiService.updateWorkspace(
628+
organizationSaved.id,
629+
workspaceSaved.id,
630+
WorkspaceUpdateRequest(
631+
key = "new_key"
632+
)
633+
)
634+
assertEquals("new_key", workspaceSaved.key)
635+
assertEquals(workspace.name, workspaceSaved.name)
636+
assertEquals(workspace.solution, workspaceSaved.solution)
637+
assertEquals(workspace.security, workspaceSaved.security)
638+
}
639+
640+
@Test
641+
fun `test updateWorkspace can't be called with only null or empty values`() {
642+
val workspace = makeWorkspaceCreateRequest()
643+
workspaceSaved = workspaceApiService.createWorkspace(organizationSaved.id, workspace)
644+
645+
assertThrows<IllegalArgumentException> {
646+
workspaceSaved = workspaceApiService.updateWorkspace(
647+
organizationSaved.id,
648+
workspaceSaved.id,
649+
WorkspaceUpdateRequest(
650+
key = ""
651+
)
652+
)
653+
}
654+
}
655+
656+
@Test
657+
fun `test createWorkspace and updateWorkspace with no parameters`() {
658+
logger.info("should fail when creating workspace with empty request")
659+
assertThrows<IllegalArgumentException> {
660+
workspaceApiService.createWorkspace(
661+
organizationSaved.id,
662+
WorkspaceCreateRequest(
663+
key = "",
664+
name = "",
665+
solution = WorkspaceSolution("") // Empty solution ID
666+
)
667+
)
668+
}
669+
670+
val workspace = makeWorkspaceCreateRequest()
671+
workspaceSaved = workspaceApiService.createWorkspace(organizationSaved.id, workspace)
672+
673+
logger.info("should fail when updating workspace with empty request")
674+
assertThrows<IllegalArgumentException> {
675+
workspaceApiService.updateWorkspace(
676+
organizationSaved.id,
677+
workspaceSaved.id,
678+
WorkspaceUpdateRequest(
679+
key = "",
680+
name = ""
681+
)
682+
)
683+
}
684+
}
685+
686+
@Test
687+
fun `test createWorkspace and updateWorkspace with only required parameters`() {
688+
logger.info("should create workspace with only required parameters")
689+
val minimalRequest = WorkspaceCreateRequest(
690+
key = "minimal-key",
691+
name = "Minimal Workspace",
692+
solution = WorkspaceSolution(solutionSaved.id!!)
693+
)
694+
val createdWorkspace = workspaceApiService.createWorkspace(organizationSaved.id, minimalRequest)
695+
assertEquals("minimal-key", createdWorkspace.key)
696+
assertEquals("Minimal Workspace", createdWorkspace.name)
697+
assertEquals(solutionSaved.id, createdWorkspace.solution.solutionId)
698+
assertNull(createdWorkspace.description)
699+
assertNull(createdWorkspace.webApp)
700+
701+
logger.info("should update workspace with only required parameters")
702+
val updatedWorkspace = workspaceApiService.updateWorkspace(
703+
organizationSaved.id,
704+
createdWorkspace.id,
705+
WorkspaceUpdateRequest(key = "updated-key", name = "Updated Workspace")
706+
)
707+
assertEquals("updated-key", updatedWorkspace.key)
708+
assertEquals("Updated Workspace", updatedWorkspace.name)
709+
assertEquals(createdWorkspace.solution, updatedWorkspace.solution)
710+
assertEquals(createdWorkspace.description, updatedWorkspace.description)
711+
assertEquals(createdWorkspace.webApp, updatedWorkspace.webApp)
712+
}
713+
492714
fun makeOrganizationCreateRequest(
493715
id: String,
494716
userName: String = CONNECTED_ADMIN_USER,

0 commit comments

Comments
 (0)