Skip to content

Commit

Permalink
feat: set ListProductUsers to getUsersById on endpoint institutions/{…
Browse files Browse the repository at this point in the history
…institutionId}/users/{userId} (#493)
  • Loading branch information
manuraf authored Oct 31, 2024
1 parent b356060 commit 7a1d02d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 129 deletions.
66 changes: 0 additions & 66 deletions app/src/main/resources/swagger/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GeographicTaxonomyList> 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
Expand Down

0 comments on commit 7a1d02d

Please sign in to comment.