From 7a1d02d02dfc1a316c28aea731d916e0e175a295 Mon Sep 17 00:00:00 2001 From: Manuel Rafeli Date: Thu, 31 Oct 2024 12:51:09 +0100 Subject: [PATCH] feat: set ListProductUsers to getUsersById on endpoint institutions/{institutionId}/users/{userId} (#493) --- app/src/main/resources/swagger/api-docs.json | 66 ------------------- .../web/controller/InstitutionController.java | 28 -------- .../controller/InstitutionV2Controller.java | 2 +- .../controller/InstitutionControllerTest.java | 34 ---------- 4 files changed, 1 insertion(+), 129 deletions(-) diff --git a/app/src/main/resources/swagger/api-docs.json b/app/src/main/resources/swagger/api-docs.json index 2a13dd80..14c396cb 100644 --- a/app/src/main/resources/swagger/api-docs.json +++ b/app/src/main/resources/swagger/api-docs.json @@ -390,72 +390,6 @@ } ] } }, - "/v1/institutions/{institutionId}/geographicTaxonomy" : { - "put" : { - "tags" : [ "institutions" ], - "summary" : "updateInstitutionGeographicTaxonomyDeprecated", - "description" : "Service to update the geographic taxonomy of an onboarded institution", - "operationId" : "updateInstitutionGeographicTaxonomyDeprecatedUsingPUT", - "parameters" : [ { - "name" : "institutionId", - "in" : "path", - "description" : "Institution's unique internal identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/GeographicTaxonomyListDto" - } - } - } - }, - "responses" : { - "200" : { - "description" : "OK" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "401" : { - "description" : "Unauthorized", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "deprecated" : true, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, "/v1/institutions/{institutionId}/institutions" : { "get" : { "tags" : [ "institutions" ], diff --git a/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionController.java b/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionController.java index f5d8782a..61ed63d1 100644 --- a/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionController.java +++ b/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionController.java @@ -97,34 +97,6 @@ public InstitutionResource getInstitution(@ApiParam("${swagger.dashboard.institu return result; } - /** - * - * @param institutionId - * @param geographicTaxonomyListDto - * @deprecated - */ - @Deprecated(forRemoval = true) - @PutMapping(value = "/{institutionId}/geographicTaxonomy", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.OK) - @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.updateInstitutionGeographicTaxonomy}") - @PreAuthorize("hasPermission(new it.pagopa.selfcare.dashboard.web.security.FilterAuthorityDomain(#institutionId, null, null), 'Selc:ViewInstitutionData')") - public void updateInstitutionGeographicTaxonomyDeprecated(@ApiParam("${swagger.dashboard.institutions.model.id}") - @PathVariable("institutionId") - String institutionId, - @ApiParam("${swagger.dashboard.institutions.model.geographicTaxonomy}") - @RequestBody - @Valid - GeographicTaxonomyListDto geographicTaxonomyListDto) { - log.trace("updateInstitutionGeographicTaxonomy start"); - log.debug("updateInstitutionGeographicTaxonomy institutionId = {}, geographic taxonomies = {}", Encode.forJava(institutionId), Encode.forJava(geographicTaxonomyListDto.toString())); - GeographicTaxonomyList geographicTaxonomies = new GeographicTaxonomyList(); - geographicTaxonomies.setGeographicTaxonomyList(geographicTaxonomyListDto.getGeographicTaxonomyDtoList().stream().map(GeographicTaxonomyMapper::fromDto).toList()); - institutionService.updateInstitutionGeographicTaxonomy(institutionId, geographicTaxonomies); - log.trace("updateInstitutionsGeographicTaxonomy end"); - } - - - @PutMapping(value = "/{institutionId}/geographic-taxonomy", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.updateInstitutionGeographicTaxonomy}") diff --git a/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionV2Controller.java b/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionV2Controller.java index 2f5f4d32..26ad346c 100644 --- a/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionV2Controller.java +++ b/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionV2Controller.java @@ -58,7 +58,7 @@ public class InstitutionV2Controller { @GetMapping(value = "/{institutionId}/users/{userId}", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.getInstitutionUser}", nickname = "v2RetrieveInstitutionUser") - @PreAuthorize("hasPermission(new it.pagopa.selfcare.dashboard.web.security.FilterAuthorityDomain(#institutionId, null, null), 'Selc:ManageProductUsers')") + @PreAuthorize("hasPermission(new it.pagopa.selfcare.dashboard.web.security.FilterAuthorityDomain(#institutionId, null, null), 'Selc:ListProductUsers')") public InstitutionUserDetailsResource getInstitutionUser(@ApiParam("${swagger.dashboard.institutions.model.id}") @PathVariable("institutionId") String institutionId, diff --git a/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionControllerTest.java b/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionControllerTest.java index 8072d1c6..ee36a267 100644 --- a/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionControllerTest.java +++ b/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionControllerTest.java @@ -148,40 +148,6 @@ void getProductsTree_empty() throws Exception { verifyNoMoreInteractions(institutionServiceMock); } - @Test - void updateInstitutionGeographicTaxonomy() throws Exception { - // given - String institutionId = "institutionId"; - GeographicTaxonomyDto geographicTaxonomyDto = new GeographicTaxonomyDto(); - geographicTaxonomyDto.setCode("code"); - geographicTaxonomyDto.setDesc("desc"); - - GeographicTaxonomyListDto geographicTaxonomyListDto = new GeographicTaxonomyListDto(); - geographicTaxonomyListDto.setGeographicTaxonomyDtoList(List.of(geographicTaxonomyDto)); - - GeographicTaxonomyList geographicTaxonomies = new GeographicTaxonomyList(); - geographicTaxonomies.setGeographicTaxonomyList(geographicTaxonomyListDto.getGeographicTaxonomyDtoList().stream().map(GeographicTaxonomyMapper::fromDto).toList()); - - doNothing().when(institutionServiceMock).updateInstitutionGeographicTaxonomy(institutionId, geographicTaxonomies); - - // when - mockMvc.perform(MockMvcRequestBuilders - .put(BASE_URL + "/" + institutionId + "/geographicTaxonomy") - .content(objectMapper.writeValueAsString(geographicTaxonomyListDto)) - .contentType(APPLICATION_JSON_VALUE) - .accept(APPLICATION_JSON_VALUE)) - .andExpect(status().isOk()); - - // then - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(GeographicTaxonomyList.class); - verify(institutionServiceMock, times(1)) - .updateInstitutionGeographicTaxonomy(eq(institutionId), argumentCaptor.capture()); - GeographicTaxonomyList capturedGeographicTaxonomies = argumentCaptor.getValue(); - assertEquals(geographicTaxonomies.getGeographicTaxonomyList().get(0).getCode(), capturedGeographicTaxonomies.getGeographicTaxonomyList().get(0).getCode()); - assertEquals(geographicTaxonomies.getGeographicTaxonomyList().get(0).getDesc(), capturedGeographicTaxonomies.getGeographicTaxonomyList().get(0).getDesc()); - verifyNoMoreInteractions(institutionServiceMock); - } - @Test void updateInstitutionDescription_ok() throws Exception { //given