diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index 393c7d9..1510550 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -3715,7 +3715,7 @@ } } }, - "Transfer" : { + "DebtPositionType" : { "type" : "object", "properties" : { "creationDate" : { @@ -3729,42 +3729,46 @@ "updateOperatorExternalId" : { "type" : "string" }, - "transferId" : { + "debtPositionTypeId" : { "type" : "integer", "format" : "int64" }, - "installmentId" : { + "brokerId" : { "type" : "integer", "format" : "int64" }, - "orgFiscalCode" : { + "code" : { "type" : "string" }, - "orgName" : { + "description" : { "type" : "string" }, - "amountCents" : { - "type" : "integer", - "format" : "int64" - }, - "remittanceInformation" : { + "orgType" : { "type" : "string" }, - "stamp" : { - "$ref" : "#/components/schemas/Stamp" + "macroArea" : { + "type" : "string" }, - "iban" : { + "serviceType" : { "type" : "string" }, - "postalIban" : { + "collectingReason" : { "type" : "string" }, - "category" : { + "taxonomyCode" : { "type" : "string" }, - "transferIndex" : { - "type" : "integer", - "format" : "int64" + "flagAnonymousFiscalCode" : { + "type" : "boolean" + }, + "flagMandatoryDueDate" : { + "type" : "boolean" + }, + "flagNotifyIo" : { + "type" : "boolean" + }, + "ioTemplateMessage" : { + "type" : "string" }, "_links" : { "$ref" : "#/components/schemas/Links" @@ -3792,16 +3796,16 @@ } } }, - "PagedModelTransfer" : { + "PagedModelDebtPositionType" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "transfers" : { + "debtPositionTypes" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/Transfer" + "$ref" : "#/components/schemas/DebtPositionType" } } } @@ -3814,21 +3818,7 @@ } } }, - "Stamp" : { - "type" : "object", - "properties" : { - "stampType" : { - "type" : "string" - }, - "stampHashDocument" : { - "type" : "string" - }, - "stampProvincialResidence" : { - "type" : "string" - } - } - }, - "InstallmentNoPII" : { + "ReceiptNoPII" : { "type" : "object", "properties" : { "creationDate" : { @@ -3842,95 +3832,118 @@ "updateOperatorExternalId" : { "type" : "string" }, - "installmentId" : { + "receiptId" : { "type" : "integer", "format" : "int64" }, - "paymentOptionId" : { + "installmentId" : { "type" : "integer", "format" : "int64" }, - "status" : { - "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + "ingestionFlowFileId" : { + "type" : "integer", + "format" : "int64" }, - "iupdPagopa" : { + "receiptOrigin" : { "type" : "string" }, - "iud" : { + "paymentReceiptId" : { "type" : "string" }, - "iuv" : { + "noticeNumber" : { "type" : "string" }, - "iur" : { + "paymentNote" : { "type" : "string" }, - "iuf" : { + "orgFiscalCode" : { "type" : "string" }, - "nav" : { + "outcome" : { "type" : "string" }, - "dueDate" : { - "type" : "string", - "format" : "date-time" - }, - "paymentTypeCode" : { + "creditorReferenceId" : { "type" : "string" }, - "amountCents" : { + "paymentAmountCents" : { "type" : "integer", "format" : "int64" }, - "notificationFeeCents" : { - "type" : "integer", - "format" : "int64" + "description" : { + "type" : "string" }, - "remittanceInformation" : { + "companyName" : { "type" : "string" }, - "humanFriendlyRemittanceInformation" : { + "officeName" : { "type" : "string" }, - "balance" : { + "idPsp" : { "type" : "string" }, - "legacyPaymentMetadata" : { + "pspFiscalCode" : { "type" : "string" }, - "personalDataId" : { + "pspPartitaIva" : { + "type" : "string" + }, + "pspCompanyName" : { + "type" : "string" + }, + "idChannel" : { + "type" : "string" + }, + "channelDescription" : { + "type" : "string" + }, + "paymentMethod" : { + "type" : "string" + }, + "feeCents" : { "type" : "integer", "format" : "int64" }, + "paymentDateTime" : { + "type" : "string", + "format" : "date-time" + }, + "applicationDate" : { + "type" : "string", + "format" : "date-time" + }, + "transferDate" : { + "type" : "string", + "format" : "date-time" + }, + "standin" : { + "type" : "boolean" + }, "debtorEntityType" : { "type" : "string" }, + "personalDataId" : { + "type" : "integer", + "format" : "int64" + }, "debtorFiscalCodeHash" : { "type" : "string", "format" : "byte" }, - "syncStatusFrom" : { - "type" : "string" - }, - "syncStatusTo" : { - "type" : "string" - }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelInstallmentNoPII" : { + "PagedModelReceiptNoPII" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "installmentNoPIIs" : { + "receiptNoPIIs" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/InstallmentNoPII" + "$ref" : "#/components/schemas/ReceiptNoPII" } } } @@ -3943,41 +3956,55 @@ } } }, - "CollectionModelTransfer" : { + "DebtPositionTypeWithCount" : { "type" : "object", "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "transfers" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/TransferResponse" - } - } - } + "debtPositionTypeId" : { + "type" : "integer", + "format" : "int64" + }, + "code" : { + "type" : "string" + }, + "description" : { + "type" : "string" + }, + "updateDate" : { + "type" : "string", + "format" : "date-time" + }, + "activeOrganizations" : { + "type" : "integer", + "format" : "int32" + }, + "brokerId" : { + "type" : "integer", + "format" : "int64" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "CollectionModelObject" : { + "PagedModelDebtPositionTypeWithCount" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "objects" : { + "debtPositionTypeWithCounts" : { "type" : "array", "items" : { - "type" : "object" + "$ref" : "#/components/schemas/DebtPositionTypeWithCount" } } } }, "_links" : { "$ref" : "#/components/schemas/Links" + }, + "page" : { + "$ref" : "#/components/schemas/PageMetadata" } } }, @@ -4033,7 +4060,7 @@ } } }, - "PaymentOption" : { + "Transfer" : { "type" : "object", "properties" : { "creationDate" : { @@ -4047,51 +4074,198 @@ "updateOperatorExternalId" : { "type" : "string" }, - "paymentOptionId" : { + "transferId" : { "type" : "integer", "format" : "int64" }, - "debtPositionId" : { + "installmentId" : { "type" : "integer", "format" : "int64" }, - "totalAmountCents" : { + "orgFiscalCode" : { + "type" : "string" + }, + "orgName" : { + "type" : "string" + }, + "amountCents" : { + "type" : "integer", + "format" : "int64" + }, + "remittanceInformation" : { + "type" : "string" + }, + "stamp" : { + "$ref" : "#/components/schemas/Stamp" + }, + "iban" : { + "type" : "string" + }, + "postalIban" : { + "type" : "string" + }, + "category" : { + "type" : "string" + }, + "transferIndex" : { + "type" : "integer", + "format" : "int64" + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "PagedModelTransfer" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "transfers" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Transfer" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + }, + "page" : { + "$ref" : "#/components/schemas/PageMetadata" + } + } + }, + "Stamp" : { + "type" : "object", + "properties" : { + "stampType" : { + "type" : "string" + }, + "stampHashDocument" : { + "type" : "string" + }, + "stampProvincialResidence" : { + "type" : "string" + } + } + }, + "InstallmentNoPII" : { + "type" : "object", + "properties" : { + "creationDate" : { + "type" : "string", + "format" : "date-time" + }, + "updateDate" : { + "type" : "string", + "format" : "date-time" + }, + "updateOperatorExternalId" : { + "type" : "string" + }, + "installmentId" : { + "type" : "integer", + "format" : "int64" + }, + "paymentOptionId" : { "type" : "integer", "format" : "int64" }, "status" : { "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] }, - "multiDebtor" : { - "type" : "boolean" + "iupdPagopa" : { + "type" : "string" + }, + "iud" : { + "type" : "string" + }, + "iuv" : { + "type" : "string" + }, + "iur" : { + "type" : "string" + }, + "iuf" : { + "type" : "string" + }, + "nav" : { + "type" : "string" }, "dueDate" : { "type" : "string", "format" : "date-time" }, - "description" : { + "paymentTypeCode" : { "type" : "string" }, - "paymentOptionType" : { + "amountCents" : { + "type" : "integer", + "format" : "int64" + }, + "notificationFeeCents" : { + "type" : "integer", + "format" : "int64" + }, + "remittanceInformation" : { + "type" : "string" + }, + "humanFriendlyRemittanceInformation" : { + "type" : "string" + }, + "balance" : { + "type" : "string" + }, + "legacyPaymentMetadata" : { + "type" : "string" + }, + "personalDataId" : { + "type" : "integer", + "format" : "int64" + }, + "debtorEntityType" : { + "type" : "string" + }, + "debtorFiscalCodeHash" : { "type" : "string", - "enum" : [ "SINGLE_INSTALLMENT", "INSTALLMENTS", "DOWN_PAYMENT" ] + "format" : "byte" + }, + "syncStatus" : { + "$ref" : "#/components/schemas/InstallmentSyncStatus" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelPaymentOption" : { + "InstallmentSyncStatus" : { + "required" : [ "syncStatusFrom", "syncStatusTo" ], + "type" : "object", + "properties" : { + "syncStatusFrom" : { + "type" : "string", + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + }, + "syncStatusTo" : { + "type" : "string", + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + } + } + }, + "PagedModelInstallmentNoPII" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "paymentOptions" : { + "installmentNoPIIs" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/PaymentOption" + "$ref" : "#/components/schemas/InstallmentNoPII" } } } @@ -4104,16 +4278,16 @@ } } }, - "CollectionModelInstallmentNoPII" : { + "CollectionModelObject" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "installmentNoPIIs" : { + "objects" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/InstallmentNoPIIResponse" + "type" : "object" } } } @@ -4123,7 +4297,26 @@ } } }, - "DebtPositionType" : { + "CollectionModelTransfer" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "transfers" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/TransferResponse" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "PaymentOption" : { "type" : "object", "properties" : { "creationDate" : { @@ -4137,62 +4330,51 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionTypeId" : { + "paymentOptionId" : { "type" : "integer", "format" : "int64" }, - "brokerId" : { + "debtPositionId" : { "type" : "integer", "format" : "int64" }, - "code" : { - "type" : "string" - }, - "description" : { - "type" : "string" - }, - "orgType" : { - "type" : "string" - }, - "macroArea" : { - "type" : "string" - }, - "serviceType" : { - "type" : "string" - }, - "collectingReason" : { - "type" : "string" - }, - "taxonomyCode" : { - "type" : "string" + "totalAmountCents" : { + "type" : "integer", + "format" : "int64" }, - "flagAnonymousFiscalCode" : { - "type" : "boolean" + "status" : { + "type" : "string", + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] }, - "flagMandatoryDueDate" : { + "multiDebtor" : { "type" : "boolean" }, - "flagNotifyIo" : { - "type" : "boolean" + "dueDate" : { + "type" : "string", + "format" : "date-time" }, - "ioTemplateMessage" : { + "description" : { "type" : "string" }, + "paymentOptionType" : { + "type" : "string", + "enum" : [ "SINGLE_INSTALLMENT", "INSTALLMENTS", "DOWN_PAYMENT" ] + }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPositionType" : { + "PagedModelPaymentOption" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypes" : { + "paymentOptions" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionType" + "$ref" : "#/components/schemas/PaymentOption" } } } @@ -4205,6 +4387,25 @@ } } }, + "CollectionModelInstallmentNoPII" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "installmentNoPIIs" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InstallmentNoPIIResponse" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, "DebtPosition" : { "type" : "object", "properties" : { @@ -4310,58 +4511,6 @@ } } }, - "DebtPositionTypeWithCount" : { - "type" : "object", - "properties" : { - "debtPositionTypeId" : { - "type" : "integer", - "format" : "int64" - }, - "code" : { - "type" : "string" - }, - "description" : { - "type" : "string" - }, - "updateDate" : { - "type" : "string", - "format" : "date-time" - }, - "activeOrganizations" : { - "type" : "integer", - "format" : "int32" - }, - "brokerId" : { - "type" : "integer", - "format" : "int64" - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "PagedModelDebtPositionTypeWithCount" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "debtPositionTypeWithCounts" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/DebtPositionTypeWithCount" - } - } - } - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - }, - "page" : { - "$ref" : "#/components/schemas/PageMetadata" - } - } - }, "DebtPositionTypeOrg" : { "type" : "object", "properties" : { @@ -4484,144 +4633,6 @@ } } }, - "ReceiptNoPII" : { - "type" : "object", - "properties" : { - "creationDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateOperatorExternalId" : { - "type" : "string" - }, - "receiptId" : { - "type" : "integer", - "format" : "int64" - }, - "installmentId" : { - "type" : "integer", - "format" : "int64" - }, - "ingestionFlowFileId" : { - "type" : "integer", - "format" : "int64" - }, - "receiptOrigin" : { - "type" : "string" - }, - "paymentReceiptId" : { - "type" : "string" - }, - "noticeNumber" : { - "type" : "string" - }, - "paymentNote" : { - "type" : "string" - }, - "orgFiscalCode" : { - "type" : "string" - }, - "outcome" : { - "type" : "string" - }, - "creditorReferenceId" : { - "type" : "string" - }, - "paymentAmountCents" : { - "type" : "integer", - "format" : "int64" - }, - "description" : { - "type" : "string" - }, - "companyName" : { - "type" : "string" - }, - "officeName" : { - "type" : "string" - }, - "idPsp" : { - "type" : "string" - }, - "pspFiscalCode" : { - "type" : "string" - }, - "pspPartitaIva" : { - "type" : "string" - }, - "pspCompanyName" : { - "type" : "string" - }, - "idChannel" : { - "type" : "string" - }, - "channelDescription" : { - "type" : "string" - }, - "paymentMethod" : { - "type" : "string" - }, - "feeCents" : { - "type" : "integer", - "format" : "int64" - }, - "paymentDateTime" : { - "type" : "string", - "format" : "date-time" - }, - "applicationDate" : { - "type" : "string", - "format" : "date-time" - }, - "transferDate" : { - "type" : "string", - "format" : "date-time" - }, - "standin" : { - "type" : "boolean" - }, - "debtorEntityType" : { - "type" : "string" - }, - "personalDataId" : { - "type" : "integer", - "format" : "int64" - }, - "debtorFiscalCodeHash" : { - "type" : "string", - "format" : "byte" - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "PagedModelReceiptNoPII" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "receiptNoPIIs" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/ReceiptNoPII" - } - } - } - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - }, - "page" : { - "$ref" : "#/components/schemas/PageMetadata" - } - } - }, "DebtPositionTypeOrgOperatorsRequestBody" : { "type" : "object", "properties" : { @@ -4979,11 +4990,8 @@ "type" : "string", "format" : "byte" }, - "syncStatusFrom" : { - "type" : "string" - }, - "syncStatusTo" : { - "type" : "string" + "syncStatus" : { + "$ref" : "#/components/schemas/InstallmentSyncStatus" }, "transfers" : { "type" : "array", @@ -5180,11 +5188,8 @@ "type" : "string", "format" : "byte" }, - "syncStatusFrom" : { - "type" : "string" - }, - "syncStatusTo" : { - "type" : "string" + "syncStatus" : { + "$ref" : "#/components/schemas/InstallmentSyncStatus" } } }, @@ -5548,18 +5553,6 @@ } } }, - "InstallmentSyncStatus" : { - "required" : [ "syncStatusFrom", "syncStatusTo" ], - "type" : "object", - "properties" : { - "syncStatusFrom" : { - "type" : "string" - }, - "syncStatusTo" : { - "type" : "string" - } - } - }, "PaymentOptionDTO" : { "required" : [ "installments", "paymentOptionType", "totalAmountCents" ], "type" : "object", diff --git a/openapi/p4pa-debt-position.openapi.yaml b/openapi/p4pa-debt-position.openapi.yaml index 2291349..3665e5c 100644 --- a/openapi/p4pa-debt-position.openapi.yaml +++ b/openapi/p4pa-debt-position.openapi.yaml @@ -566,9 +566,9 @@ components: type: object properties: syncStatusFrom: - type: string + $ref: "#/components/schemas/InstallmentStatus" syncStatusTo: - type: string + $ref: "#/components/schemas/InstallmentStatus" DebtPositionErrorDTO: type: object required: diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentMapper.java b/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentMapper.java index 250feb3..27ea603 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentMapper.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentMapper.java @@ -50,11 +50,10 @@ public Installment mapToModel(InstallmentDTO dto) { } public InstallmentDTO mapToDto(InstallmentNoPII installment) { - return InstallmentDTO.builder() + InstallmentDTO installmentDTO = InstallmentDTO.builder() .installmentId(installment.getInstallmentId()) .paymentOptionId(installment.getPaymentOptionId()) .status(installment.getStatus()) - .syncStatus(InstallmentSyncStatus.builder().syncStatusFrom(installment.getSyncStatusFrom()).syncStatusTo(installment.getSyncStatusTo()).build()) .iupdPagopa(installment.getIupdPagopa()) .iud(installment.getIud()) .iuv(installment.getIuv()) @@ -75,9 +74,18 @@ public InstallmentDTO mapToDto(InstallmentNoPII installment) { .creationDate(localDatetimeToOffsetDateTime(installment.getCreationDate())) .updateDate(localDatetimeToOffsetDateTime(installment.getUpdateDate())) .build(); + + if(installment.getSyncStatus() != null) { + InstallmentSyncStatus installmentSyncStatus = InstallmentSyncStatus.builder() + .syncStatusFrom(installment.getSyncStatus().getSyncStatusFrom()) + .syncStatusTo(installment.getSyncStatus().getSyncStatusTo()).build(); + installmentDTO.setSyncStatus(installmentSyncStatus); + } + + return installmentDTO; } - public InstallmentDTO mapToDto(Installment installment){ + public InstallmentDTO mapToDto(Installment installment) { return InstallmentDTO.builder() .installmentId(installment.getInstallmentId()) .paymentOptionId(installment.getPaymentOptionId()) diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentPIIMapper.java b/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentPIIMapper.java index 96f2974..a608e23 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentPIIMapper.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentPIIMapper.java @@ -29,8 +29,7 @@ public Pair map(Installment installment) { installmentNoPII.setInstallmentId(installment.getInstallmentId()); installmentNoPII.setPaymentOptionId(installment.getPaymentOptionId()); installmentNoPII.setStatus(installment.getStatus()); - installmentNoPII.setSyncStatusFrom(installment.getSyncStatus().getSyncStatusFrom()); - installmentNoPII.setSyncStatusTo(installment.getSyncStatus().getSyncStatusTo());installmentNoPII.setIupdPagopa(installment.getIupdPagopa()); + installmentNoPII.setIupdPagopa(installment.getIupdPagopa()); installmentNoPII.setIud(installment.getIud()); installmentNoPII.setIuv(installment.getIuv()); installmentNoPII.setIur(installment.getIur()); @@ -54,6 +53,12 @@ public Pair map(Installment installment) { installmentNoPII.setPersonalDataId(installment.getNoPII().getPersonalDataId()); } + if(installment.getSyncStatus() != null){ + installmentNoPII.setSyncStatus(it.gov.pagopa.pu.debtpositions.model.InstallmentSyncStatus.builder() + .syncStatusFrom(installment.getSyncStatus().getSyncStatusFrom()) + .syncStatusTo(installment.getSyncStatus().getSyncStatusTo()).build()); + } + InstallmentPIIDTO installmentPIIDTO = InstallmentPIIDTO.builder() .debtor(installment.getDebtor()).build(); @@ -62,14 +67,10 @@ public Pair map(Installment installment) { public Installment map(InstallmentNoPII installmentNoPII) { InstallmentPIIDTO pii = personalDataService.get(installmentNoPII.getPersonalDataId(), InstallmentPIIDTO.class); - return Installment.builder() + Installment installment = Installment.builder() .installmentId(installmentNoPII.getInstallmentId()) .paymentOptionId(installmentNoPII.getPaymentOptionId()) .status(installmentNoPII.getStatus()) - .syncStatus(InstallmentSyncStatus.builder() - .syncStatusFrom(installmentNoPII.getSyncStatusFrom()) - .syncStatusTo(installmentNoPII.getSyncStatusTo()) - .build()) .iupdPagopa(installmentNoPII.getIupdPagopa()) .iud(installmentNoPII.getIud()) .iuv(installmentNoPII.getIuv()) @@ -91,5 +92,13 @@ public Installment map(InstallmentNoPII installmentNoPII) { .transfers(Optional.ofNullable(installmentNoPII.getTransfers()).map(List::copyOf).orElse(List.of())) .noPII(installmentNoPII) .build(); + + if(installmentNoPII.getSyncStatus() != null) { + installment.setSyncStatus(InstallmentSyncStatus.builder() + .syncStatusFrom(installmentNoPII.getSyncStatus().getSyncStatusFrom()) + .syncStatusTo(installmentNoPII.getSyncStatus().getSyncStatusTo()) + .build()); + } + return installment; } } diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/model/InstallmentNoPII.java b/src/main/java/it/gov/pagopa/pu/debtpositions/model/InstallmentNoPII.java index 506859d..29b7028 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/model/InstallmentNoPII.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/model/InstallmentNoPII.java @@ -47,8 +47,8 @@ public class InstallmentNoPII extends BaseEntity implements Serializable, Compar private Long personalDataId; private Character debtorEntityType; private byte[] debtorFiscalCodeHash; - private String syncStatusFrom; - private String syncStatusTo; + @Embedded + private InstallmentSyncStatus syncStatus; @OneToMany(mappedBy = "installmentId") private SortedSet transfers; diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/model/InstallmentSyncStatus.java b/src/main/java/it/gov/pagopa/pu/debtpositions/model/InstallmentSyncStatus.java new file mode 100644 index 0000000..2bcc8da --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/model/InstallmentSyncStatus.java @@ -0,0 +1,26 @@ +package it.gov.pagopa.pu.debtpositions.model; + +import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentStatus; +import jakarta.persistence.Embeddable; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Embeddable +@AllArgsConstructor +@NoArgsConstructor +@Data +@Builder +public class InstallmentSyncStatus implements Serializable { + + @Enumerated(EnumType.STRING) + private InstallmentStatus syncStatusFrom; + @Enumerated(EnumType.STRING) + private InstallmentStatus syncStatusTo; + +} diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentMapperTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentMapperTest.java index 5ef654c..30ed5d4 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentMapperTest.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentMapperTest.java @@ -65,6 +65,24 @@ void givenMapToDtoThenOk(){ reflectionEqualsByName(installmentExpected, result, "debtor"); checkNotNullFields(result, "debtor"); + checkNotNullFields(result.getSyncStatus()); + } + + @Test + void givenMapToDtoWithNullSyncStatus(){ + InstallmentDTO installmentExpected = buildInstallmentDTO(); + installmentExpected.setStatus(InstallmentStatus.TO_SYNC); + installmentExpected.setSyncStatus(null); + InstallmentNoPII installmentNoPII = buildInstallmentNoPII(); + installmentNoPII.setTransfers(new TreeSet<>(List.of(buildTransfer()))); + installmentNoPII.setSyncStatus(null); + + Mockito.when(transferMapperMock.mapToDto(buildTransfer())).thenReturn(buildTransferDTO()); + + InstallmentDTO result = installmentMapper.mapToDto(installmentNoPII); + + reflectionEqualsByName(installmentExpected, result, "debtor"); + checkNotNullFields(result, "debtor", "syncStatus"); } @Test diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentPIIMapperTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentPIIMapperTest.java index 45db351..cf4e800 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentPIIMapperTest.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentPIIMapperTest.java @@ -14,7 +14,6 @@ import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.util.Pair; -import uk.co.jemos.podam.api.PodamFactory; import static it.gov.pagopa.pu.debtpositions.util.TestUtils.checkNotNullFields; import static it.gov.pagopa.pu.debtpositions.util.TestUtils.reflectionEqualsByName; @@ -33,8 +32,8 @@ class InstallmentPIIMapperTest { private PersonalDataService personalDataServiceMock; @BeforeEach - void init(){ - mapper = new InstallmentPIIMapper(dataCipherServiceMock,personalDataServiceMock); + void init() { + mapper = new InstallmentPIIMapper(dataCipherServiceMock, personalDataServiceMock); } @AfterEach @@ -45,7 +44,7 @@ void verifyNotMoreInvocation() { //region map(it.gov.pagopa.pu.debtpositions.dto.Installment) @Test - void testMap(){ + void testMap() { InstallmentNoPII installmentNoPIIExpected = buildInstallmentNoPII(); InstallmentPIIDTO installmentPIIDTOExpected = buildInstallmentPIIDTO(); @@ -62,7 +61,7 @@ void testMap(){ } @Test - void testMapWithNoPIINotNull(){ + void testMapWithNoPIINotNull() { InstallmentNoPII installmentNoPIIExpected = buildInstallmentNoPII(); InstallmentPIIDTO installmentPIIDTOExpected = buildInstallmentPIIDTO(); @@ -83,7 +82,7 @@ void testMapWithNoPIINotNull(){ //region map(it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII) @Test - void testMapInstallmentNoPII(){ + void testMapInstallmentNoPII() { //given InstallmentNoPII installmentNoPII = buildInstallmentNoPII(); InstallmentPIIDTO installmentPIIDTO = buildInstallmentPIIDTO(); @@ -93,8 +92,43 @@ void testMapInstallmentNoPII(){ Installment result = mapper.map(installmentNoPII); //then TestUtils.checkNotNullFields(result); + TestUtils.checkNotNullFields(result.getSyncStatus()); Mockito.verify(personalDataServiceMock, Mockito.times(1)).get(installmentNoPII.getPersonalDataId(), InstallmentPIIDTO.class); } //endregion + @Test + void testMapInstallmentWithNullSyncStatus() { + InstallmentNoPII installmentNoPIIExpected = buildInstallmentNoPII(); + InstallmentPIIDTO installmentPIIDTOExpected = buildInstallmentPIIDTO(); + installmentNoPIIExpected.setSyncStatus(null); + + Installment installment = buildInstallment(); + installment.setSyncStatus(null); + byte[] expectedHashedCF = {}; + Mockito.when(dataCipherServiceMock.hash(installment.getDebtor().getFiscalCode())).thenReturn(expectedHashedCF); + + Pair result = mapper.map(installment); + + reflectionEqualsByName(installmentNoPIIExpected, result.getFirst()); + reflectionEqualsByName(installmentPIIDTOExpected, result.getSecond()); + checkNotNullFields(result.getFirst(), "transfers", "personalDataId", + "debtorFiscalCodeHash", "syncStatus"); + checkNotNullFields(result.getSecond()); + } + + @Test + void testMapInstallmentNoPIIWithNullSyncStatus() { + //given + InstallmentNoPII installmentNoPII = buildInstallmentNoPII(); + installmentNoPII.setSyncStatus(null); + InstallmentPIIDTO installmentPIIDTO = buildInstallmentPIIDTO(); + Mockito.when(personalDataServiceMock.get(installmentNoPII.getPersonalDataId(), InstallmentPIIDTO.class)).thenReturn(installmentPIIDTO); + + //when + Installment result = mapper.map(installmentNoPII); + //then + TestUtils.checkNotNullFields(result, "syncStatus"); + Mockito.verify(personalDataServiceMock, Mockito.times(1)).get(installmentNoPII.getPersonalDataId(), InstallmentPIIDTO.class); + } } diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/InstallmentFaker.java b/src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/InstallmentFaker.java index 6552e8c..6880b77 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/InstallmentFaker.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/InstallmentFaker.java @@ -5,6 +5,7 @@ import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentDTO; import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentStatus; import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; +import it.gov.pagopa.pu.debtpositions.model.InstallmentSyncStatus; import java.time.LocalDateTime; import java.time.OffsetDateTime; @@ -56,8 +57,9 @@ public static InstallmentNoPII buildInstallmentNoPII(){ .installmentId(1L) .paymentOptionId(1L) .status(InstallmentStatus.TO_SYNC) - .syncStatusFrom("syncStatusFrom") - .syncStatusTo("syncStatusTo") + .syncStatus(InstallmentSyncStatus.builder() + .syncStatusFrom(InstallmentStatus.DRAFT) + .syncStatusTo(InstallmentStatus.UNPAID).build()) .iupdPagopa("iupdPagoPa") .iud("iud") .iuv("iuv") diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/InstallmentSyncStatusFaker.java b/src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/InstallmentSyncStatusFaker.java index 6bdd12d..651b9bd 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/InstallmentSyncStatusFaker.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/InstallmentSyncStatusFaker.java @@ -1,13 +1,14 @@ package it.gov.pagopa.pu.debtpositions.util.faker; +import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentStatus; import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentSyncStatus; public class InstallmentSyncStatusFaker { public static InstallmentSyncStatus buildInstallmentSyncStatus() { return InstallmentSyncStatus.builder() - .syncStatusFrom("syncStatusFrom") - .syncStatusTo("syncStatusTo") + .syncStatusFrom(InstallmentStatus.DRAFT) + .syncStatusTo(InstallmentStatus.UNPAID) .build(); } }