From 9f8092d16361702eb504b85f7287d2c550ed1290 Mon Sep 17 00:00:00 2001 From: andrea-putzu <106688558+andrea-putzu@users.noreply.github.com> Date: Wed, 17 Apr 2024 15:35:21 +0200 Subject: [PATCH] [SELC-4717] Add order param to getDelegation (#474) --- app/src/main/resources/swagger/api-docs.json | 10 ++++ .../mscore/api/DelegationConnector.java | 3 +- .../selfcare/mscore/constant/Order.java | 9 +++ .../dao/DelegationConnectorImpl.java | 57 ++++++++++++++----- .../dao/DelegationConnectorImplTest.java | 9 +-- .../mscore/core/DelegationService.java | 3 +- .../mscore/core/DelegationServiceImpl.java | 5 +- .../core/DelegationServiceImplTest.java | 19 ++++--- infra/container_apps/.terraform.lock.hcl | 2 + .../web/controller/DelegationController.java | 5 +- .../resources/swagger/swagger_en.properties | 1 + .../controller/DelegationControllerTest.java | 17 +++--- 12 files changed, 101 insertions(+), 39 deletions(-) create mode 100644 connector-api/src/main/java/it/pagopa/selfcare/mscore/constant/Order.java diff --git a/app/src/main/resources/swagger/api-docs.json b/app/src/main/resources/swagger/api-docs.json index 7e32e8d24..13b99c3df 100644 --- a/app/src/main/resources/swagger/api-docs.json +++ b/app/src/main/resources/swagger/api-docs.json @@ -105,6 +105,16 @@ "type" : "string", "enum" : [ "FULL", "NORMAL" ] } + }, { + "name" : "order", + "in" : "query", + "description" : "Order to show response NONE, ASC, DESC", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string", + "enum" : [ "ASC", "DESC", "NONE" ] + } }, { "name" : "page", "in" : "query", diff --git a/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/DelegationConnector.java b/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/DelegationConnector.java index 62b4378a2..8842ffa67 100644 --- a/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/DelegationConnector.java +++ b/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/DelegationConnector.java @@ -2,6 +2,7 @@ import it.pagopa.selfcare.mscore.constant.DelegationState; import it.pagopa.selfcare.mscore.constant.GetDelegationsMode; +import it.pagopa.selfcare.mscore.constant.Order; import it.pagopa.selfcare.mscore.model.delegation.Delegation; import java.util.List; @@ -10,7 +11,7 @@ public interface DelegationConnector { Delegation save(Delegation delegation); boolean checkIfExists(Delegation delegation); - List find(String from, String to, String productId, String search, String taxCode, GetDelegationsMode mode, Integer page, Integer size); + List find(String from, String to, String productId, String search, String taxCode, GetDelegationsMode mode, Order order, Integer page, Integer size); Delegation findByIdAndModifyStatus(String delegationId, DelegationState status); boolean checkIfDelegationsAreActive(String institutionId); } diff --git a/connector-api/src/main/java/it/pagopa/selfcare/mscore/constant/Order.java b/connector-api/src/main/java/it/pagopa/selfcare/mscore/constant/Order.java new file mode 100644 index 000000000..c02e8db95 --- /dev/null +++ b/connector-api/src/main/java/it/pagopa/selfcare/mscore/constant/Order.java @@ -0,0 +1,9 @@ +package it.pagopa.selfcare.mscore.constant; + +public enum Order { + + NONE, + ASC, + DESC; + +} diff --git a/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/DelegationConnectorImpl.java b/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/DelegationConnectorImpl.java index ca6b3d238..29da7b8b6 100644 --- a/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/DelegationConnectorImpl.java +++ b/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/DelegationConnectorImpl.java @@ -7,11 +7,13 @@ import it.pagopa.selfcare.mscore.connector.dao.model.mapper.DelegationInstitutionMapper; import it.pagopa.selfcare.mscore.constant.DelegationState; import it.pagopa.selfcare.mscore.constant.GetDelegationsMode; +import it.pagopa.selfcare.mscore.constant.Order; import it.pagopa.selfcare.mscore.model.delegation.Delegation; import it.pagopa.selfcare.mscore.model.delegation.DelegationInstitution; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.aggregation.*; @@ -29,6 +31,8 @@ @Component public class DelegationConnectorImpl implements DelegationConnector { + public static final String INSTITUTIONS = "institutions"; + public static final String DELEGATIONS = "Delegations"; private final DelegationRepository repository; private final DelegationEntityMapper delegationMapper; private final DelegationInstitutionMapper delegationInstitutionMapper; @@ -63,11 +67,13 @@ public boolean checkIfExists(Delegation delegation) { } @Override - public List find(String from, String to, String productId, String search, String taxCode, GetDelegationsMode mode, Integer page, Integer size) { + public List find(String from, String to, String productId, String search, String taxCode, GetDelegationsMode mode, Order order, Integer page, Integer size) { List criterias = new ArrayList<>(); Criteria criteria = new Criteria(); Pageable pageable = PageRequest.of(page, size); + criterias.add(Criteria.where(DelegationEntity.Fields.status.name()).is(DelegationState.ACTIVE.name())); + if (Objects.nonNull(from)) { criterias.add(Criteria.where(DelegationEntity.Fields.from.name()).is(from)); } @@ -80,27 +86,35 @@ public List find(String from, String to, String productId, String se if (Objects.nonNull(search)) { criterias.add(Criteria.where(DelegationEntity.Fields.institutionFromName.name()).regex("(?i)" + Pattern.quote(search))); } + + Sort.Direction sortDirection = order.equals(Order.ASC) ? Sort.Direction.ASC : Sort.Direction.DESC; + if (GetDelegationsMode.FULL.equals(mode)) { - GraphLookupOperation.GraphLookupOperationBuilder lookup = Aggregation.graphLookup("Institution") - .startWith(Objects.nonNull(from) ? "to" : "from") - .connectFrom(Objects.nonNull(from) ? "to" : "from") - .connectTo("_id"); + GraphLookupOperation.GraphLookupOperationBuilder lookup = createInstitutionGraphLookupOperationBuilder(from); MatchOperation matchOperation = new MatchOperation(new Criteria().andOperator(criterias.toArray(new Criteria[criterias.size()]))); + long skipLimit = (long) page * size; SkipOperation skip = Aggregation.skip(skipLimit); - LimitOperation limit = Aggregation.limit(skipLimit + size); + LimitOperation limit = Aggregation.limit(size); Aggregation aggregation; + if (Objects.nonNull(taxCode)) { - Criteria taxCodeCriteria = Criteria.where("institutions." + InstitutionEntity.Fields.taxCode.name()).is(taxCode); - MatchOperation matchTaxCodeOperation = new MatchOperation(new Criteria().andOperator(taxCodeCriteria)); - aggregation = Aggregation.newAggregation(matchOperation, lookup.as("institutions"), matchTaxCodeOperation, skip, limit); - } else { - aggregation = Aggregation.newAggregation(matchOperation, lookup.as("institutions"), skip, limit); + MatchOperation matchTaxCodeOperation = getMatchTaxCodeOperation(taxCode); + aggregation = Aggregation.newAggregation(matchOperation, lookup.as(INSTITUTIONS), matchTaxCodeOperation, skip, limit); + } + else { + if (!order.equals(Order.NONE)) { + SortOperation sortOperation = new SortOperation(Sort.by(sortDirection, DelegationEntity.Fields.institutionFromName.name())); + aggregation = Aggregation.newAggregation(matchOperation, sortOperation, lookup.as(INSTITUTIONS), skip, limit); + } + else { + aggregation = Aggregation.newAggregation(matchOperation, lookup.as(INSTITUTIONS), skip, limit); + } } - List result = mongoTemplate.aggregate(aggregation, "Delegations", DelegationInstitution.class).getMappedResults(); + List result = mongoTemplate.aggregate(aggregation, DELEGATIONS, DelegationInstitution.class).getMappedResults(); return result.stream() .map(Objects.nonNull(from) ? delegationInstitutionMapper::convertToDelegationBroker : @@ -108,12 +122,29 @@ public List find(String from, String to, String productId, String se .collect(Collectors.toList()); } - return repository.find(Query.query(criteria.andOperator(criterias)), pageable, DelegationEntity.class) + Query query = Query.query(criteria.andOperator(criterias)); + if (!order.equals(Order.NONE)) { + query = query.with(Sort.by(sortDirection, DelegationEntity.Fields.institutionFromName.name())); + } + + return repository.find(query, pageable, DelegationEntity.class) .stream() .map(delegationMapper::convertToDelegation) .collect(Collectors.toList()); } + private static GraphLookupOperation.GraphLookupOperationBuilder createInstitutionGraphLookupOperationBuilder(String from) { + return Aggregation.graphLookup(INSTITUTIONS) + .startWith(Objects.nonNull(from) ? "to" : "from") + .connectFrom(Objects.nonNull(from) ? "to" : "from") + .connectTo("_id"); + } + + private static MatchOperation getMatchTaxCodeOperation(String taxCode) { + Criteria taxCodeCriteria = Criteria.where("institutions." + InstitutionEntity.Fields.taxCode.name()).is(taxCode); + return new MatchOperation(new Criteria().andOperator(taxCodeCriteria)); + } + @Override public Delegation findByIdAndModifyStatus(String delegationId, DelegationState status) { Query query = Query.query(Criteria.where(DelegationEntity.Fields.id.name()).is(delegationId)); diff --git a/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/DelegationConnectorImplTest.java b/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/DelegationConnectorImplTest.java index f301fe3ca..37bc9054c 100644 --- a/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/DelegationConnectorImplTest.java +++ b/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/DelegationConnectorImplTest.java @@ -9,6 +9,7 @@ import it.pagopa.selfcare.mscore.constant.DelegationState; import it.pagopa.selfcare.mscore.constant.DelegationType; import it.pagopa.selfcare.mscore.constant.GetDelegationsMode; +import it.pagopa.selfcare.mscore.constant.Order; import it.pagopa.selfcare.mscore.exception.MsCoreException; import it.pagopa.selfcare.mscore.model.delegation.Delegation; import it.pagopa.selfcare.mscore.model.delegation.DelegationInstitution; @@ -130,7 +131,7 @@ void find_shouldGetData() { .find(any(), any(), any()); List response = delegationConnectorImpl.find(delegationEntity.getFrom(), - delegationEntity.getTo(), delegationEntity.getProductId(), null, null, GetDelegationsMode.NORMAL, PAGE_SIZE, MAX_PAGE_SIZE); + delegationEntity.getTo(), delegationEntity.getProductId(), null, null, GetDelegationsMode.NORMAL, Order.NONE, PAGE_SIZE, MAX_PAGE_SIZE); //Then assertNotNull(response); @@ -158,7 +159,7 @@ void getBrokersFullMode() { thenReturn(results); List response = delegationConnectorImpl.find(dummyDelegationEntity.getFrom(), null, - dummyDelegationEntity.getProductId(), null, null, GetDelegationsMode.FULL, PAGE_SIZE, MAX_PAGE_SIZE); + dummyDelegationEntity.getProductId(), null, null, GetDelegationsMode.FULL, Order.NONE, PAGE_SIZE, MAX_PAGE_SIZE); //Then assertNotNull(response); @@ -188,7 +189,7 @@ void getInstitutionsFullMode() { thenReturn(results); List response = delegationConnectorImpl.find(null, dummyDelegationEntity.getTo(), - dummyDelegationEntity.getProductId(), null, null, GetDelegationsMode.FULL, PAGE_SIZE, MAX_PAGE_SIZE); + dummyDelegationEntity.getProductId(), null, null, GetDelegationsMode.FULL, Order.ASC, PAGE_SIZE, MAX_PAGE_SIZE); //Then assertNotNull(response); @@ -247,7 +248,7 @@ void find_shouldGetDataPaginated() { thenReturn(results); List response = delegationConnectorImpl.find(null, - TO1, "productId", null, null, GetDelegationsMode.FULL, 0, 1); + TO1, "productId", null, null, GetDelegationsMode.FULL, Order.NONE, 0, 1); //Then assertNotNull(response); diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/DelegationService.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/DelegationService.java index 835032b5c..9a13b4930 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/DelegationService.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/DelegationService.java @@ -1,6 +1,7 @@ package it.pagopa.selfcare.mscore.core; import it.pagopa.selfcare.mscore.constant.GetDelegationsMode; +import it.pagopa.selfcare.mscore.constant.Order; import it.pagopa.selfcare.mscore.model.delegation.Delegation; import java.util.List; @@ -10,7 +11,7 @@ public interface DelegationService { Delegation createDelegation(Delegation delegation); boolean checkIfExists(Delegation delegation); - List getDelegations(String from, String to, String productId, String search, String taxCode, GetDelegationsMode mode, Optional page, Optional size); + List getDelegations(String from, String to, String productId, String search, String taxCode, GetDelegationsMode mode, Optional order, Optional page, Optional size); Delegation createDelegationFromInstitutionsTaxCode(Delegation delegation); void deleteDelegationByDelegationId(String delegationId); } diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/DelegationServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/DelegationServiceImpl.java index 0909dae00..8f974421a 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/DelegationServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/DelegationServiceImpl.java @@ -5,6 +5,7 @@ import it.pagopa.selfcare.mscore.constant.CustomError; import it.pagopa.selfcare.mscore.constant.DelegationState; import it.pagopa.selfcare.mscore.constant.GetDelegationsMode; +import it.pagopa.selfcare.mscore.constant.Order; import it.pagopa.selfcare.mscore.exception.MsCoreException; import it.pagopa.selfcare.mscore.exception.ResourceConflictException; import it.pagopa.selfcare.mscore.exception.ResourceNotFoundException; @@ -163,8 +164,8 @@ public boolean checkIfExists(Delegation delegation) { @Override public List getDelegations(String from, String to, String productId, String search, String taxCode, GetDelegationsMode mode, - Optional page, Optional size) { + Optional order, Optional page, Optional size) { int pageSize = size.filter(s -> s > 0).filter(s -> s <= DEFAULT_DELEGATIONS_PAGE_SIZE).orElse(DEFAULT_DELEGATIONS_PAGE_SIZE); - return delegationConnector.find(from, to, productId, search, taxCode, mode, page.orElse(0), pageSize); + return delegationConnector.find(from, to, productId, search, taxCode, mode, order.orElse(Order.NONE), page.orElse(0), pageSize); } } diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/DelegationServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/DelegationServiceImplTest.java index 9734eaf49..8a745ea8b 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/DelegationServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/DelegationServiceImplTest.java @@ -4,6 +4,7 @@ import it.pagopa.selfcare.mscore.api.DelegationConnector; import it.pagopa.selfcare.mscore.constant.DelegationState; import it.pagopa.selfcare.mscore.constant.GetDelegationsMode; +import it.pagopa.selfcare.mscore.constant.Order; import it.pagopa.selfcare.mscore.exception.MsCoreException; import it.pagopa.selfcare.mscore.exception.ResourceConflictException; import it.pagopa.selfcare.mscore.exception.ResourceNotFoundException; @@ -176,12 +177,12 @@ void find_shouldGetData() { //Given Delegation delegation = new Delegation(); delegation.setId("id"); - when(delegationConnector.find(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(List.of(delegation)); + when(delegationConnector.find(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(List.of(delegation)); //When List response = delegationServiceImpl.getDelegations("from", "to", "productId", null, null, - GetDelegationsMode.NORMAL, Optional.of(0), Optional.of(100)); + GetDelegationsMode.NORMAL, Optional.empty(), Optional.of(0), Optional.of(100)); //Then - verify(delegationConnector).find(any(), any(), any(), any(), any(), any(), any(), any()); + verify(delegationConnector).find(any(), any(), any(), any(), any(), any(), any(), any(), any()); assertNotNull(response); assertFalse(response.isEmpty()); @@ -196,12 +197,12 @@ void find_shouldGetData_fullMode() { //Given Delegation delegation = new Delegation(); delegation.setId("id"); - when(delegationConnector.find(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(List.of(delegation)); + when(delegationConnector.find(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(List.of(delegation)); //When List response = delegationServiceImpl.getDelegations("from", null, "productId", null, null, - GetDelegationsMode.FULL, Optional.of(0), Optional.of(0)); + GetDelegationsMode.FULL, Optional.of(Order.DESC), Optional.of(0), Optional.of(0)); //Then - verify(delegationConnector).find(any(), any(), any(), any(), any(), any(), any(), any()); + verify(delegationConnector).find(any(), any(), any(), any(), any(), any(), any(), any(), any()); assertNotNull(response); assertFalse(response.isEmpty()); @@ -216,12 +217,12 @@ void find_shouldGetData_fullMode_defaultPage() { //Given Delegation delegation = new Delegation(); delegation.setId("id"); - when(delegationConnector.find(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(List.of(delegation)); + when(delegationConnector.find(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(List.of(delegation)); //When List response = delegationServiceImpl.getDelegations("from", null, "productId", null, null, - GetDelegationsMode.FULL, Optional.empty(), Optional.empty()); + GetDelegationsMode.FULL, Optional.of(Order.DESC), Optional.empty(), Optional.empty()); //Then - verify(delegationConnector).find(any(), any(), any(), any(), any(), any(), any(), any()); + verify(delegationConnector).find(any(), any(), any(), any(), any(), any(), any(), any(), any()); assertNotNull(response); assertFalse(response.isEmpty()); diff --git a/infra/container_apps/.terraform.lock.hcl b/infra/container_apps/.terraform.lock.hcl index 8baa26205..dd904d6e1 100644 --- a/infra/container_apps/.terraform.lock.hcl +++ b/infra/container_apps/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/azure/azapi" { version = "1.9.0" constraints = "~> 1.9.0" hashes = [ + "h1:Ow1rr5fYBGSkplH/kcXeWz9y2wA81BnhZ7vTBzJfAAg=", "h1:shpEoqcAbf+p6AvspiYO1YrX//8l1LV/owEcQpujWHw=", "zh:349569471fbf387feaaf8b88da1690669e201147c342f905e5eb03df42b3cf87", "zh:54346d5fb78cbad3eb7cfd96e1dd7ce4f78666cabaaccfec6ee9437476330018", @@ -26,6 +27,7 @@ provider "registry.terraform.io/hashicorp/azurerm" { constraints = "<= 3.91.0" hashes = [ "h1:8hMFuaTQsZIV69D0J/W+6hSlhRRDzYSpC0Eg9yWYF0o=", + "h1:Iv9CR+7491iozaK2AkCSAK2u4a2rPyJDQpyHijClj6Y=", "zh:13928b71b1235783f3f877a799e28fb91e50512b051eb8ccb370500fc140cf3f", "zh:3264341657e9ff3963d69b0fa088f64665349e2a29b2f3aeb4deee6d9d7584b7", "zh:467a2ddd2eee26353db65e949bfbe533481ca0fb53c152724380b63a308f11b9", diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/DelegationController.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/DelegationController.java index b22317ec2..4c3316ec0 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/DelegationController.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/DelegationController.java @@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.tags.Tags; import it.pagopa.selfcare.mscore.constant.GenericError; import it.pagopa.selfcare.mscore.constant.GetDelegationsMode; +import it.pagopa.selfcare.mscore.constant.Order; import it.pagopa.selfcare.mscore.core.DelegationService; import it.pagopa.selfcare.mscore.exception.InvalidRequestException; import it.pagopa.selfcare.mscore.model.delegation.Delegation; @@ -105,13 +106,15 @@ public ResponseEntity> getDelegations(@ApiParam("${swag @RequestParam(name = "taxCode", required = false) String taxCode, @ApiParam("${swagger.mscore.institutions.delegations.mode}") @RequestParam(name = "mode", required = false) GetDelegationsMode mode, + @ApiParam("${swagger.mscore.institutions.delegations.order}") + @RequestParam(name = "order", required = false) Optional order, @RequestParam(name = "page", required = false) Optional page, @RequestParam(name = "size", required = false) Optional size) { if(Objects.isNull(institutionId) && Objects.isNull(brokerId)) throw new InvalidRequestException("institutionId or brokerId must not be null!!", GenericError.GENERIC_ERROR.getCode()); - return ResponseEntity.status(HttpStatus.OK).body(delegationService.getDelegations(institutionId, brokerId, productId, search, taxCode, mode, page, size).stream() + return ResponseEntity.status(HttpStatus.OK).body(delegationService.getDelegations(institutionId, brokerId, productId, search, taxCode, mode, order, page, size).stream() .map(delegationMapper::toDelegationResponse) .collect(Collectors.toList())); } diff --git a/web/src/main/resources/swagger/swagger_en.properties b/web/src/main/resources/swagger/swagger_en.properties index ee6683183..45acb0f26 100644 --- a/web/src/main/resources/swagger/swagger_en.properties +++ b/web/src/main/resources/swagger/swagger_en.properties @@ -94,6 +94,7 @@ swagger.mscore.api.users.updateUserStatus=Update user status with optional filte swagger.mscore.api.users.getOnboardedUsers=Retrieve onboarded users according to identifiers in input swagger.mscore.institutions.delegations=Retrieve institution's delegations swagger.mscore.institutions.delegations.mode=Mode (full or normal) to retreieve institution's delegations +swagger.mscore.institutions.delegations.order=Order to show response NONE, ASC, DESC swagger.mscore.institutions.brokers=Retrieve institution brokers swagger.mscore.institutions.getInstitutionBrokers=Retrieve institution brokers swagger.mscore.users.userId=User's unique identifier diff --git a/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/DelegationControllerTest.java b/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/DelegationControllerTest.java index 4c857730d..4fac97ae0 100644 --- a/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/DelegationControllerTest.java +++ b/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/DelegationControllerTest.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import it.pagopa.selfcare.mscore.constant.DelegationType; import it.pagopa.selfcare.mscore.constant.GetDelegationsMode; +import it.pagopa.selfcare.mscore.constant.Order; import it.pagopa.selfcare.mscore.core.DelegationService; import it.pagopa.selfcare.mscore.model.delegation.Delegation; import it.pagopa.selfcare.mscore.web.model.delegation.DelegationRequest; @@ -130,7 +131,7 @@ void getDelegations_shouldInvalidRequest() { } /** - * Method under test: {@link DelegationController#getDelegations(String, String, String, String, String, GetDelegationsMode, Optional, Optional)} + * Method under test: {@link DelegationController#getDelegations(String, String, String, String, String, GetDelegationsMode, Optional, Optional, Optional)} */ @Test void getDelegations_shouldGetData() throws Exception { @@ -138,7 +139,7 @@ void getDelegations_shouldGetData() throws Exception { Delegation expectedDelegation = dummyDelegation(); when(delegationService.getDelegations(expectedDelegation.getFrom(), expectedDelegation.getTo(), - expectedDelegation.getProductId(), null, null, GetDelegationsMode.NORMAL, Optional.empty(), Optional.empty())) + expectedDelegation.getProductId(), null, null, GetDelegationsMode.NORMAL, Optional.empty(), Optional.empty(), Optional.empty())) .thenReturn(List.of(expectedDelegation)); // When MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders @@ -166,7 +167,7 @@ void getDelegations_shouldGetData() throws Exception { verify(delegationService, times(1)) .getDelegations(expectedDelegation.getFrom(), expectedDelegation.getTo(), - expectedDelegation.getProductId(), null, null, GetDelegationsMode.NORMAL, + expectedDelegation.getProductId(), null, null, GetDelegationsMode.NORMAL, Optional.empty(), Optional.empty(), Optional.empty()); verifyNoMoreInteractions(delegationService); @@ -182,7 +183,7 @@ void getDelegations_shouldGetDataCustom() throws Exception { expectedDelegations.add(delegation2); when(delegationService.getDelegations(null, TO1, - null, null, null, GetDelegationsMode.FULL, Optional.empty(), Optional.empty())) + null, null, null, GetDelegationsMode.FULL, Optional.empty(), Optional.empty(), Optional.empty())) .thenReturn(expectedDelegations); // When MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders @@ -209,13 +210,13 @@ void getDelegations_shouldGetDataCustom() throws Exception { verify(delegationService, times(1)) .getDelegations(null, TO1, null, - null, null, GetDelegationsMode.FULL, + null, null, GetDelegationsMode.FULL, Optional.empty(), Optional.empty(), Optional.empty()); verifyNoMoreInteractions(delegationService); } /** - * Method under test: {@link DelegationController#getDelegations(String, String, String, String, String, GetDelegationsMode, Optional, Optional)} + * Method under test: {@link DelegationController#getDelegations(String, String, String, String, String, GetDelegationsMode, Optional, Optional, Optional)} */ @Test void getDelegations_shouldGetData_nullMode() throws Exception { @@ -223,7 +224,7 @@ void getDelegations_shouldGetData_nullMode() throws Exception { Delegation expectedDelegation = dummyDelegation(); when(delegationService.getDelegations(expectedDelegation.getFrom(), expectedDelegation.getTo(), - expectedDelegation.getProductId(), null, null, null, Optional.empty(), Optional.empty())) + expectedDelegation.getProductId(), null, null, null, Optional.empty(), Optional.empty(), Optional.empty())) .thenReturn(List.of(expectedDelegation)); // When MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders @@ -251,7 +252,7 @@ void getDelegations_shouldGetData_nullMode() throws Exception { verify(delegationService, times(1)) .getDelegations(expectedDelegation.getFrom(), expectedDelegation.getTo(), - expectedDelegation.getProductId(), null, null, null, Optional.empty(), Optional.empty()); + expectedDelegation.getProductId(), null, null, null, Optional.empty(), Optional.empty(), Optional.empty()); verifyNoMoreInteractions(delegationService); }