Skip to content

Commit 0511604

Browse files
committed
[PROD-14307] Add controller tests for run templates CRUD endpoints
1 parent d603c1f commit 0511604

File tree

2 files changed

+200
-70
lines changed

2 files changed

+200
-70
lines changed

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

Lines changed: 134 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,56 @@ class SolutionControllerTests : ControllerTestBase() {
971971
"organizations/{organization_id}/solutions/{solution_id}/parameterGroups/{parameter_id}/DELETE"))
972972
}
973973

974+
@Test
975+
@WithMockOauth2User
976+
fun list_solution_runTemplate() {
977+
val runTemplateId = "runtemplate1"
978+
979+
val runTemplateName = "this_is_a_name"
980+
val runTemplateLabels = mutableMapOf("fr" to "this_is_a_label")
981+
val runTemplateDescription = "this_is_a_description"
982+
val runTemplateTags = mutableListOf("tag1", "tag2")
983+
val runTemplateComputeSize = "this_is_a_compute_size"
984+
val runTemplateParameterGroups = mutableListOf("parameterGroup1")
985+
val runTemplates =
986+
mutableListOf(
987+
RunTemplateCreateRequest(
988+
runTemplateId,
989+
runTemplateName,
990+
runTemplateLabels,
991+
runTemplateDescription,
992+
runTemplateTags,
993+
runTemplateComputeSize,
994+
RunTemplateResourceSizing(
995+
ResourceSizeInfo("cpu_requests", "memory_requests"),
996+
ResourceSizeInfo("cpu_limits", "memory_limits")),
997+
runTemplateParameterGroups,
998+
10))
999+
1000+
val solutionId =
1001+
createSolutionAndReturnId(
1002+
mvc, organizationId, constructSolutionCreateRequest(runTemplates = runTemplates))
1003+
1004+
mvc.perform(
1005+
get("/organizations/$organizationId/solutions/$solutionId/runTemplates")
1006+
.contentType(MediaType.APPLICATION_JSON))
1007+
.andExpect(status().is2xxSuccessful)
1008+
.andExpect(jsonPath("$[0].id").value(runTemplateId))
1009+
.andExpect(jsonPath("$[0].name").value(runTemplateName))
1010+
.andExpect(jsonPath("$[0].labels").value(runTemplateLabels))
1011+
.andExpect(jsonPath("$[0].description").value(runTemplateDescription))
1012+
.andExpect(jsonPath("$[0].tags").value(runTemplateTags))
1013+
.andExpect(jsonPath("$[0].computeSize").value(runTemplateComputeSize))
1014+
.andExpect(jsonPath("$[0].runSizing.requests.cpu").value("cpu_requests"))
1015+
.andExpect(jsonPath("$[0].runSizing.requests.memory").value("memory_requests"))
1016+
.andExpect(jsonPath("$[0].runSizing.limits.cpu").value("cpu_limits"))
1017+
.andExpect(jsonPath("$[0].runSizing.limits.memory").value("memory_limits"))
1018+
.andExpect(jsonPath("$[0].parameterGroups").value(runTemplateParameterGroups))
1019+
.andExpect(jsonPath("$[0].executionTimeout").value(10))
1020+
.andDo(MockMvcResultHandlers.print())
1021+
.andDo(document("organizations/{organization_id}/solutions/{solution_id}/runTemplates/GET"))
1022+
}
1023+
9741024
@Test
9751025
@WithMockOauth2User
9761026
fun create_solution_runTemplate() {
@@ -1026,46 +1076,54 @@ class SolutionControllerTests : ControllerTestBase() {
10261076

10271077
@Test
10281078
@WithMockOauth2User
1029-
fun delete_solution_runTemplate() {
1030-
1031-
val description = "this_is_a_description"
1032-
val tags = mutableListOf("tag1", "tag2")
1033-
val parameterLabels = mutableMapOf("fr" to "this_is_a_label")
1034-
val parameterGroupId = "parameterGroup1"
1079+
fun get_solution_runTemplate() {
10351080
val runTemplateId = "runtemplate1"
1081+
10361082
val runTemplateName = "this_is_a_name"
1083+
val runTemplateLabels = mutableMapOf("fr" to "this_is_a_label")
1084+
val runTemplateDescription = "this_is_a_description"
1085+
val runTemplateTags = mutableListOf("tag1", "tag2")
10371086
val runTemplateComputeSize = "this_is_a_compute_size"
1038-
val runTemplateRunSizing =
1039-
RunTemplateResourceSizing(
1040-
ResourceSizeInfo("cpu_requests", "memory_requests"),
1041-
ResourceSizeInfo("cpu_limits", "memory_limits"))
1087+
val runTemplateParameterGroups = mutableListOf("parameterGroup1")
10421088
val runTemplates =
10431089
mutableListOf(
10441090
RunTemplateCreateRequest(
10451091
runTemplateId,
10461092
runTemplateName,
1047-
parameterLabels,
1048-
description,
1049-
tags,
1093+
runTemplateLabels,
1094+
runTemplateDescription,
1095+
runTemplateTags,
10501096
runTemplateComputeSize,
1051-
runTemplateRunSizing,
1052-
mutableListOf(parameterGroupId),
1097+
RunTemplateResourceSizing(
1098+
ResourceSizeInfo("cpu_requests", "memory_requests"),
1099+
ResourceSizeInfo("cpu_limits", "memory_limits")),
1100+
runTemplateParameterGroups,
10531101
10))
10541102

10551103
val solutionId =
10561104
createSolutionAndReturnId(
10571105
mvc, organizationId, constructSolutionCreateRequest(runTemplates = runTemplates))
10581106

10591107
mvc.perform(
1060-
delete(
1061-
"/organizations/$organizationId/solutions/$solutionId/runTemplates/$runTemplateId")
1062-
.contentType(MediaType.APPLICATION_JSON)
1063-
.with(csrf()))
1108+
get("/organizations/$organizationId/solutions/$solutionId/runTemplates/$runTemplateId")
1109+
.contentType(MediaType.APPLICATION_JSON))
10641110
.andExpect(status().is2xxSuccessful)
1111+
.andExpect(jsonPath("$.id").value(runTemplateId))
1112+
.andExpect(jsonPath("$.name").value(runTemplateName))
1113+
.andExpect(jsonPath("$.labels").value(runTemplateLabels))
1114+
.andExpect(jsonPath("$.description").value(runTemplateDescription))
1115+
.andExpect(jsonPath("$.tags").value(runTemplateTags))
1116+
.andExpect(jsonPath("$.computeSize").value(runTemplateComputeSize))
1117+
.andExpect(jsonPath("$.runSizing.requests.cpu").value("cpu_requests"))
1118+
.andExpect(jsonPath("$.runSizing.requests.memory").value("memory_requests"))
1119+
.andExpect(jsonPath("$.runSizing.limits.cpu").value("cpu_limits"))
1120+
.andExpect(jsonPath("$.runSizing.limits.memory").value("memory_limits"))
1121+
.andExpect(jsonPath("$.parameterGroups").value(runTemplateParameterGroups))
1122+
.andExpect(jsonPath("$.executionTimeout").value(10))
10651123
.andDo(MockMvcResultHandlers.print())
10661124
.andDo(
10671125
document(
1068-
"organizations/{organization_id}/solutions/{solution_id}/runTemplates/{run_template_id}/DELETE"))
1126+
"organizations/{organization_id}/solutions/{solution_id}/runTemplates/{run_template_id}/GET"))
10691127
}
10701128

10711129
@Test
@@ -1120,24 +1178,68 @@ class SolutionControllerTests : ControllerTestBase() {
11201178
.contentType(MediaType.APPLICATION_JSON)
11211179
.with(csrf()))
11221180
.andExpect(status().is2xxSuccessful)
1123-
.andExpect(jsonPath("$[0].id").value(runTemplateId))
1124-
.andExpect(jsonPath("$[0].name").value(runTemplateName))
1125-
.andExpect(jsonPath("$[0].labels").value(parameterLabels))
1126-
.andExpect(jsonPath("$[0].description").value(description))
1127-
.andExpect(jsonPath("$[0].tags").value(tags))
1128-
.andExpect(jsonPath("$[0].computeSize").value(runTemplateComputeSize))
1129-
.andExpect(jsonPath("$[0].runSizing.requests.cpu").value("cpu_requests2"))
1130-
.andExpect(jsonPath("$[0].runSizing.requests.memory").value("memory_requests2"))
1131-
.andExpect(jsonPath("$[0].runSizing.limits.cpu").value("cpu_limits2"))
1132-
.andExpect(jsonPath("$[0].runSizing.limits.memory").value("memory_limits2"))
1133-
.andExpect(jsonPath("$[0].parameterGroups").value(mutableListOf(parameterGroupId)))
1134-
.andExpect(jsonPath("$[0].executionTimeout").value(100))
1181+
.andExpect(jsonPath("$.id").value(runTemplateId))
1182+
.andExpect(jsonPath("$.name").value(runTemplateName))
1183+
.andExpect(jsonPath("$.labels").value(parameterLabels))
1184+
.andExpect(jsonPath("$.description").value(description))
1185+
.andExpect(jsonPath("$.tags").value(tags))
1186+
.andExpect(jsonPath("$.computeSize").value(runTemplateComputeSize))
1187+
.andExpect(jsonPath("$.runSizing.requests.cpu").value("cpu_requests2"))
1188+
.andExpect(jsonPath("$.runSizing.requests.memory").value("memory_requests2"))
1189+
.andExpect(jsonPath("$.runSizing.limits.cpu").value("cpu_limits2"))
1190+
.andExpect(jsonPath("$.runSizing.limits.memory").value("memory_limits2"))
1191+
.andExpect(jsonPath("$.parameterGroups").value(mutableListOf(parameterGroupId)))
1192+
.andExpect(jsonPath("$.executionTimeout").value(100))
11351193
.andDo(MockMvcResultHandlers.print())
11361194
.andDo(
11371195
document(
11381196
"organizations/{organization_id}/solutions/{solution_id}/runTemplates/{run_template_id}/PATCH"))
11391197
}
11401198

1199+
@Test
1200+
@WithMockOauth2User
1201+
fun delete_solution_runTemplate() {
1202+
1203+
val description = "this_is_a_description"
1204+
val tags = mutableListOf("tag1", "tag2")
1205+
val parameterLabels = mutableMapOf("fr" to "this_is_a_label")
1206+
val parameterGroupId = "parameterGroup1"
1207+
val runTemplateId = "runtemplate1"
1208+
val runTemplateName = "this_is_a_name"
1209+
val runTemplateComputeSize = "this_is_a_compute_size"
1210+
val runTemplateRunSizing =
1211+
RunTemplateResourceSizing(
1212+
ResourceSizeInfo("cpu_requests", "memory_requests"),
1213+
ResourceSizeInfo("cpu_limits", "memory_limits"))
1214+
val runTemplates =
1215+
mutableListOf(
1216+
RunTemplateCreateRequest(
1217+
runTemplateId,
1218+
runTemplateName,
1219+
parameterLabels,
1220+
description,
1221+
tags,
1222+
runTemplateComputeSize,
1223+
runTemplateRunSizing,
1224+
mutableListOf(parameterGroupId),
1225+
10))
1226+
1227+
val solutionId =
1228+
createSolutionAndReturnId(
1229+
mvc, organizationId, constructSolutionCreateRequest(runTemplates = runTemplates))
1230+
1231+
mvc.perform(
1232+
delete(
1233+
"/organizations/$organizationId/solutions/$solutionId/runTemplates/$runTemplateId")
1234+
.contentType(MediaType.APPLICATION_JSON)
1235+
.with(csrf()))
1236+
.andExpect(status().is2xxSuccessful)
1237+
.andDo(MockMvcResultHandlers.print())
1238+
.andDo(
1239+
document(
1240+
"organizations/{organization_id}/solutions/{solution_id}/runTemplates/{run_template_id}/DELETE"))
1241+
}
1242+
11411243
@Test
11421244
@WithMockOauth2User
11431245
fun get_solution_security() {

doc/Apis/SolutionApi.md

Lines changed: 66 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ All URIs are relative to *http://localhost*
88
| [**createSolutionAccessControl**](SolutionApi.md#createSolutionAccessControl) | **POST** /organizations/{organization_id}/solutions/{solution_id}/security/access | Create solution access control |
99
| [**createSolutionParameter**](SolutionApi.md#createSolutionParameter) | **POST** /organizations/{organization_id}/solutions/{solution_id}/parameters | Create solution parameter for a solution |
1010
| [**createSolutionParameterGroup**](SolutionApi.md#createSolutionParameterGroup) | **POST** /organizations/{organization_id}/solutions/{solution_id}/parameterGroups | Create a solution parameter group |
11+
| [**createSolutionRunTemplate**](SolutionApi.md#createSolutionRunTemplate) | **POST** /organizations/{organization_id}/solutions/{solution_id}/runTemplates | Create a solution run template |
1112
| [**deleteSolution**](SolutionApi.md#deleteSolution) | **DELETE** /organizations/{organization_id}/solutions/{solution_id} | Delete a solution |
1213
| [**deleteSolutionAccessControl**](SolutionApi.md#deleteSolutionAccessControl) | **DELETE** /organizations/{organization_id}/solutions/{solution_id}/security/access/{identity_id} | Delete solution access control |
1314
| [**deleteSolutionParameter**](SolutionApi.md#deleteSolutionParameter) | **DELETE** /organizations/{organization_id}/solutions/{solution_id}/parameters/{parameter_id} | Delete specific parameter from the solution |
1415
| [**deleteSolutionParameterGroup**](SolutionApi.md#deleteSolutionParameterGroup) | **DELETE** /organizations/{organization_id}/solutions/{solution_id}/parameterGroups/{parameter_group_id} | Delete a parameter group from the solution |
1516
| [**deleteSolutionRunTemplate**](SolutionApi.md#deleteSolutionRunTemplate) | **DELETE** /organizations/{organization_id}/solutions/{solution_id}/runTemplates/{run_template_id} | Delete a specific run template |
16-
| [**deleteSolutionRunTemplates**](SolutionApi.md#deleteSolutionRunTemplates) | **DELETE** /organizations/{organization_id}/solutions/{solution_id}/runTemplates | Delete all run templates from the solution |
17+
| [**getRunTemplate**](SolutionApi.md#getRunTemplate) | **GET** /organizations/{organization_id}/solutions/{solution_id}/runTemplates/{run_template_id} | Retrieve a solution run templates |
1718
| [**getSolution**](SolutionApi.md#getSolution) | **GET** /organizations/{organization_id}/solutions/{solution_id} | Get the details of a solution |
1819
| [**getSolutionAccessControl**](SolutionApi.md#getSolutionAccessControl) | **GET** /organizations/{organization_id}/solutions/{solution_id}/security/access/{identity_id} | Get solution access control |
1920
| [**getSolutionParameter**](SolutionApi.md#getSolutionParameter) | **GET** /organizations/{organization_id}/solutions/{solution_id}/parameters/{parameter_id} | Get the details of a solution parameter |
2021
| [**getSolutionParameterGroup**](SolutionApi.md#getSolutionParameterGroup) | **GET** /organizations/{organization_id}/solutions/{solution_id}/parameterGroups/{parameter_group_id} | Get details of a solution parameter group |
2122
| [**getSolutionSecurity**](SolutionApi.md#getSolutionSecurity) | **GET** /organizations/{organization_id}/solutions/{solution_id}/security | Get solution security information |
23+
| [**listRunTemplates**](SolutionApi.md#listRunTemplates) | **GET** /organizations/{organization_id}/solutions/{solution_id}/runTemplates | List all solution run templates |
2224
| [**listSolutionParameterGroups**](SolutionApi.md#listSolutionParameterGroups) | **GET** /organizations/{organization_id}/solutions/{solution_id}/parameterGroups | List all solution parameter groups |
2325
| [**listSolutionParameters**](SolutionApi.md#listSolutionParameters) | **GET** /organizations/{organization_id}/solutions/{solution_id}/parameters | List all solution parameters |
2426
| [**listSolutionSecurityUsers**](SolutionApi.md#listSolutionSecurityUsers) | **GET** /organizations/{organization_id}/solutions/{solution_id}/security/users | List solution security users |
@@ -29,7 +31,6 @@ All URIs are relative to *http://localhost*
2931
| [**updateSolutionParameter**](SolutionApi.md#updateSolutionParameter) | **PATCH** /organizations/{organization_id}/solutions/{solution_id}/parameters/{parameter_id} | Update solution parameter |
3032
| [**updateSolutionParameterGroup**](SolutionApi.md#updateSolutionParameterGroup) | **PATCH** /organizations/{organization_id}/solutions/{solution_id}/parameterGroups/{parameter_group_id} | Update a solution parameter group |
3133
| [**updateSolutionRunTemplate**](SolutionApi.md#updateSolutionRunTemplate) | **PATCH** /organizations/{organization_id}/solutions/{solution_id}/runTemplates/{run_template_id} | Update a specific run template |
32-
| [**updateSolutionRunTemplates**](SolutionApi.md#updateSolutionRunTemplates) | **PATCH** /organizations/{organization_id}/solutions/{solution_id}/runTemplates | Update solution run templates |
3334

3435

3536
<a name="createSolution"></a>
@@ -139,6 +140,33 @@ Create a solution parameter group
139140
- **Content-Type**: application/json, application/yaml
140141
- **Accept**: application/json, application/yaml
141142

143+
<a name="createSolutionRunTemplate"></a>
144+
# **createSolutionRunTemplate**
145+
> RunTemplate createSolutionRunTemplate(organization\_id, solution\_id, RunTemplateCreateRequest)
146+
147+
Create a solution run template
148+
149+
### Parameters
150+
151+
|Name | Type | Description | Notes |
152+
|------------- | ------------- | ------------- | -------------|
153+
| **organization\_id** | **String**| the Organization identifier | [default to null] |
154+
| **solution\_id** | **String**| the Solution identifier | [default to null] |
155+
| **RunTemplateCreateRequest** | [**RunTemplateCreateRequest**](../Models/RunTemplateCreateRequest.md)| Run template to create | |
156+
157+
### Return type
158+
159+
[**RunTemplate**](../Models/RunTemplate.md)
160+
161+
### Authorization
162+
163+
[oAuth2AuthCode](../README.md#oAuth2AuthCode)
164+
165+
### HTTP request headers
166+
167+
- **Content-Type**: application/json, application/yaml
168+
- **Accept**: application/json, application/yaml
169+
142170
<a name="deleteSolution"></a>
143171
# **deleteSolution**
144172
> deleteSolution(organization\_id, solution\_id)
@@ -273,22 +301,23 @@ null (empty response body)
273301
- **Content-Type**: Not defined
274302
- **Accept**: Not defined
275303

276-
<a name="deleteSolutionRunTemplates"></a>
277-
# **deleteSolutionRunTemplates**
278-
> deleteSolutionRunTemplates(organization\_id, solution\_id)
304+
<a name="getRunTemplate"></a>
305+
# **getRunTemplate**
306+
> RunTemplate getRunTemplate(organization\_id, solution\_id, run\_template\_id)
279307
280-
Delete all run templates from the solution
308+
Retrieve a solution run templates
281309

282310
### Parameters
283311

284312
|Name | Type | Description | Notes |
285313
|------------- | ------------- | ------------- | -------------|
286314
| **organization\_id** | **String**| the Organization identifier | [default to null] |
287315
| **solution\_id** | **String**| the Solution identifier | [default to null] |
316+
| **run\_template\_id** | **String**| the Run Template identifier | [default to null] |
288317

289318
### Return type
290319

291-
null (empty response body)
320+
[**RunTemplate**](../Models/RunTemplate.md)
292321

293322
### Authorization
294323

@@ -297,7 +326,7 @@ null (empty response body)
297326
### HTTP request headers
298327

299328
- **Content-Type**: Not defined
300-
- **Accept**: Not defined
329+
- **Accept**: application/json, application/yaml
301330

302331
<a name="getSolution"></a>
303332
# **getSolution**
@@ -432,6 +461,32 @@ Get solution security information
432461
- **Content-Type**: Not defined
433462
- **Accept**: application/json, application/yaml
434463

464+
<a name="listRunTemplates"></a>
465+
# **listRunTemplates**
466+
> List listRunTemplates(organization\_id, solution\_id)
467+
468+
List all solution run templates
469+
470+
### Parameters
471+
472+
|Name | Type | Description | Notes |
473+
|------------- | ------------- | ------------- | -------------|
474+
| **organization\_id** | **String**| the Organization identifier | [default to null] |
475+
| **solution\_id** | **String**| the Solution identifier | [default to null] |
476+
477+
### Return type
478+
479+
[**List**](../Models/RunTemplate.md)
480+
481+
### Authorization
482+
483+
[oAuth2AuthCode](../README.md#oAuth2AuthCode)
484+
485+
### HTTP request headers
486+
487+
- **Content-Type**: Not defined
488+
- **Accept**: application/json, application/yaml
489+
435490
<a name="listSolutionParameterGroups"></a>
436491
# **listSolutionParameterGroups**
437492
> List listSolutionParameterGroups(organization\_id, solution\_id)
@@ -677,7 +732,7 @@ Update a solution parameter group
677732

678733
<a name="updateSolutionRunTemplate"></a>
679734
# **updateSolutionRunTemplate**
680-
> List updateSolutionRunTemplate(organization\_id, solution\_id, run\_template\_id, RunTemplate)
735+
> RunTemplate updateSolutionRunTemplate(organization\_id, solution\_id, run\_template\_id, RunTemplateUpdateRequest)
681736
682737
Update a specific run template
683738

@@ -688,38 +743,11 @@ Update a specific run template
688743
| **organization\_id** | **String**| the Organization identifier | [default to null] |
689744
| **solution\_id** | **String**| the Solution identifier | [default to null] |
690745
| **run\_template\_id** | **String**| the Run Template identifier | [default to null] |
691-
| **RunTemplate** | [**RunTemplate**](../Models/RunTemplate.md)| Run template updates | |
746+
| **RunTemplateUpdateRequest** | [**RunTemplateUpdateRequest**](../Models/RunTemplateUpdateRequest.md)| Run template updates | |
692747

693748
### Return type
694749

695-
[**List**](../Models/RunTemplate.md)
696-
697-
### Authorization
698-
699-
[oAuth2AuthCode](../README.md#oAuth2AuthCode)
700-
701-
### HTTP request headers
702-
703-
- **Content-Type**: application/json, application/yaml
704-
- **Accept**: application/json, application/yaml
705-
706-
<a name="updateSolutionRunTemplates"></a>
707-
# **updateSolutionRunTemplates**
708-
> List updateSolutionRunTemplates(organization\_id, solution\_id, RunTemplate)
709-
710-
Update solution run templates
711-
712-
### Parameters
713-
714-
|Name | Type | Description | Notes |
715-
|------------- | ------------- | ------------- | -------------|
716-
| **organization\_id** | **String**| the Organization identifier | [default to null] |
717-
| **solution\_id** | **String**| the Solution identifier | [default to null] |
718-
| **RunTemplate** | [**List**](../Models/RunTemplate.md)| Run templates to update | |
719-
720-
### Return type
721-
722-
[**List**](../Models/RunTemplate.md)
750+
[**RunTemplate**](../Models/RunTemplate.md)
723751

724752
### Authorization
725753

0 commit comments

Comments
 (0)