@@ -570,65 +570,133 @@ class SolutionControllerTests : ControllerTestBase() {
570
570
.andDo(document(" organizations/{organization_id}/solutions/{solution_id}/parameters/POST" ))
571
571
}
572
572
573
- @Test
574
- @WithMockOauth2User
575
- fun get_solution_parameter () {
576
-
577
- val parameterLabels = mutableMapOf (" fr" to " this_is_a_label" )
578
- val parameterVarType = " this_is_a_vartype"
579
- val parameterId = " my_parameter_id"
580
- val parameterDesc = " my_parameter_desc"
581
- val parameterDefaultValue = " this_is_a_default_value"
582
- val parameterMinValue = " this_is_a_minimal_value"
583
- val parameterMaxValue = " this_is_a_maximal_value"
584
- val parameterRegexValidation = " this_is_a_regex_to_validate_value"
585
- val options =
586
- mutableMapOf (
587
- " you_can_put" to " whatever_you_want_here" ,
588
- " even" to JSONObject (mapOf (" object" to " if_you_want" )))
589
- val parameterCreateRequest =
590
- RunTemplateParameterCreateRequest (
591
- parameterId,
592
- parameterVarType,
593
- parameterDesc,
594
- parameterLabels,
595
- parameterDefaultValue,
596
- parameterMinValue,
597
- parameterMaxValue,
598
- parameterRegexValidation,
599
- options)
573
+ @Test
574
+ @WithMockOauth2User
575
+ fun get_solution_parameter () {
600
576
601
- val solutionId =
602
- createSolutionAndReturnId(mvc, organizationId, constructSolutionCreateRequest())
577
+ val parameterLabels = mutableMapOf (" fr" to " this_is_a_label" )
578
+ val parameterVarType = " this_is_a_vartype"
579
+ val parameterId = " my_parameter_id"
580
+ val parameterDesc = " my_parameter_desc"
581
+ val parameterDefaultValue = " this_is_a_default_value"
582
+ val parameterMinValue = " this_is_a_minimal_value"
583
+ val parameterMaxValue = " this_is_a_maximal_value"
584
+ val parameterRegexValidation = " this_is_a_regex_to_validate_value"
585
+ val options =
586
+ mutableMapOf (
587
+ " you_can_put" to " whatever_you_want_here" ,
588
+ " even" to JSONObject (mapOf (" object" to " if_you_want" )))
589
+ val parameterCreateRequest =
590
+ RunTemplateParameterCreateRequest (
591
+ parameterId,
592
+ parameterVarType,
593
+ parameterDesc,
594
+ parameterLabels,
595
+ parameterDefaultValue,
596
+ parameterMinValue,
597
+ parameterMaxValue,
598
+ parameterRegexValidation,
599
+ options)
603
600
604
- mvc.perform(
601
+ val solutionId =
602
+ createSolutionAndReturnId(mvc, organizationId, constructSolutionCreateRequest())
603
+
604
+ mvc.perform(
605
605
post(" /organizations/$organizationId /solutions/$solutionId /parameters" )
606
606
.contentType(MediaType .APPLICATION_JSON )
607
607
.content(JSONObject (parameterCreateRequest).toString())
608
608
.with (csrf()))
609
- .andExpect(status().is2xxSuccessful)
609
+ .andExpect(status().is2xxSuccessful)
610
610
611
- mvc.perform(
611
+ mvc.perform(
612
612
get(" /organizations/$organizationId /solutions/$solutionId /parameters/$parameterId " )
613
613
.contentType(MediaType .APPLICATION_JSON ))
614
- .andExpect(status().is2xxSuccessful)
615
- .andExpect(jsonPath(" $.labels" ).value(parameterLabels))
616
- .andExpect(jsonPath(" $.varType" ).value(parameterVarType))
617
- .andExpect(jsonPath(" $.description" ).value(parameterDesc))
618
- .andExpect(jsonPath(" $.id" ).value(parameterId))
619
- .andExpect(jsonPath(" $.defaultValue" ).value(parameterDefaultValue))
620
- .andExpect(jsonPath(" $.minValue" ).value(parameterMinValue))
621
- .andExpect(jsonPath(" $.maxValue" ).value(parameterMaxValue))
622
- .andExpect(jsonPath(" $.regexValidation" ).value(parameterRegexValidation))
623
- .andExpect(jsonPath(" $.options[\" you_can_put\" ]" ).value(" whatever_you_want_here" ))
624
- .andExpect(jsonPath(" $.options[\" even\" ][\" object\" ]" ).value(" if_you_want" ))
625
- .andDo(MockMvcResultHandlers .print ())
626
- .andDo(document(" organizations/{organization_id}/solutions/{solution_id}/parameters/{parameter_id}/GET" ))
627
- }
628
-
629
-
630
- // TODO missing /parameters/{parameter_id}/PATCH
631
- // TODO missing /parameters/POST
614
+ .andExpect(status().is2xxSuccessful)
615
+ .andExpect(jsonPath(" $.labels" ).value(parameterLabels))
616
+ .andExpect(jsonPath(" $.varType" ).value(parameterVarType))
617
+ .andExpect(jsonPath(" $.description" ).value(parameterDesc))
618
+ .andExpect(jsonPath(" $.id" ).value(parameterId))
619
+ .andExpect(jsonPath(" $.defaultValue" ).value(parameterDefaultValue))
620
+ .andExpect(jsonPath(" $.minValue" ).value(parameterMinValue))
621
+ .andExpect(jsonPath(" $.maxValue" ).value(parameterMaxValue))
622
+ .andExpect(jsonPath(" $.regexValidation" ).value(parameterRegexValidation))
623
+ .andExpect(jsonPath(" $.options[\" you_can_put\" ]" ).value(" whatever_you_want_here" ))
624
+ .andExpect(jsonPath(" $.options[\" even\" ][\" object\" ]" ).value(" if_you_want" ))
625
+ .andDo(MockMvcResultHandlers .print ())
626
+ .andDo(
627
+ document(
628
+ " organizations/{organization_id}/solutions/{solution_id}/parameters/{parameter_id}/GET" ))
629
+ }
630
+
631
+ @Test
632
+ @WithMockOauth2User
633
+ fun update_solution_parameter () {
634
+
635
+ val parameterId = " my_parameter_id"
636
+ val newParameterVarType = " this_is_a_new_vartype"
637
+ val newParameterDesc = " my_new_parameter_desc"
638
+ val newParameterLabels = mutableMapOf (" fr" to " this_is_a_new_label" )
639
+ val newParameterDefaultValue = " this_is_a_new_default_value"
640
+ val newParameterMinValue = " this_is_a_new_minimal_value"
641
+ val newParameterMaxValue = " this_is_a_new_maximal_value"
642
+ val newParameterRegexValidation = " this_is_a_new_regex_to_validate_value"
643
+ val newParameterOptions =
644
+ mutableMapOf (
645
+ " new_you_can_put" to " new_whatever_you_want_here" ,
646
+ " new_even" to JSONObject (mapOf (" new_object" to " new_if_you_want" )))
647
+
648
+ val newParameterUpdateRequest =
649
+ RunTemplateParameterUpdateRequest (
650
+ newParameterDesc,
651
+ newParameterLabels,
652
+ newParameterVarType,
653
+ newParameterDefaultValue,
654
+ newParameterMinValue,
655
+ newParameterMaxValue,
656
+ newParameterRegexValidation,
657
+ newParameterOptions)
658
+
659
+ val solutionId =
660
+ createSolutionAndReturnId(
661
+ mvc,
662
+ organizationId,
663
+ constructSolutionCreateRequest(
664
+ parameters =
665
+ mutableListOf (
666
+ RunTemplateParameterCreateRequest (
667
+ parameterId,
668
+ " this_is_a_vartype" ,
669
+ " my_parameter_desc" ,
670
+ mutableMapOf (" fr" to " this_is_a_label" ),
671
+ " this_is_a_default_value" ,
672
+ " this_is_a_minimal_value" ,
673
+ " this_is_a_maximal_value" ,
674
+ " this_is_a_regex_to_validate_value" ,
675
+ mutableMapOf (
676
+ " you_can_put" to " whatever_you_want_here" ,
677
+ " even" to JSONObject (mapOf (" object" to " if_you_want" )))))))
678
+
679
+ mvc.perform(
680
+ patch(" /organizations/$organizationId /solutions/$solutionId /parameters/$parameterId " )
681
+ .content(JSONObject (newParameterUpdateRequest).toString())
682
+ .contentType(MediaType .APPLICATION_JSON )
683
+ .with (csrf()))
684
+ .andExpect(status().is2xxSuccessful)
685
+ .andExpect(jsonPath(" $.labels" ).value(newParameterLabels))
686
+ .andExpect(jsonPath(" $.varType" ).value(newParameterVarType))
687
+ .andExpect(jsonPath(" $.description" ).value(newParameterDesc))
688
+ .andExpect(jsonPath(" $.id" ).value(parameterId))
689
+ .andExpect(jsonPath(" $.defaultValue" ).value(newParameterDefaultValue))
690
+ .andExpect(jsonPath(" $.minValue" ).value(newParameterMinValue))
691
+ .andExpect(jsonPath(" $.maxValue" ).value(newParameterMaxValue))
692
+ .andExpect(jsonPath(" $.regexValidation" ).value(newParameterRegexValidation))
693
+ .andExpect(jsonPath(" $.options[\" new_you_can_put\" ]" ).value(" new_whatever_you_want_here" ))
694
+ .andExpect(jsonPath(" $.options[\" new_even\" ][\" new_object\" ]" ).value(" new_if_you_want" ))
695
+ .andDo(MockMvcResultHandlers .print ())
696
+ .andDo(
697
+ document(
698
+ " organizations/{organization_id}/solutions/{solution_id}/parameters/{parameter_id}/PATCH" ))
699
+ }
632
700
633
701
@Test
634
702
@WithMockOauth2User
@@ -681,7 +749,7 @@ class SolutionControllerTests : ControllerTestBase() {
681
749
682
750
@Test
683
751
@WithMockOauth2User
684
- fun delete_solution_parameters () {
752
+ fun delete_solution_parameter () {
685
753
686
754
val parameterId = " parameter1"
687
755
val parameterLabels = mutableMapOf (" fr" to " this_is_a_label" )
0 commit comments