diff --git a/src/main/java/it/gov/pagopa/bizeventsservice/model/response/Debtor.java b/src/main/java/it/gov/pagopa/bizeventsservice/model/response/Debtor.java index c41762f5..a09c5d39 100644 --- a/src/main/java/it/gov/pagopa/bizeventsservice/model/response/Debtor.java +++ b/src/main/java/it/gov/pagopa/bizeventsservice/model/response/Debtor.java @@ -5,6 +5,7 @@ import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import it.gov.pagopa.bizeventsservice.model.response.enumeration.EntityUniqueIdentifierType; import lombok.AllArgsConstructor; @@ -16,6 +17,7 @@ @Data @NoArgsConstructor @AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) public class Debtor implements Serializable{ /** * generated serialVersionUID diff --git a/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java b/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java index 9750f247..7296ae69 100644 --- a/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java +++ b/src/main/java/it/gov/pagopa/bizeventsservice/service/impl/TransactionService.java @@ -1,5 +1,19 @@ package it.gov.pagopa.bizeventsservice.service.impl; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.apache.commons.lang3.SerializationUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + import com.azure.spring.data.cosmos.core.query.CosmosPageRequest; import feign.FeignException; @@ -25,24 +39,6 @@ import it.gov.pagopa.bizeventsservice.util.Constants; import it.gov.pagopa.bizeventsservice.util.Util; -import org.apache.commons.lang3.SerializationUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Sort; -import org.springframework.data.domain.Sort.Direction; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - @Service public class TransactionService implements ITransactionService { @@ -83,16 +79,9 @@ public TransactionListResponse getTransactionList(String taxCode, Boolean isPaye final Sort sort = Sort.by(Sort.Direction.fromString(direction), columnName); final CosmosPageRequest pageRequest = new CosmosPageRequest(0, size, continuationToken, sort); final Page page = this.bizEventsViewUserRepository.getBizEventsViewUserByTaxCode(taxCode, isPayer, isDebtor, pageRequest); - Set set = new HashSet<>(page.getContent().size()); - List listOfViewUser = page.getContent().stream() - .sorted(Comparator.comparing(BizEventsViewUser::getIsDebtor,Comparator.reverseOrder())) - .filter(p -> set.add(p.getTransactionId())) - .collect(Collectors.toList()) - .stream() - .sorted(Comparator.comparing(BizEventsViewUser::getTransactionDate,Comparator.reverseOrder())) - .toList(); - + List listOfViewUser = page.getContent(); + if(listOfViewUser.isEmpty()){ throw new AppException(AppError.VIEW_USER_NOT_FOUND_WITH_TAX_CODE_AND_FILTER, taxCode, isPayer, isDebtor); }