Skip to content

Commit a9a3700

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

File tree

8 files changed

+117
-162
lines changed

8 files changed

+117
-162
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: 97 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,102 @@ 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+
492589
fun makeOrganizationCreateRequest(
493590
id: String,
494591
userName: String = CONNECTED_ADMIN_USER,

workspace/src/main/kotlin/com/cosmotech/workspace/service/WorkspaceServiceImpl.kt

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,24 @@ internal class WorkspaceServiceImpl(
119119
// Validate Solution ID
120120
workspaceCreateRequest.solution.solutionId.let { solutionService.findSolutionById(organizationId, it) }
121121

122-
123122
val workspaceId = idGenerator.generate("workspace")
124123
val security = csmRbac.initSecurity(
125124
workspaceCreateRequest.security.toGenericSecurity(workspaceId)).toResourceSecurity()
126125
val createdWorkspace =
127126
Workspace(
128-
id = workspaceId,
129-
organizationId = organizationId,
130-
ownerId = getCurrentAuthenticatedUserName(csmPlatformProperties),
131-
key = workspaceCreateRequest.key,
132-
name = workspaceCreateRequest.name,
133-
solution = workspaceCreateRequest.solution,
134-
security = security)
127+
id = workspaceId,
128+
organizationId = organizationId,
129+
ownerId = getCurrentAuthenticatedUserName(csmPlatformProperties),
130+
key = workspaceCreateRequest.key,
131+
name = workspaceCreateRequest.name,
132+
solution = workspaceCreateRequest.solution,
133+
security = security,
134+
version = workspaceCreateRequest.version,
135+
tags = workspaceCreateRequest.tags,
136+
description = workspaceCreateRequest.description,
137+
webApp = workspaceCreateRequest.webApp,
138+
datasetCopy = workspaceCreateRequest.datasetCopy,
139+
)
135140

136141
return workspaceRepository.save(createdWorkspace)
137142
}
@@ -149,21 +154,15 @@ internal class WorkspaceServiceImpl(
149154
val existingWorkspace = this.getVerifiedWorkspace(organizationId, workspaceId, PERMISSION_WRITE)
150155
// Security cannot be changed by updateWorkspace
151156
val updatedWorkspace = Workspace(
152-
key = workspaceUpdateRequest.key,
153-
name = workspaceUpdateRequest.name,
157+
key = workspaceUpdateRequest.key ?: existingWorkspace.key,
158+
name = workspaceUpdateRequest.name ?: existingWorkspace.name,
154159
solution = workspaceUpdateRequest.solution ?: existingWorkspace.solution,
155160
id = existingWorkspace.id,
156161
organizationId = organizationId,
157-
description = workspaceUpdateRequest.description ?: "",
162+
description = workspaceUpdateRequest.description ?: existingWorkspace.description,
158163
tags = workspaceUpdateRequest.tags,
159164
ownerId = existingWorkspace.ownerId,
160165
webApp = workspaceUpdateRequest.webApp,
161-
sendInputToDataWarehouse = workspaceUpdateRequest.sendInputToDataWarehouse,
162-
useDedicatedEventHubNamespace = workspaceUpdateRequest.useDedicatedEventHubNamespace,
163-
dedicatedEventHubSasKeyName = workspaceUpdateRequest.dedicatedEventHubSasKeyName,
164-
dedicatedEventHubAuthenticationStrategy = workspaceUpdateRequest.dedicatedEventHubAuthenticationStrategy,
165-
sendScenarioRunToEventHub = workspaceUpdateRequest.sendScenarioRunToEventHub,
166-
sendScenarioMetadataToEventHub = workspaceUpdateRequest.sendScenarioMetadataToEventHub,
167166
datasetCopy = workspaceUpdateRequest.datasetCopy,
168167
security = existingWorkspace.security
169168
)

0 commit comments

Comments
 (0)