Skip to content

Commit

Permalink
P4ADEV-1774 merged develop and code aligned
Browse files Browse the repository at this point in the history
  • Loading branch information
RiccardoGiuliani committed Jan 14, 2025
1 parent 50e8c43 commit c9d9d17
Show file tree
Hide file tree
Showing 11 changed files with 327 additions and 323 deletions.
583 changes: 294 additions & 289 deletions openapi/generated.openapi.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions openapi/p4pa-debt-position.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ components:
format: int64
iupdOrg:
type: string
iupdPagopa:
type: string
description:
type: string
status:
Expand Down Expand Up @@ -136,7 +134,7 @@ components:
format: int64
status:
type: string
iupd_pagopa:
iupdPagopa:
type: string
iud:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

@Service
public class DebtPositionMapper {
Expand All @@ -34,20 +32,20 @@ public Pair<DebtPosition, Map<InstallmentNoPII, Installment>> mapToModel(DebtPos
debtPosition.setNotificationDate(dto.getNotificationDate());
debtPosition.setValidityDate(dto.getValidityDate());
debtPosition.setFlagIuvVolatile(dto.getFlagIuvVolatile());
debtPosition.setCreationDate(dto.getCreationDate());
debtPosition.setUpdateDate(dto.getUpdateDate());
debtPosition.setCreationDate(dto.getCreationDate().toLocalDateTime());
debtPosition.setUpdateDate(dto.getUpdateDate().toLocalDateTime());

Map<InstallmentNoPII, Installment> installmentMapping = new HashMap<>();

List<PaymentOption> paymentOptions = dto.getPaymentOptions().stream()
SortedSet<PaymentOption> paymentOptions = dto.getPaymentOptions().stream()
.map(paymentOptionDTO -> {
Pair<PaymentOption, Map<InstallmentNoPII, Installment>> paymentOptionWithInstallments = paymentOptionMapper.mapToModel(paymentOptionDTO);

installmentMapping.putAll(paymentOptionWithInstallments.getSecond());

return paymentOptionWithInstallments.getFirst();
})
.toList();
.collect(() -> new TreeSet<>(Comparator.comparing(PaymentOption::getPaymentOptionId)),
SortedSet::add,
SortedSet::addAll);

debtPosition.setPaymentOptions(paymentOptions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public Installment mapToModel(InstallmentDTO dto) {
installment.setTransfers(dto.getTransfers().stream()
.map(transferMapper::mapToModel)
.toList());
installment.setCreationDate(dto.getCreationDate());
installment.setUpdateDate(dto.getUpdateDate());
installment.setCreationDate(dto.getCreationDate().toLocalDateTime());
installment.setUpdateDate(dto.getUpdateDate().toLocalDateTime());
return installment;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

@Service
public class PaymentOptionMapper {
Expand All @@ -31,14 +29,16 @@ public Pair<PaymentOption, Map<InstallmentNoPII, Installment>> mapToModel(Paymen
.map(installmentMapper::mapToModel)
.toList();

List<InstallmentNoPII> installmentNoPIIs = installments.stream()
SortedSet<InstallmentNoPII> installmentNoPIIs = installments.stream()
.map(installment -> {
Pair<InstallmentNoPII, InstallmentPIIDTO> result = installmentPIIMapper.map(installment);
InstallmentNoPII installmentNoPII = result.getFirst();
installmentMapping.put(installmentNoPII, installment);
return installmentNoPII;
})
.toList();
.collect(() -> new TreeSet<>(Comparator.comparing(InstallmentNoPII::getInstallmentId)),
SortedSet::add,
SortedSet::addAll);

PaymentOption paymentOption = new PaymentOption();
paymentOption.setPaymentOptionId(dto.getPaymentOptionId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class PersonMapper {

public Person mapToModel(PersonDTO dto) {
Person person = new Person();
person.setEntityType(dto.getUniqueIdentifierType());
person.setFiscalCode(dto.getUniqueIdentifierCode());
person.setEntityType(dto.getEntityType());
person.setFiscalCode(dto.getFiscalCode());
person.setFullName(dto.getFullName());
person.setAddress(dto.getAddress());
person.setCivic(dto.getCivic());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.util.Pair;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;

import static it.gov.pagopa.pu.debtpositions.util.faker.DebtPositionFaker.buildDebtPosition;
import static it.gov.pagopa.pu.debtpositions.util.faker.DebtPositionFaker.buildDebtPositionDTO;
Expand Down Expand Up @@ -72,11 +73,11 @@ void givenValidDebtPositionDTO_WhenSaveDebtPosition_ThenSaveAllEntities() {

DebtPosition savedDebtPosition = new DebtPosition();
savedDebtPosition.setDebtPositionId(1L);
savedDebtPosition.setPaymentOptions(Collections.singletonList(paymentOption));
savedDebtPosition.setPaymentOptions(new TreeSet<>(List.of(paymentOption)));

PaymentOption savedPaymentOption = new PaymentOption();
savedPaymentOption.setPaymentOptionId(1L);
savedPaymentOption.setInstallments(Collections.singletonList(installmentNoPII));
savedPaymentOption.setInstallments(new TreeSet<>(List.of(installmentNoPII)));

Installment savedInstallment = new Installment();
savedInstallment.setInstallmentId(1L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.TreeSet;

import static it.gov.pagopa.pu.debtpositions.util.faker.PaymentOptionFaker.buildPaymentOption;
import static it.gov.pagopa.pu.debtpositions.util.faker.PaymentOptionFaker.buildPaymentOptionDTO;
Expand All @@ -27,9 +28,9 @@ public static DebtPosition buildDebtPosition() {
debtPosition.setNotificationDate(DATE);
debtPosition.setValidityDate(DATE);
debtPosition.setFlagIuvVolatile(true);
debtPosition.setCreationDate(DATE);
debtPosition.setUpdateDate(DATE);
debtPosition.setPaymentOptions(List.of(buildPaymentOption()));
debtPosition.setCreationDate(DATE.toLocalDateTime());
debtPosition.setUpdateDate(DATE.toLocalDateTime());
debtPosition.setPaymentOptions(new TreeSet<>(List.of(buildPaymentOption())));
return debtPosition;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static Installment buildInstallmentNoUpdate(){
.iur("iur")
.iuf("iuf")
.nav("nav")
.dueDate(date)
.dueDate(date.atOffset(ZoneOffset.UTC))
.paymentTypeCode("paymentTypeCode")
.amountCents(100L)
.notificationFeeCents(100L)
Expand All @@ -116,7 +116,7 @@ public static InstallmentDTO buildInstallmentDTO() {
.iur("iur")
.iuf("iuf")
.nav("nav")
.dueDate(date)
.dueDate(date.atOffset(ZoneOffset.UTC))
.paymentTypeCode("paymentTypeCode")
.amountCents(100L)
.notificationFeeCents(100L)
Expand All @@ -126,8 +126,8 @@ public static InstallmentDTO buildInstallmentDTO() {
.balance("balance")
.debtor(buildPersonDTO())
.transfers(List.of())
.creationDate(date)
.updateDate(date)
.creationDate(date.atOffset(ZoneOffset.UTC))
.updateDate(date.atOffset(ZoneOffset.UTC))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.TreeSet;

public class PaymentOptionFaker {

Expand All @@ -22,7 +23,7 @@ public static PaymentOption buildPaymentOption() {
paymentOption.setMultiDebtor(true);
paymentOption.setDescription("Payment description");
paymentOption.setPaymentOptionType(PaymentOptionType.SINGLE_INSTALLMENT);
paymentOption.setInstallments(List.of());
paymentOption.setInstallments(new TreeSet<>());
return paymentOption;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public static Person buildPerson(){

public static PersonDTO buildPersonDTO(){
return PersonDTO.builder()
.uniqueIdentifierType("F")
.uniqueIdentifierCode("uniqueIdentifierCode")
.entityType("F")
.fiscalCode("uniqueIdentifierCode")
.fullName("fullName")
.address("address")
.civic("civic")
Expand Down

0 comments on commit c9d9d17

Please sign in to comment.