Skip to content

Commit

Permalink
make productId params optionals in getContract and getInstitutionUser…
Browse files Browse the repository at this point in the history
…sByProduct, rename userId param
  • Loading branch information
giulia-tremolada committed Sep 5, 2024
1 parent e0d11d0 commit 09e3d22
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
8 changes: 4 additions & 4 deletions app/src/main/resources/swagger/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
},
"/v2/institutions" : {
"get" : {
"tags" : [ "Institution", "external-pnpg", "external-v2" ],
"tags" : [ "Institution", "external-pnpg" ],
"summary" : "getInstitutions",
"description" : "The service retrieves all the onboarded institutions related to the logged user",
"operationId" : "getInstitutionsUsingGETDeprecated",
Expand Down Expand Up @@ -301,7 +301,7 @@
"name" : "productId",
"in" : "query",
"description" : "Product's unique identifier",
"required" : true,
"required" : false,
"style" : "form",
"schema" : {
"type" : "string"
Expand Down Expand Up @@ -469,13 +469,13 @@
"name" : "productId",
"in" : "query",
"description" : "Product's unique identifier",
"required" : true,
"required" : false,
"style" : "form",
"schema" : {
"type" : "string"
}
}, {
"name" : "userId",
"name" : "userIdForAuth",
"in" : "query",
"description" : "User's unique identifier",
"required" : false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class InstitutionV2Controller {

@Tag(name = "Institution")
@Tag(name = "external-pnpg")
@Tag(name = "external-v2")
@GetMapping(value = "")
@ResponseStatus(HttpStatus.OK)
@Deprecated
Expand Down Expand Up @@ -77,7 +76,7 @@ public List<InstitutionResource> getInstitutions(@ApiParam("${swagger.external_a
public ResponseEntity<byte[]> getContract(@ApiParam("${swagger.external_api.institutions.model.id}")
@PathVariable("institutionId") String institutionId,
@ApiParam("${swagger.external_api.products.model.id}")
@RequestParam(value = "productId") String productId){
@RequestParam(value = "productId", required = false) String productId){
log.trace("getContract start");
log.debug("getContract institutionId = {}, productId = {}", institutionId, productId);
ResourceResponse contract = contractService.getContractV2(institutionId, productId);
Expand Down Expand Up @@ -120,10 +119,10 @@ public List<ProductResource> getInstitutionProducts(@ApiParam("${swagger.externa
public List<UserResource> getInstitutionUsersByProduct(@ApiParam("${swagger.external_api.institutions.model.id}")
@PathVariable("institutionId") String institutionId,
@ApiParam("${swagger.external_api.products.model.id}")
@RequestParam("productId")
@RequestParam(value = "productId", required = false)
String productId,
@ApiParam("${swagger.external_api.user.model.id}")
@RequestParam(value = "userId", required = false)
@RequestParam(value = "userIdForAuth", required = false)
Optional<String> userId,
@ApiParam("${swagger.external_api.model.productRoles}")
@RequestParam(value = "productRoles", required = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import it.pagopa.selfcare.external_api.model.documents.ResourceResponse;
import it.pagopa.selfcare.external_api.model.onboarding.OnboardedInstitutionResource;
import it.pagopa.selfcare.external_api.model.user.UserProductResponse;
import it.pagopa.selfcare.external_api.web.model.mapper.*;
import it.pagopa.selfcare.external_api.web.model.mapper.InstitutionResourceMapperImpl;
import it.pagopa.selfcare.external_api.web.model.mapper.ProductsMapper;
import it.pagopa.selfcare.external_api.web.model.mapper.ProductsMapperImpl;
import it.pagopa.selfcare.product.entity.Product;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -204,15 +204,6 @@ void getContractOk() throws Exception {
.andExpect(content().bytes(resourceResponse.getData()));
}

@Test
void getContractOkWithoutProductId() throws Exception {

String institutionId = "institutionId";

mockMvc.perform(MockMvcRequestBuilders.get(BASE_URL + "/{institutionId}/contract", institutionId)
.accept(MediaType.APPLICATION_OCTET_STREAM))
.andExpect(status().isBadRequest());
}

@Test
void getInstitutionUserProductsWith2Elements() throws Exception {
Expand Down

0 comments on commit 09e3d22

Please sign in to comment.