From 485d9a7f982e7a0a908a85081c0777d9af38c7fa Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 10:47:27 +0100 Subject: [PATCH 01/13] P4ADEV-1779 create api getInstallmentsByOrganizationIdAndNav --- .gitignore | 3 +- build.gradle.kts | 2 + openapi/generated.openapi.json | 605 ++++++++++-------- openapi/p4pa-debt-position.openapi.yaml | 32 + .../citizen/service/PersonalDataService.java | 7 + .../controller/InstallmentControllerImpl.java | 23 + .../exception/custom/NotFoundException.java | 8 + .../mapper/InstallmentMapper.java | 28 + .../mapper/InstallmentPIIMapper.java | 109 ++-- .../InstallmentNoPIIRepository.java | 12 + .../repository/InstallmentPIIRepository.java | 6 +- .../InstallmentPIIRepositoryImpl.java | 8 + .../service/InstallmentService.java | 9 + .../service/InstallmentServiceImpl.java | 26 + .../service/PersonalDataServiceTest.java | 39 ++ .../controller/InstallmentControllerTest.java | 67 ++ .../mapper/InstallmentPIIMapperTest.java | 30 +- .../InstallmentPIIRepositoryImplTest.java | 23 + .../service/InstallmentServiceImplTest.java | 55 ++ .../pu/debtpositions/util/TestUtils.java | 17 + 20 files changed, 801 insertions(+), 308 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/pu/debtpositions/controller/InstallmentControllerImpl.java create mode 100644 src/main/java/it/gov/pagopa/pu/debtpositions/exception/custom/NotFoundException.java create mode 100644 src/main/java/it/gov/pagopa/pu/debtpositions/service/InstallmentService.java create mode 100644 src/main/java/it/gov/pagopa/pu/debtpositions/service/InstallmentServiceImpl.java create mode 100644 src/test/java/it/gov/pagopa/pu/debtpositions/controller/InstallmentControllerTest.java create mode 100644 src/test/java/it/gov/pagopa/pu/debtpositions/service/InstallmentServiceImplTest.java diff --git a/.gitignore b/.gitignore index e1a6165..2cb2301 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,8 @@ HELP.md !**/src/main/**/target/ !**/src/test/**/target/ -#**/src/main/resources/application-local*.properties +### Local development resources ### +local-*.env ### STS ### .apt_generated diff --git a/build.gradle.kts b/build.gradle.kts index db687b1..6fe0443 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,6 +42,7 @@ val micrometerVersion = "1.4.1" val postgresJdbcVersion = "42.7.4" val bouncycastleVersion = "1.79" val mapStructVersion = "1.6.3" +val podamVersion = "8.0.2.RELEASE" dependencies { implementation("org.springframework.boot:spring-boot-starter") @@ -82,6 +83,7 @@ dependencies { testImplementation ("org.projectlombok:lombok") testAnnotationProcessor("org.projectlombok:lombok") testImplementation("com.h2database:h2") + testImplementation("uk.co.jemos.podam:podam:$podamVersion") } tasks.withType { diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index f1ab91a..b64ecb6 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -15,6 +15,9 @@ "tags" : [ { "name" : "debt-position", "description" : "the debt-position API" + }, { + "name" : "installment", + "description" : "the installment API" }, { "name" : "receipt", "description" : "the receipt API" @@ -3391,6 +3394,74 @@ "BearerAuth" : [ ] } ] } + }, + "/installments/{organizationId}/{nav}" : { + "get" : { + "tags" : [ "installment" ], + "operationId" : "getInstallmentsByOrganizationIdAndNav", + "parameters" : [ { + "name" : "organizationId", + "in" : "path", + "description" : "The ID of the organization", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + }, { + "name" : "nav", + "in" : "path", + "description" : "The nav of the installments", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "Ok", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InstallmentDTO" + } + } + } + } + }, + "400" : { + "description" : "Invalid request", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InstallmentDTO" + } + } + } + } + }, + "500" : { + "description" : "Internal server error", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InstallmentDTO" + } + } + } + } + } + }, + "security" : [ { + "BearerAuth" : [ ] + } ] + } } }, "components" : { @@ -3475,124 +3546,145 @@ } } }, - "InstallmentNoPII" : { + "DebtPositionTypeWithCount" : { "type" : "object", "properties" : { - "creationDate" : { - "type" : "string", - "format" : "date-time" + "debtPositionTypeId" : { + "type" : "integer", + "format" : "int64" + }, + "code" : { + "type" : "string" + }, + "description" : { + "type" : "string" }, "updateDate" : { "type" : "string", "format" : "date-time" }, - "updateOperatorExternalId" : { - "type" : "string" + "activeOrganizations" : { + "type" : "integer", + "format" : "int32" }, - "installmentId" : { + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "PageMetadata" : { + "type" : "object", + "properties" : { + "size" : { "type" : "integer", "format" : "int64" }, - "paymentOptionId" : { + "totalElements" : { "type" : "integer", "format" : "int64" }, - "status" : { - "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] - }, - "iupdPagopa" : { - "type" : "string" - }, - "iud" : { - "type" : "string" - }, - "iuv" : { - "type" : "string" - }, - "iur" : { - "type" : "string" - }, - "iuf" : { - "type" : "string" - }, - "nav" : { - "type" : "string" - }, - "dueDate" : { - "type" : "string", - "format" : "date-time" - }, - "paymentTypeCode" : { - "type" : "string" - }, - "amountCents" : { + "totalPages" : { "type" : "integer", "format" : "int64" }, - "notificationFeeCents" : { + "number" : { "type" : "integer", "format" : "int64" + } + } + }, + "PagedModelDebtPositionTypeWithCount" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "debtPositionTypeWithCounts" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/DebtPositionTypeWithCount" + } + } + } }, - "remittanceInformation" : { - "type" : "string" + "_links" : { + "$ref" : "#/components/schemas/Links" }, - "humanFriendlyRemittanceInformation" : { - "type" : "string" + "page" : { + "$ref" : "#/components/schemas/PageMetadata" + } + } + }, + "DebtPosition" : { + "type" : "object", + "properties" : { + "creationDate" : { + "type" : "string", + "format" : "date-time" }, - "balance" : { - "type" : "string" + "updateDate" : { + "type" : "string", + "format" : "date-time" }, - "legacyPaymentMetadata" : { + "updateOperatorExternalId" : { "type" : "string" }, - "personalDataId" : { + "debtPositionId" : { "type" : "integer", "format" : "int64" }, - "debtorEntityType" : { + "iupdOrg" : { "type" : "string" }, - "debtorFiscalCodeHash" : { + "description" : { + "type" : "string" + }, + "status" : { "type" : "string", - "format" : "byte" + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "PageMetadata" : { - "type" : "object", - "properties" : { - "size" : { + "ingestionFlowFileId" : { "type" : "integer", "format" : "int64" }, - "totalElements" : { + "ingestionFlowFileLineNumber" : { "type" : "integer", "format" : "int64" }, - "totalPages" : { + "organizationId" : { "type" : "integer", "format" : "int64" }, - "number" : { + "debtPositionTypeOrgId" : { "type" : "integer", "format" : "int64" + }, + "notificationDate" : { + "type" : "string", + "format" : "date-time" + }, + "validityDate" : { + "type" : "string", + "format" : "date-time" + }, + "flagIuvVolatile" : { + "type" : "boolean" + }, + "_links" : { + "$ref" : "#/components/schemas/Links" } } }, - "PagedModelInstallmentNoPII" : { + "PagedModelDebtPosition" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "installmentNoPIIs" : { + "debtPositions" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/InstallmentNoPII" + "$ref" : "#/components/schemas/DebtPosition" } } } @@ -3619,16 +3711,16 @@ } } }, - "CollectionModelTransfer" : { + "CollectionModelPaymentOption" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "transfers" : { + "paymentOptions" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/TransferResponse" + "$ref" : "#/components/schemas/PaymentOptionResponse" } } } @@ -3657,7 +3749,7 @@ } } }, - "Transfer" : { + "DebtPositionTypeOrg" : { "type" : "object", "properties" : { "creationDate" : { @@ -3671,29 +3763,26 @@ "updateOperatorExternalId" : { "type" : "string" }, - "transferId" : { + "debtPositionTypeOrgId" : { "type" : "integer", "format" : "int64" }, - "installmentId" : { + "debtPositionTypeId" : { "type" : "integer", "format" : "int64" }, - "orgFiscalCode" : { - "type" : "string" - }, - "orgName" : { - "type" : "string" - }, - "amountCents" : { + "organizationId" : { "type" : "integer", "format" : "int64" }, - "remittanceInformation" : { + "balance" : { "type" : "string" }, - "stamp" : { - "$ref" : "#/components/schemas/Stamp" + "code" : { + "type" : "string" + }, + "description" : { + "type" : "string" }, "iban" : { "type" : "string" @@ -3701,28 +3790,75 @@ "postalIban" : { "type" : "string" }, - "category" : { + "postalAccountCode" : { "type" : "string" }, - "transferIndex" : { + "holderPostalCc" : { + "type" : "string" + }, + "orgSector" : { + "type" : "string" + }, + "xsdDefinitionRef" : { + "type" : "string" + }, + "amountCents" : { "type" : "integer", "format" : "int64" }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "PagedModelTransfer" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "transfers" : { + "externalPaymentUrl" : { + "type" : "string" + }, + "flagAnonymousFiscalCode" : { + "type" : "boolean" + }, + "flagMandatoryDueDate" : { + "type" : "boolean" + }, + "flagSpontaneous" : { + "type" : "boolean" + }, + "flagNotifyIo" : { + "type" : "boolean" + }, + "ioTemplateMessage" : { + "type" : "string" + }, + "flagActive" : { + "type" : "boolean" + }, + "flagNotifyOutcomePush" : { + "type" : "boolean" + }, + "notifyOutcomePushOrgSilServiceId" : { + "type" : "integer", + "format" : "int64" + }, + "flagAmountActualization" : { + "type" : "boolean" + }, + "amountActualizationOrgSilServiceId" : { + "type" : "integer", + "format" : "int64" + }, + "flagExternal" : { + "type" : "boolean" + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "PagedModelDebtPositionTypeOrg" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "debtPositionTypeOrgs" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/Transfer" + "$ref" : "#/components/schemas/DebtPositionTypeOrg" } } } @@ -3735,7 +3871,7 @@ } } }, - "DebtPositionType" : { + "Transfer" : { "type" : "object", "properties" : { "creationDate" : { @@ -3749,62 +3885,58 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionTypeId" : { + "transferId" : { "type" : "integer", "format" : "int64" }, - "brokerId" : { + "installmentId" : { "type" : "integer", "format" : "int64" }, - "code" : { + "orgFiscalCode" : { "type" : "string" }, - "description" : { + "orgName" : { "type" : "string" }, - "orgType" : { - "type" : "string" + "amountCents" : { + "type" : "integer", + "format" : "int64" }, - "macroArea" : { + "remittanceInformation" : { "type" : "string" }, - "serviceType" : { - "type" : "string" + "stamp" : { + "$ref" : "#/components/schemas/Stamp" }, - "collectingReason" : { + "iban" : { "type" : "string" }, - "taxonomyCode" : { + "postalIban" : { "type" : "string" }, - "flagAnonymousFiscalCode" : { - "type" : "boolean" - }, - "flagMandatoryDueDate" : { - "type" : "boolean" - }, - "flagNotifyIo" : { - "type" : "boolean" - }, - "ioTemplateMessage" : { + "category" : { "type" : "string" }, + "transferIndex" : { + "type" : "integer", + "format" : "int64" + }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPositionType" : { + "PagedModelTransfer" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypes" : { + "transfers" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionType" + "$ref" : "#/components/schemas/Transfer" } } } @@ -3817,7 +3949,7 @@ } } }, - "DebtPositionTypeOrg" : { + "InstallmentNoPII" : { "type" : "object", "properties" : { "creationDate" : { @@ -3831,102 +3963,89 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionTypeOrgId" : { - "type" : "integer", - "format" : "int64" - }, - "debtPositionTypeId" : { + "installmentId" : { "type" : "integer", "format" : "int64" }, - "organizationId" : { + "paymentOptionId" : { "type" : "integer", "format" : "int64" }, - "balance" : { - "type" : "string" + "status" : { + "type" : "string", + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] }, - "code" : { + "iupdPagopa" : { "type" : "string" }, - "description" : { + "iud" : { "type" : "string" }, - "iban" : { + "iuv" : { "type" : "string" }, - "postalIban" : { + "iur" : { "type" : "string" }, - "postalAccountCode" : { + "iuf" : { "type" : "string" }, - "holderPostalCc" : { + "nav" : { "type" : "string" }, - "orgSector" : { - "type" : "string" + "dueDate" : { + "type" : "string", + "format" : "date-time" }, - "xsdDefinitionRef" : { + "paymentTypeCode" : { "type" : "string" }, "amountCents" : { "type" : "integer", "format" : "int64" }, - "externalPaymentUrl" : { - "type" : "string" - }, - "flagAnonymousFiscalCode" : { - "type" : "boolean" - }, - "flagMandatoryDueDate" : { - "type" : "boolean" - }, - "flagSpontaneous" : { - "type" : "boolean" + "notificationFeeCents" : { + "type" : "integer", + "format" : "int64" }, - "flagNotifyIo" : { - "type" : "boolean" + "remittanceInformation" : { + "type" : "string" }, - "ioTemplateMessage" : { + "humanFriendlyRemittanceInformation" : { "type" : "string" }, - "flagActive" : { - "type" : "boolean" + "balance" : { + "type" : "string" }, - "flagNotifyOutcomePush" : { - "type" : "boolean" + "legacyPaymentMetadata" : { + "type" : "string" }, - "notifyOutcomePushOrgSilServiceId" : { + "personalDataId" : { "type" : "integer", "format" : "int64" }, - "flagAmountActualization" : { - "type" : "boolean" - }, - "amountActualizationOrgSilServiceId" : { - "type" : "integer", - "format" : "int64" + "debtorEntityType" : { + "type" : "string" }, - "flagExternal" : { - "type" : "boolean" + "debtorFiscalCodeHash" : { + "type" : "string", + "format" : "byte" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPositionTypeOrg" : { + "PagedModelInstallmentNoPII" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypeOrgs" : { + "installmentNoPIIs" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionTypeOrg" + "$ref" : "#/components/schemas/InstallmentNoPII" } } } @@ -3939,55 +4058,22 @@ } } }, - "DebtPositionTypeOrgOperators" : { - "type" : "object", - "properties" : { - "creationDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateOperatorExternalId" : { - "type" : "string" - }, - "debtPositionTypeOrgOperatorId" : { - "type" : "integer", - "format" : "int64" - }, - "debtPositionTypeOrgId" : { - "type" : "integer", - "format" : "int64" - }, - "operatorExternalUserId" : { - "type" : "string" - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "PagedModelDebtPositionTypeOrgOperators" : { + "CollectionModelTransfer" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypeOrgOperatorses" : { + "transfers" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionTypeOrgOperators" + "$ref" : "#/components/schemas/TransferResponse" } } } }, "_links" : { "$ref" : "#/components/schemas/Links" - }, - "page" : { - "$ref" : "#/components/schemas/PageMetadata" } } }, @@ -4129,42 +4215,46 @@ } } }, - "DebtPositionTypeWithCount" : { + "DebtPositionTypeOrgOperators" : { "type" : "object", "properties" : { - "debtPositionTypeId" : { - "type" : "integer", - "format" : "int64" - }, - "code" : { - "type" : "string" - }, - "description" : { - "type" : "string" + "creationDate" : { + "type" : "string", + "format" : "date-time" }, "updateDate" : { "type" : "string", "format" : "date-time" }, - "activeOrganizations" : { + "updateOperatorExternalId" : { + "type" : "string" + }, + "debtPositionTypeOrgOperatorId" : { "type" : "integer", - "format" : "int32" + "format" : "int64" + }, + "debtPositionTypeOrgId" : { + "type" : "integer", + "format" : "int64" + }, + "operatorExternalUserId" : { + "type" : "string" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPositionTypeWithCount" : { + "PagedModelDebtPositionTypeOrgOperators" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypeWithCounts" : { + "debtPositionTypeOrgOperatorses" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionTypeWithCount" + "$ref" : "#/components/schemas/DebtPositionTypeOrgOperators" } } } @@ -4177,7 +4267,7 @@ } } }, - "DebtPosition" : { + "DebtPositionType" : { "type" : "object", "properties" : { "creationDate" : { @@ -4191,62 +4281,62 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionId" : { + "debtPositionTypeId" : { "type" : "integer", "format" : "int64" }, - "iupdOrg" : { + "brokerId" : { + "type" : "integer", + "format" : "int64" + }, + "code" : { "type" : "string" }, "description" : { "type" : "string" }, - "status" : { - "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + "orgType" : { + "type" : "string" }, - "ingestionFlowFileId" : { - "type" : "integer", - "format" : "int64" + "macroArea" : { + "type" : "string" }, - "ingestionFlowFileLineNumber" : { - "type" : "integer", - "format" : "int64" + "serviceType" : { + "type" : "string" }, - "organizationId" : { - "type" : "integer", - "format" : "int64" + "collectingReason" : { + "type" : "string" }, - "debtPositionTypeOrgId" : { - "type" : "integer", - "format" : "int64" + "taxonomyCode" : { + "type" : "string" }, - "notificationDate" : { - "type" : "string", - "format" : "date-time" + "flagAnonymousFiscalCode" : { + "type" : "boolean" }, - "validityDate" : { - "type" : "string", - "format" : "date-time" + "flagMandatoryDueDate" : { + "type" : "boolean" }, - "flagIuvVolatile" : { + "flagNotifyIo" : { "type" : "boolean" }, + "ioTemplateMessage" : { + "type" : "string" + }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPosition" : { + "PagedModelDebtPositionType" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositions" : { + "debtPositionTypes" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPosition" + "$ref" : "#/components/schemas/DebtPositionType" } } } @@ -4259,25 +4349,6 @@ } } }, - "CollectionModelPaymentOption" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "paymentOptions" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/PaymentOptionResponse" - } - } - } - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, "PaymentOption" : { "type" : "object", "properties" : { diff --git a/openapi/p4pa-debt-position.openapi.yaml b/openapi/p4pa-debt-position.openapi.yaml index 17962c6..697ad64 100644 --- a/openapi/p4pa-debt-position.openapi.yaml +++ b/openapi/p4pa-debt-position.openapi.yaml @@ -46,6 +46,38 @@ paths: $ref: "#/components/schemas/DebtPositionErrorDTO" "500": description: Internal server error + /installments/{organizationId}/{nav}: + get: + tags: + - installment + operationId: getInstallmentsByOrganizationIdAndNav + parameters: + - name: organizationId + in: path + required: true + schema: + type: integer + format: int64 + description: The ID of the organization + - name: nav + in: path + required: true + schema: + type: string + description: The nav of the installments + responses: + "200": + description: Ok + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/InstallmentDTO" + "400": + description: Invalid request + "500": + description: Internal server error /receipts: post: tags: diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataService.java b/src/main/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataService.java index 1854e08..d4a680a 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataService.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataService.java @@ -3,6 +3,7 @@ import it.gov.pagopa.pu.debtpositions.citizen.enums.PersonalDataType; import it.gov.pagopa.pu.debtpositions.citizen.model.PersonalData; import it.gov.pagopa.pu.debtpositions.citizen.repository.PersonalDataRepository; +import it.gov.pagopa.pu.debtpositions.exception.custom.NotFoundException; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -25,4 +26,10 @@ public long insert(Object pii, PersonalDataType type) { .build()).getId(); } + public T get(Long personalDataId, Class classType) { + return repository.findById(personalDataId) + .map(personalData -> dataCipherService.decryptObj(personalData.getData(), classType)) + .orElseThrow(() -> new NotFoundException("installment pii not found for id " + personalDataId)); + } + } diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/controller/InstallmentControllerImpl.java b/src/main/java/it/gov/pagopa/pu/debtpositions/controller/InstallmentControllerImpl.java new file mode 100644 index 0000000..e341e26 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/controller/InstallmentControllerImpl.java @@ -0,0 +1,23 @@ +package it.gov.pagopa.pu.debtpositions.controller; + +import it.gov.pagopa.pu.debtpositions.controller.generated.InstallmentApi; +import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentDTO; +import it.gov.pagopa.pu.debtpositions.service.InstallmentService; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +public class InstallmentControllerImpl implements InstallmentApi { + private final InstallmentService installmentService; + + public InstallmentControllerImpl(InstallmentService installmentService) { + this.installmentService = installmentService; + } + + @Override + public ResponseEntity> getInstallmentsByOrganizationIdAndNav(Long organizationId, String nav) { + return ResponseEntity.ok(installmentService.getInstallmentsByOrganizationIdAndNav(organizationId, nav)); + } +} diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/exception/custom/NotFoundException.java b/src/main/java/it/gov/pagopa/pu/debtpositions/exception/custom/NotFoundException.java new file mode 100644 index 0000000..928b956 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/exception/custom/NotFoundException.java @@ -0,0 +1,8 @@ +package it.gov.pagopa.pu.debtpositions.exception.custom; + +public class NotFoundException extends RuntimeException { + + public NotFoundException(String message) { + super(message); + } +} 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 2b74645..d40f7a5 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 @@ -74,5 +74,33 @@ public InstallmentDTO mapToDto(InstallmentNoPII installment) { .build(); } + public InstallmentDTO mapToDto(Installment installment){ + return InstallmentDTO.builder() + .installmentId(installment.getInstallmentId()) + .paymentOptionId(installment.getPaymentOptionId()) + .status(installment.getStatus()) + .iupdPagopa(installment.getIupdPagopa()) + .iud(installment.getIud()) + .iuv(installment.getIuv()) + .iur(installment.getIur()) + .iuf(installment.getIuf()) + .nav(installment.getNav()) + .dueDate(installment.getDueDate()) + .paymentTypeCode(installment.getPaymentTypeCode()) + .amountCents(installment.getAmountCents()) + .notificationFeeCents(installment.getNotificationFeeCents()) + .remittanceInformation(installment.getRemittanceInformation()) + .humanFriendlyRemittanceInformation(installment.getHumanFriendlyRemittanceInformation()) + .balance(installment.getBalance()) + .legacyPaymentMetadata(installment.getLegacyPaymentMetadata()) + .debtor(null) //TODO P4ADEV-2028 + .transfers(installment.getTransfers().stream() + .map(transferMapper::mapToDto) + .toList()) + .creationDate(localDatetimeToOffsetDateTime(installment.getCreationDate())) + .updateDate(localDatetimeToOffsetDateTime(installment.getUpdateDate())) + .build(); + } + } 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 012dd70..b963365 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 @@ -1,54 +1,87 @@ package it.gov.pagopa.pu.debtpositions.mapper; import it.gov.pagopa.pu.debtpositions.citizen.service.DataCipherService; +import it.gov.pagopa.pu.debtpositions.citizen.service.PersonalDataService; import it.gov.pagopa.pu.debtpositions.dto.Installment; import it.gov.pagopa.pu.debtpositions.dto.InstallmentPIIDTO; import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; import org.springframework.data.util.Pair; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class InstallmentPIIMapper { - private final DataCipherService dataCipherService; + private final DataCipherService dataCipherService; + private final PersonalDataService personalDataService; - public InstallmentPIIMapper(DataCipherService dataCipherService) { - this.dataCipherService = dataCipherService; - } + public InstallmentPIIMapper(DataCipherService dataCipherService, PersonalDataService personalDataService) { + this.dataCipherService = dataCipherService; + this.personalDataService = personalDataService; + } + + public Pair map(Installment installment) { + InstallmentNoPII installmentNoPII = new InstallmentNoPII(); + + installmentNoPII.setInstallmentId(installment.getInstallmentId()); + installmentNoPII.setPaymentOptionId(installment.getPaymentOptionId()); + installmentNoPII.setStatus(installment.getStatus()); + installmentNoPII.setIupdPagopa(installment.getIupdPagopa()); + installmentNoPII.setIud(installment.getIud()); + installmentNoPII.setIuv(installment.getIuv()); + installmentNoPII.setIur(installment.getIur()); + installmentNoPII.setIuf(installment.getIuf()); + installmentNoPII.setNav(installment.getNav()); + installmentNoPII.setDueDate(installment.getDueDate()); + installmentNoPII.setPaymentTypeCode(installment.getPaymentTypeCode()); + installmentNoPII.setAmountCents(installment.getAmountCents()); + installmentNoPII.setNotificationFeeCents(installment.getNotificationFeeCents()); + installmentNoPII.setRemittanceInformation(installment.getRemittanceInformation()); + installmentNoPII.setHumanFriendlyRemittanceInformation(installment.getHumanFriendlyRemittanceInformation()); + installmentNoPII.setBalance(installment.getBalance()); + installmentNoPII.setLegacyPaymentMetadata(installment.getLegacyPaymentMetadata()); + installmentNoPII.setDebtorEntityType(installment.getDebtor().getEntityType().charAt(0)); + installmentNoPII.setDebtorFiscalCodeHash(dataCipherService.hash(installment.getDebtor().getFiscalCode())); + installmentNoPII.setCreationDate(installment.getCreationDate()); + installmentNoPII.setUpdateDate(installment.getUpdateDate()); + installmentNoPII.setUpdateOperatorExternalId(installment.getUpdateOperatorExternalId()); - public Pair map(Installment installment) { - InstallmentNoPII installmentNoPII = new InstallmentNoPII(); - - installmentNoPII.setInstallmentId(installment.getInstallmentId()); - installmentNoPII.setPaymentOptionId(installment.getPaymentOptionId()); - installmentNoPII.setStatus(installment.getStatus()); - installmentNoPII.setIupdPagopa(installment.getIupdPagopa()); - installmentNoPII.setIud(installment.getIud()); - installmentNoPII.setIuv(installment.getIuv()); - installmentNoPII.setIur(installment.getIur()); - installmentNoPII.setIuf(installment.getIuf()); - installmentNoPII.setNav(installment.getNav()); - installmentNoPII.setDueDate(installment.getDueDate()); - installmentNoPII.setPaymentTypeCode(installment.getPaymentTypeCode()); - installmentNoPII.setAmountCents(installment.getAmountCents()); - installmentNoPII.setNotificationFeeCents(installment.getNotificationFeeCents()); - installmentNoPII.setRemittanceInformation(installment.getRemittanceInformation()); - installmentNoPII.setHumanFriendlyRemittanceInformation(installment.getHumanFriendlyRemittanceInformation()); - installmentNoPII.setBalance(installment.getBalance()); - installmentNoPII.setLegacyPaymentMetadata(installment.getLegacyPaymentMetadata()); - installmentNoPII.setDebtorEntityType(installment.getDebtor().getEntityType().charAt(0)); - installmentNoPII.setDebtorFiscalCodeHash(dataCipherService.hash(installment.getDebtor().getFiscalCode())); - installmentNoPII.setCreationDate(installment.getCreationDate()); - installmentNoPII.setUpdateDate(installment.getUpdateDate()); - installmentNoPII.setUpdateOperatorExternalId(installment.getUpdateOperatorExternalId()); - - if(installment.getNoPII() != null){ - installmentNoPII.setPersonalDataId(installment.getNoPII().getPersonalDataId()); - } - - InstallmentPIIDTO installmentPIIDTO = InstallmentPIIDTO.builder() - .debtor(installment.getDebtor()).build(); - - return Pair.of(installmentNoPII, installmentPIIDTO); + if (installment.getNoPII() != null) { + installmentNoPII.setPersonalDataId(installment.getNoPII().getPersonalDataId()); } + + InstallmentPIIDTO installmentPIIDTO = InstallmentPIIDTO.builder() + .debtor(installment.getDebtor()).build(); + + return Pair.of(installmentNoPII, installmentPIIDTO); + } + + public Installment map(InstallmentNoPII installmentNoPII) { + InstallmentPIIDTO pii = personalDataService.get(installmentNoPII.getPersonalDataId(), InstallmentPIIDTO.class); + return Installment.builder() + .installmentId(installmentNoPII.getInstallmentId()) + .paymentOptionId(installmentNoPII.getPaymentOptionId()) + .status(installmentNoPII.getStatus()) + .iupdPagopa(installmentNoPII.getIupdPagopa()) + .iud(installmentNoPII.getIud()) + .iuv(installmentNoPII.getIuv()) + .iur(installmentNoPII.getIur()) + .iuf(installmentNoPII.getIuf()) + .nav(installmentNoPII.getNav()) + .dueDate(installmentNoPII.getDueDate()) + .paymentTypeCode(installmentNoPII.getPaymentTypeCode()) + .amountCents(installmentNoPII.getAmountCents()) + .notificationFeeCents(installmentNoPII.getNotificationFeeCents()) + .remittanceInformation(installmentNoPII.getRemittanceInformation()) + .humanFriendlyRemittanceInformation(installmentNoPII.getHumanFriendlyRemittanceInformation()) + .balance(installmentNoPII.getBalance()) + .legacyPaymentMetadata(installmentNoPII.getLegacyPaymentMetadata()) + .creationDate(installmentNoPII.getCreationDate()) + .updateDate(installmentNoPII.getUpdateDate()) + .updateOperatorExternalId(installmentNoPII.getUpdateOperatorExternalId()) + .debtor(pii.getDebtor()) + .transfers(List.copyOf(installmentNoPII.getTransfers())) + .build(); + } } diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentNoPIIRepository.java b/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentNoPIIRepository.java index 7ad0ac9..f78f77f 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentNoPIIRepository.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentNoPIIRepository.java @@ -10,6 +10,8 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RestResource; +import java.util.List; + @RepositoryRestResource(path = "installments") public interface InstallmentNoPIIRepository extends JpaRepository { @@ -20,4 +22,14 @@ public interface InstallmentNoPIIRepository extends JpaRepository getByOrganizationIdAndNav(@Param("organizationId") Long organizationId, @Param("nav") String nav); } diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepository.java b/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepository.java index c974f5e..cc7c6d2 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepository.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepository.java @@ -2,7 +2,11 @@ import it.gov.pagopa.pu.debtpositions.dto.Installment; +import java.util.List; + public interface InstallmentPIIRepository { - long save(Installment installment); + long save(Installment installment); + + List getByOrganizationIdAndNav(Long organizationId, String nav); } diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepositoryImpl.java b/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepositoryImpl.java index 6761acb..02d13c3 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepositoryImpl.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepositoryImpl.java @@ -9,6 +9,8 @@ import org.springframework.data.util.Pair; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class InstallmentPIIRepositoryImpl implements InstallmentPIIRepository { @@ -33,4 +35,10 @@ public long save(Installment installment) { installment.getNoPII().setInstallmentId(newId); return newId; } + + @Override + public List getByOrganizationIdAndNav(Long organizationId, String nav) { + return installmentNoPIIRepository.getByOrganizationIdAndNav(organizationId, nav) + .stream().map(installmentPIIMapper::map).toList(); + } } diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/service/InstallmentService.java b/src/main/java/it/gov/pagopa/pu/debtpositions/service/InstallmentService.java new file mode 100644 index 0000000..b250eb4 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/service/InstallmentService.java @@ -0,0 +1,9 @@ +package it.gov.pagopa.pu.debtpositions.service; + +import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentDTO; + +import java.util.List; + +public interface InstallmentService { + List getInstallmentsByOrganizationIdAndNav(Long organizationId, String nav); +} diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/service/InstallmentServiceImpl.java b/src/main/java/it/gov/pagopa/pu/debtpositions/service/InstallmentServiceImpl.java new file mode 100644 index 0000000..76651a3 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/service/InstallmentServiceImpl.java @@ -0,0 +1,26 @@ +package it.gov.pagopa.pu.debtpositions.service; + +import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentDTO; +import it.gov.pagopa.pu.debtpositions.mapper.InstallmentMapper; +import it.gov.pagopa.pu.debtpositions.repository.InstallmentPIIRepository; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class InstallmentServiceImpl implements InstallmentService { + private final InstallmentPIIRepository installmentPIIRepository; + private final InstallmentMapper installmentMapper; + + public InstallmentServiceImpl(InstallmentPIIRepository installmentPIIRepository, InstallmentMapper installmentMapper) { + this.installmentPIIRepository = installmentPIIRepository; + this.installmentMapper = installmentMapper; + } + + @Override + public List getInstallmentsByOrganizationIdAndNav(Long organizationId, String nav) { + return installmentPIIRepository.getByOrganizationIdAndNav(organizationId, nav).stream() + .map(installmentMapper::mapToDto) + .toList(); + } +} diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataServiceTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataServiceTest.java index 8b713e2..2080597 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataServiceTest.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataServiceTest.java @@ -4,6 +4,9 @@ import it.gov.pagopa.pu.debtpositions.citizen.model.PersonalData; import it.gov.pagopa.pu.debtpositions.citizen.repository.PersonalDataRepository; import it.gov.pagopa.pu.debtpositions.dto.InstallmentPIIDTO; +import it.gov.pagopa.pu.debtpositions.exception.custom.NotFoundException; +import it.gov.pagopa.pu.debtpositions.util.TestUtils; +import org.apache.commons.lang3.builder.EqualsBuilder; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -12,6 +15,9 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; +import uk.co.jemos.podam.api.PodamFactory; + +import java.util.Optional; @ExtendWith(MockitoExtension.class) class PersonalDataServiceTest { @@ -23,6 +29,8 @@ class PersonalDataServiceTest { private PersonalDataService service; + private final PodamFactory podamFactory = TestUtils.getPodamFactory(); + @BeforeEach void init() { service = new PersonalDataService(repositoryMock, cipherServiceMock); @@ -63,4 +71,35 @@ void testInsert() { Assertions.assertEquals(piiId, insert); } + //region get + + @Test + void givenValidPersonalDataIdWhenGetThenOk(){ + //given + InstallmentPIIDTO expected = podamFactory.manufacturePojo(InstallmentPIIDTO.class); + Mockito.when(repositoryMock.findById(1L)).thenReturn( + Optional.of(PersonalData.builder().id(1L).data(new byte[0]).type(PersonalDataType.INSTALLMENT.name()).build())); + Mockito.when(cipherServiceMock.decryptObj(new byte[0], InstallmentPIIDTO.class)).thenReturn(expected); + //when + InstallmentPIIDTO installmentPIIDTO = service.get(1L, InstallmentPIIDTO.class); + //then + Assertions.assertTrue(EqualsBuilder.reflectionEquals(expected, installmentPIIDTO,true, null, true)); + Mockito.verify(repositoryMock, Mockito.times(1)).findById(1L); + Mockito.verify(cipherServiceMock, Mockito.times(1)).decryptObj(new byte[0], InstallmentPIIDTO.class); + } + + @Test + void givenNotFoundPersonalDataIdWhenGetThenException(){ + //given + Mockito.when(repositoryMock.findById(1L)).thenReturn(null); + //when + NotFoundException notFoundException = Assertions.assertThrows(NotFoundException.class, () -> service.get(1L, InstallmentPIIDTO.class)); + //then + Assertions.assertEquals("installment pii not found for id 1", notFoundException.getMessage()); + Mockito.verify(repositoryMock, Mockito.times(1)).findById(1L); + Mockito.verifyNoInteractions(cipherServiceMock); + } + + //endregion + } diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/controller/InstallmentControllerTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/controller/InstallmentControllerTest.java new file mode 100644 index 0000000..988632e --- /dev/null +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/controller/InstallmentControllerTest.java @@ -0,0 +1,67 @@ +package it.gov.pagopa.pu.debtpositions.controller; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentDTO; +import it.gov.pagopa.pu.debtpositions.service.InstallmentService; +import it.gov.pagopa.pu.debtpositions.util.TestUtils; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.bean.override.mockito.MockitoBean; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import uk.co.jemos.podam.api.PodamFactory; + +import java.util.List; + +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@WebMvcTest(InstallmentControllerImpl.class) +@AutoConfigureMockMvc(addFilters = false) +class InstallmentControllerTest { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private ObjectMapper objectMapper; + + @MockitoBean + private InstallmentService installmentServiceMock; + + private final PodamFactory podamFactory = TestUtils.getPodamFactory(); + + @Test + void whenGetInstallmentsByOrganizationIdAndNavThenOk() throws Exception { + //given + List installmentDTOList = podamFactory.manufacturePojo(List.class, InstallmentDTO.class); + + Mockito.when(installmentServiceMock.getInstallmentsByOrganizationIdAndNav(1L, "NAV")).thenReturn(installmentDTOList); + + MvcResult result = mockMvc.perform( + MockMvcRequestBuilders.get("/installments/{organizationId}/{nav}",1L,"NAV") + .contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isOk()) + .andReturn(); + + List resultResponse = objectMapper.readValue(result.getResponse().getContentAsString(), new TypeReference>(){}); + for(int idx = 0; idx < installmentDTOList.size(); idx++) { + InstallmentDTO resultElem = resultResponse.get(idx); + InstallmentDTO expectedElem = installmentDTOList.get(idx); + Assertions.assertTrue(EqualsBuilder.reflectionEquals(expectedElem, resultElem, false, null, true, + "transfers", "dueDate", "creationDate", "updateDate"), "Error on element " + idx); + Assertions.assertEquals(expectedElem.getDueDate().toInstant(), resultElem.getDueDate().toInstant()); + Assertions.assertEquals(expectedElem.getCreationDate().toInstant(), resultElem.getCreationDate().toInstant()); + Assertions.assertEquals(expectedElem.getUpdateDate().toInstant(), resultElem.getUpdateDate().toInstant()); + Assertions.assertIterableEquals(expectedElem.getTransfers(), resultElem.getTransfers()); + } + Mockito.verify(installmentServiceMock, Mockito.times(1)).getInstallmentsByOrganizationIdAndNav(1L, "NAV"); + } +} 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 c5d1ea9..957ea41 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 @@ -1,9 +1,11 @@ package it.gov.pagopa.pu.debtpositions.mapper; import it.gov.pagopa.pu.debtpositions.citizen.service.DataCipherService; +import it.gov.pagopa.pu.debtpositions.citizen.service.PersonalDataService; import it.gov.pagopa.pu.debtpositions.dto.Installment; import it.gov.pagopa.pu.debtpositions.dto.InstallmentPIIDTO; import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; +import it.gov.pagopa.pu.debtpositions.util.TestUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -12,6 +14,7 @@ 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; @@ -26,9 +29,14 @@ class InstallmentPIIMapperTest { @Mock private DataCipherService dataCipherServiceMock; + @Mock + private PersonalDataService personalDataServiceMock; + + private final PodamFactory podamFactory = TestUtils.getPodamFactory(); + @BeforeEach void init(){ - mapper = new InstallmentPIIMapper(dataCipherServiceMock); + mapper = new InstallmentPIIMapper(dataCipherServiceMock,personalDataServiceMock); } @AfterEach @@ -36,6 +44,8 @@ void verifyNotMoreInvocation() { Mockito.verifyNoMoreInteractions(dataCipherServiceMock); } + //region map(it.gov.pagopa.pu.debtpositions.dto.Installment) + @Test void testMap(){ InstallmentNoPII installmentNoPIIExpected = buildInstallmentNoPII(); @@ -71,4 +81,22 @@ void testMapWithNoPIINotNull(){ checkNotNullFields(result.getSecond()); } + //endregion + + //region map(it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII) + @Test + void testMapInstallmentNoPII(){ + //given + InstallmentNoPII installmentNoPII = podamFactory.manufacturePojo(InstallmentNoPII.class); + InstallmentPIIDTO installmentPIIDTO = podamFactory.manufacturePojo(InstallmentPIIDTO.class); + Mockito.when(personalDataServiceMock.get(installmentNoPII.getPersonalDataId(), InstallmentPIIDTO.class)).thenReturn(installmentPIIDTO); + + //when + Installment result = mapper.map(installmentNoPII); + //then + TestUtils.checkNotNullFields(result,"noPII"); + Mockito.verify(personalDataServiceMock, Mockito.times(1)).get(installmentNoPII.getPersonalDataId(), InstallmentPIIDTO.class); + } + //endregion + } diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepositoryImplTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepositoryImplTest.java index e0933fd..a804b88 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepositoryImplTest.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/repository/InstallmentPIIRepositoryImplTest.java @@ -6,6 +6,7 @@ import it.gov.pagopa.pu.debtpositions.dto.InstallmentPIIDTO; import it.gov.pagopa.pu.debtpositions.mapper.InstallmentPIIMapper; import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; +import it.gov.pagopa.pu.debtpositions.util.TestUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -15,6 +16,9 @@ import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.util.Pair; +import uk.co.jemos.podam.api.PodamFactory; + +import java.util.List; @ExtendWith(MockitoExtension.class) class InstallmentPIIRepositoryImplTest { @@ -28,6 +32,8 @@ class InstallmentPIIRepositoryImplTest { private InstallmentPIIRepository installmentPIIRepository; + private final PodamFactory podamFactory = TestUtils.getPodamFactory(); + @BeforeEach void init() { installmentPIIRepository = new InstallmentPIIRepositoryImpl(mapperMock, personalDataServiceMock, installmentNoPIIRepository); @@ -59,4 +65,21 @@ void testInsert(){ Assertions.assertSame(p.getFirst(), installment.getNoPII()); } + + @Test + void givenValidOrganizationAndNavWhenGetByOrganizationIdAndNavThenOk() { + // Given + List installmentDTOList = podamFactory.manufacturePojo(List.class, InstallmentNoPII.class); + Mockito.when(installmentNoPIIRepository.getByOrganizationIdAndNav(1L, "NAV")).thenReturn(installmentDTOList); + installmentDTOList.forEach(installmentNoPII -> Mockito.when(mapperMock.map(installmentNoPII)).thenReturn(Installment.builder().build())); + + // When + List result = installmentPIIRepository.getByOrganizationIdAndNav(1L, "NAV"); + + // Then + Assertions.assertNotNull(result); + Assertions.assertEquals(installmentDTOList.size(), result.size()); + installmentDTOList.forEach(installmentNoPII -> Mockito.verify(mapperMock, Mockito.times(1)).map(installmentNoPII)); + } + } diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/service/InstallmentServiceImplTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/service/InstallmentServiceImplTest.java new file mode 100644 index 0000000..13fdf08 --- /dev/null +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/service/InstallmentServiceImplTest.java @@ -0,0 +1,55 @@ +package it.gov.pagopa.pu.debtpositions.service; + +import it.gov.pagopa.pu.debtpositions.dto.Installment; +import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentDTO; +import it.gov.pagopa.pu.debtpositions.mapper.InstallmentMapper; +import it.gov.pagopa.pu.debtpositions.repository.InstallmentPIIRepository; +import it.gov.pagopa.pu.debtpositions.util.TestUtils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import uk.co.jemos.podam.api.PodamFactory; + +import java.util.ArrayList; +import java.util.List; + +@ExtendWith(MockitoExtension.class) +class InstallmentServiceImplTest { + + @Mock + private InstallmentPIIRepository installmentPIIRepositoryMock; + @Mock + private InstallmentMapper installmentMapperMock; + + @InjectMocks + private InstallmentServiceImpl installmentService; + + private final PodamFactory podamFactory = TestUtils.getPodamFactory(); + + @Test + void givenValidOrganizationAndNavWhGetInstallmentsByOrganizationIdAndNavThenOk() { + //given + List installmentList = podamFactory.manufacturePojo(List.class, Installment.class); + List installmentDTOList = new ArrayList<>(); + + Mockito.when(installmentPIIRepositoryMock.getByOrganizationIdAndNav(1L, "NAV")).thenReturn(installmentList); + installmentList.forEach(installment -> { + InstallmentDTO installmentDTO = podamFactory.manufacturePojo(InstallmentDTO.class); + installmentDTOList.add(installmentDTO); + Mockito.when(installmentMapperMock.mapToDto(installment)).thenReturn(installmentDTO); + }); + + //when + List response = installmentService.getInstallmentsByOrganizationIdAndNav(1L, "NAV"); + + //verify + Assertions.assertNotNull(response); + Assertions.assertIterableEquals(installmentDTOList, response); + Mockito.verify(installmentPIIRepositoryMock, Mockito.times(1)).getByOrganizationIdAndNav(1L, "NAV"); + installmentList.forEach(installment -> Mockito.verify(installmentMapperMock, Mockito.times(1)).mapToDto(installment)); + } +} diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/util/TestUtils.java b/src/test/java/it/gov/pagopa/pu/debtpositions/util/TestUtils.java index 605cfad..e1f5b80 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/util/TestUtils.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/util/TestUtils.java @@ -3,6 +3,12 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.Assertions; +import uk.co.jemos.podam.api.AttributeMetadata; +import uk.co.jemos.podam.api.DataProviderStrategy; +import uk.co.jemos.podam.api.PodamFactory; +import uk.co.jemos.podam.api.PodamFactoryImpl; +import uk.co.jemos.podam.common.ManufacturingContext; +import uk.co.jemos.podam.typeManufacturers.AbstractTypeManufacturer; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -118,4 +124,15 @@ private static boolean hasStandardEquals(Class clazz) { } } + public static PodamFactory getPodamFactory() { + PodamFactoryImpl podamFactory = new PodamFactoryImpl(); + podamFactory.getStrategy().addOrReplaceTypeManufacturer(SortedSet.class, new AbstractTypeManufacturer<>(){ + @Override + public SortedSet getType(DataProviderStrategy strategy, AttributeMetadata attributeMetadata, ManufacturingContext manufacturingCtx) { + return new TreeSet<>(); + } + }); + return podamFactory; + } + } From a0b024676c1f1aff5fa8e1a49307b25a67885eb7 Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 11:07:39 +0100 Subject: [PATCH 02/13] P4ADEV-1779 fix test PersonalDataServiceTest --- .../debtpositions/citizen/service/PersonalDataServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataServiceTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataServiceTest.java index 2080597..5325f1f 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataServiceTest.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/citizen/service/PersonalDataServiceTest.java @@ -91,7 +91,7 @@ void givenValidPersonalDataIdWhenGetThenOk(){ @Test void givenNotFoundPersonalDataIdWhenGetThenException(){ //given - Mockito.when(repositoryMock.findById(1L)).thenReturn(null); + Mockito.when(repositoryMock.findById(1L)).thenReturn(Optional.empty()); //when NotFoundException notFoundException = Assertions.assertThrows(NotFoundException.class, () -> service.get(1L, InstallmentPIIDTO.class)); //then From f3ac11bdd8693649c390391181ebd479c700f8c8 Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 13:14:23 +0100 Subject: [PATCH 03/13] P4ADEV-1779 use exception handler to handle NotFoundException --- .../exception/DebtPositionExceptionHandler.java | 17 +++++++++++++++++ .../DebtPositionExceptionHandlerTest.java | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandler.java b/src/main/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandler.java index 9c05e87..661add5 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandler.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandler.java @@ -3,14 +3,17 @@ import it.gov.pagopa.pu.debtpositions.dto.generated.DebtPositionErrorDTO; import it.gov.pagopa.pu.debtpositions.exception.custom.ConflictErrorException; import it.gov.pagopa.pu.debtpositions.exception.custom.InvalidValueException; +import it.gov.pagopa.pu.debtpositions.exception.custom.NotFoundException; import it.gov.pagopa.pu.debtpositions.exception.custom.OperatorNotAuthorizedException; import jakarta.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; +import org.springdoc.api.ErrorMessage; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; @@ -34,6 +37,20 @@ public ResponseEntity handleConflictError(RuntimeException return handleWorkflowErrorException(ex, request, HttpStatus.CONFLICT, DebtPositionErrorDTO.CodeEnum.CONFLICT); } + @ExceptionHandler(NotFoundException.class) + @ResponseStatus(value = HttpStatus.NOT_FOUND) + public ErrorMessage resourceNotFoundException(NotFoundException ex, HttpServletRequest request) { + if (log.isInfoEnabled()) { + String logMessage = "A ResourceNotFoundException occurred handling request %s - HttpStatus %s - %s" + .formatted(getRequestDetails(request), HttpStatus.NOT_FOUND.value(), ex.getMessage()); + if (log.isDebugEnabled()) + log.debug(logMessage, ex); + else + log.info(logMessage); + } + return new ErrorMessage("resource not found: %s".formatted(ex.getMessage())); + } + static ResponseEntity handleWorkflowErrorException(RuntimeException ex, HttpServletRequest request, HttpStatus httpStatus, DebtPositionErrorDTO.CodeEnum errorEnum) { String message = logException(ex, request, httpStatus); diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandlerTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandlerTest.java index 810769d..d905ae7 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandlerTest.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandlerTest.java @@ -2,6 +2,7 @@ import it.gov.pagopa.pu.debtpositions.exception.custom.ConflictErrorException; import it.gov.pagopa.pu.debtpositions.exception.custom.InvalidValueException; +import it.gov.pagopa.pu.debtpositions.exception.custom.NotFoundException; import it.gov.pagopa.pu.debtpositions.exception.custom.OperatorNotAuthorizedException; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -87,4 +88,17 @@ void handleGenericErrorExceptionError() throws Exception { .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Error")); } + + @Test + void handleNotFoundException() throws Exception { + doThrow(new NotFoundException("NOT_FOUND_MESSAGE")).when(testControllerSpy).testEndpoint(DATA); + + mockMvc.perform(MockMvcRequestBuilders.get("/test") + .param(DATA, DATA) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(MockMvcResultMatchers.status().isNotFound()) + .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("resource not found: NOT_FOUND_MESSAGE")); + + } } From 23fee888c250bddbbd2d9e21cf87f508319ad294 Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 14:39:34 +0100 Subject: [PATCH 04/13] P4ADEV-1779 modify handling of NotFoundException on ExceptionHandler --- openapi/p4pa-debt-position.openapi.yaml | 1 + .../exception/DebtPositionExceptionHandler.java | 17 +++-------------- .../DebtPositionExceptionHandlerTest.java | 5 +++-- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/openapi/p4pa-debt-position.openapi.yaml b/openapi/p4pa-debt-position.openapi.yaml index ee1b80c..410868e 100644 --- a/openapi/p4pa-debt-position.openapi.yaml +++ b/openapi/p4pa-debt-position.openapi.yaml @@ -547,5 +547,6 @@ components: - DEBT_POSITION_CONFLICT - DEBT_POSITION_FORBIDDEN - DEBT_POSITION_GENERIC_ERROR + - DEBT_POSITION_NOT_FOUND message: type: string diff --git a/src/main/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandler.java b/src/main/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandler.java index 661add5..7bc37c7 100644 --- a/src/main/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandler.java +++ b/src/main/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandler.java @@ -7,13 +7,11 @@ import it.gov.pagopa.pu.debtpositions.exception.custom.OperatorNotAuthorizedException; import jakarta.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; -import org.springdoc.api.ErrorMessage; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; @@ -37,18 +35,9 @@ public ResponseEntity handleConflictError(RuntimeException return handleWorkflowErrorException(ex, request, HttpStatus.CONFLICT, DebtPositionErrorDTO.CodeEnum.CONFLICT); } - @ExceptionHandler(NotFoundException.class) - @ResponseStatus(value = HttpStatus.NOT_FOUND) - public ErrorMessage resourceNotFoundException(NotFoundException ex, HttpServletRequest request) { - if (log.isInfoEnabled()) { - String logMessage = "A ResourceNotFoundException occurred handling request %s - HttpStatus %s - %s" - .formatted(getRequestDetails(request), HttpStatus.NOT_FOUND.value(), ex.getMessage()); - if (log.isDebugEnabled()) - log.debug(logMessage, ex); - else - log.info(logMessage); - } - return new ErrorMessage("resource not found: %s".formatted(ex.getMessage())); + @ExceptionHandler({NotFoundException.class}) + public ResponseEntity handleNotFoundError(RuntimeException ex, HttpServletRequest request){ + return handleWorkflowErrorException(ex, request, HttpStatus.NOT_FOUND, DebtPositionErrorDTO.CodeEnum.NOT_FOUND); } static ResponseEntity handleWorkflowErrorException(RuntimeException ex, HttpServletRequest request, HttpStatus httpStatus, DebtPositionErrorDTO.CodeEnum errorEnum) { diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandlerTest.java b/src/test/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandlerTest.java index d905ae7..35eebee 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandlerTest.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/exception/DebtPositionExceptionHandlerTest.java @@ -91,14 +91,15 @@ void handleGenericErrorExceptionError() throws Exception { @Test void handleNotFoundException() throws Exception { - doThrow(new NotFoundException("NOT_FOUND_MESSAGE")).when(testControllerSpy).testEndpoint(DATA); + doThrow(new NotFoundException("Error")).when(testControllerSpy).testEndpoint(DATA); mockMvc.perform(MockMvcRequestBuilders.get("/test") .param(DATA, DATA) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(MockMvcResultMatchers.status().isNotFound()) - .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("resource not found: NOT_FOUND_MESSAGE")); + .andExpect(MockMvcResultMatchers.jsonPath("$.code").value("DEBT_POSITION_NOT_FOUND")) + .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Error")); } } From faaff19e2b04211e87c76b83cbf0521c3843aca9 Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 14:42:46 +0100 Subject: [PATCH 05/13] P4ADEV-1779 add NoPII filed on InstallmentPIIMapper.map() --- .../pagopa/pu/debtpositions/mapper/InstallmentPIIMapper.java | 1 + .../pu/debtpositions/mapper/InstallmentPIIMapperTest.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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 b963365..4f426e2 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 @@ -82,6 +82,7 @@ public Installment map(InstallmentNoPII installmentNoPII) { .updateOperatorExternalId(installmentNoPII.getUpdateOperatorExternalId()) .debtor(pii.getDebtor()) .transfers(List.copyOf(installmentNoPII.getTransfers())) + .noPII(installmentNoPII) .build(); } } 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 957ea41..deaf7d7 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 @@ -94,7 +94,7 @@ void testMapInstallmentNoPII(){ //when Installment result = mapper.map(installmentNoPII); //then - TestUtils.checkNotNullFields(result,"noPII"); + TestUtils.checkNotNullFields(result); Mockito.verify(personalDataServiceMock, Mockito.times(1)).get(installmentNoPII.getPersonalDataId(), InstallmentPIIDTO.class); } //endregion From a81624029683ce2d1922f7cd6d90d5efc8b951a1 Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 16:16:08 +0100 Subject: [PATCH 06/13] P4ADEV-1779 add test for InstallmentMapper.mapToDto() --- .../debtpositions/mapper/InstallmentMapperTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 2ed2f47..5ef654c 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 @@ -66,5 +66,17 @@ void givenMapToDtoThenOk(){ reflectionEqualsByName(installmentExpected, result, "debtor"); checkNotNullFields(result, "debtor"); } + + @Test + void givenMapInstallmentToDtoThenOk(){ + Installment installmentExpected = buildInstallment(); + + Mockito.when(transferMapperMock.mapToDto(buildTransfer())).thenReturn(buildTransferDTO()); + + InstallmentDTO result = installmentMapper.mapToDto(installmentExpected); + + reflectionEqualsByName(installmentExpected, result, "debtor"); //TODO P4ADEV-2028 + checkNotNullFields(result, "debtor"); //TODO P4ADEV-2028 + } } From e257ff02466a74e15e22d34c5657ac9ee770615a Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 16:31:37 +0100 Subject: [PATCH 07/13] P4ADEV-1779 improve TestUtils.reflectionEqualsByName (support collections, arrays, generic date/time) --- .../pu/debtpositions/util/TestUtils.java | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/test/java/it/gov/pagopa/pu/debtpositions/util/TestUtils.java b/src/test/java/it/gov/pagopa/pu/debtpositions/util/TestUtils.java index e1f5b80..0f283db 100644 --- a/src/test/java/it/gov/pagopa/pu/debtpositions/util/TestUtils.java +++ b/src/test/java/it/gov/pagopa/pu/debtpositions/util/TestUtils.java @@ -1,6 +1,7 @@ package it.gov.pagopa.pu.debtpositions.util; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.Assertions; import uk.co.jemos.podam.api.AttributeMetadata; @@ -10,11 +11,13 @@ import uk.co.jemos.podam.common.ManufacturingContext; import uk.co.jemos.podam.typeManufacturers.AbstractTypeManufacturer; -import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Array; import java.lang.reflect.Method; import java.math.BigInteger; import java.time.OffsetDateTime; import java.time.chrono.ChronoZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAccessor; import java.util.*; @Slf4j @@ -65,7 +68,7 @@ public static List reflectionEqualsByName(Object o1, Object o2, String.. if (v1 != null) { if (v1.equals(v2)) { //Do Nothing - } else if (v1 instanceof Comparable && v2 instanceof Comparable && ((Comparable) v1).compareTo(v2) == 0) { + } else if (v1 instanceof Comparable v1Comparable && v2 instanceof Comparable v2Comparable && compareEquals(v1Comparable, v2Comparable)) { //Do Nothing } else if (OffsetDateTime.class.isAssignableFrom(v1.getClass()) && OffsetDateTime.class.isAssignableFrom(v2.getClass())) { result = ((OffsetDateTime) v1).isEqual((OffsetDateTime) v2); @@ -87,6 +90,16 @@ public static List reflectionEqualsByName(Object o1, Object o2, String.. } else if (String.class.isAssignableFrom(v2.getClass()) && Enum.class.isAssignableFrom(v1.getClass())) { v1 = ReflectionUtils.enum2String((Enum) v1); result = v2.equals(v1); + } else if (v1 instanceof Collection collV1 && v2 instanceof Collection collV2 && collV1.size() == collV2.size()) { + Iterator it1 = collV1.iterator(); + Iterator it2 = collV2.iterator(); + while (it1.hasNext() && it2.hasNext()) { + checked.addAll(reflectionEqualsByName(it1.next(), it2.next())); + } + } else if (v1.getClass().isArray() && v2.getClass().isArray() && Array.getLength(v1) == Array.getLength(v2)) { + for (int i = 0; i < Array.getLength(v1); i++) { + checked.addAll(reflectionEqualsByName(Array.get(v1, i), Array.get(v2, i))); + } } else { boolean equals = v1.toString().equals(v2.toString()); if (Enum.class.isAssignableFrom(v2.getClass()) && Enum.class.isAssignableFrom(v1.getClass())) { @@ -94,7 +107,9 @@ public static List reflectionEqualsByName(Object o1, Object o2, String.. } else if (String.class.isAssignableFrom(v1.getClass()) || String.class.isAssignableFrom(v2.getClass())) { result = equals; } else { - checked.addAll(reflectionEqualsByName(v1, v2)); + List addedMethods = reflectionEqualsByName(v1, v2); + Assertions.assertFalse(addedMethods.isEmpty(), String.format("Invalid compare between methods%n%s = %s%n%s = %s", m1, v1, m2, v2)); + checked.addAll(addedMethods); } } @@ -104,9 +119,8 @@ public static List reflectionEqualsByName(Object o1, Object o2, String.. Assertions.assertTrue(result, String.format("Invalid compare between methods%n%s = %s%n%s = %s", m1, v1, m2, v2)); } catch (NoSuchMethodException e) { log.warn("Method {} is not defined in {}{}", m1, o2.getClass().getName(), e.getMessage()); - } catch (IllegalAccessException | - InvocationTargetException e) { - throw new IllegalStateException(String.format("[ERROR] Something gone wrong comparing %s with %s%n%s", m1, m2, e.getMessage())); + } catch (Exception e) { + throw new IllegalStateException(String.format("[ERROR] Something gone wrong comparing %s with %s%n%s", m1, m2, e.getMessage()), e); } } } @@ -114,6 +128,23 @@ public static List reflectionEqualsByName(Object o1, Object o2, String.. return checked; } + private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.nnnnnnnnn"); + private static boolean compareEquals(Comparable v1, T v2) { + try { + //specific equality tests for TemporalAccessor classes + if(v1 instanceof TemporalAccessor v1Time && v2 instanceof TemporalAccessor v2Time){ + //ignore timezone (for localDate/Time objects) + return StringUtils.equals(formatter.format(v1Time), formatter.format(v2Time)); + } else { + //generic fallback + return v1.compareTo(v2)==0; + } + } catch (ClassCastException cce) { + log.warn("cannot compare {} with {}", ClassUtils.getName(v1), ClassUtils.getName(v2)); + return false; + } + } + private static boolean hasStandardEquals(Class clazz) { try { return !clazz.getMethod("equals", Object.class).equals(Object.class.getMethod("equals", Object.class)); From 18d48f617731aaf0fc280110f19e841e6f4a4b79 Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 16:31:53 +0100 Subject: [PATCH 08/13] P4ADEV-1779 update generated.openapi.json --- openapi/generated.openapi.json | 536 ++++++++++++++++----------------- 1 file changed, 268 insertions(+), 268 deletions(-) diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index fdc7d5c..880267b 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -3612,7 +3612,7 @@ } } }, - "DebtPositionTypeOrgOperators" : { + "DebtPosition" : { "type" : "object", "properties" : { "creationDate" : { @@ -3626,7 +3626,29 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionTypeOrgOperatorId" : { + "debtPositionId" : { + "type" : "integer", + "format" : "int64" + }, + "iupdOrg" : { + "type" : "string" + }, + "description" : { + "type" : "string" + }, + "status" : { + "type" : "string", + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + }, + "ingestionFlowFileId" : { + "type" : "integer", + "format" : "int64" + }, + "ingestionFlowFileLineNumber" : { + "type" : "integer", + "format" : "int64" + }, + "organizationId" : { "type" : "integer", "format" : "int64" }, @@ -3634,8 +3656,16 @@ "type" : "integer", "format" : "int64" }, - "operatorExternalUserId" : { - "type" : "string" + "notificationDate" : { + "type" : "string", + "format" : "date-time" + }, + "validityDate" : { + "type" : "string", + "format" : "date-time" + }, + "flagIuvVolatile" : { + "type" : "boolean" }, "_links" : { "$ref" : "#/components/schemas/Links" @@ -3663,16 +3693,16 @@ } } }, - "PagedModelDebtPositionTypeOrgOperators" : { + "PagedModelDebtPosition" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypeOrgOperatorses" : { + "debtPositions" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionTypeOrgOperators" + "$ref" : "#/components/schemas/DebtPosition" } } } @@ -3699,56 +3729,7 @@ } } }, - "PaymentOption" : { - "type" : "object", - "properties" : { - "creationDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateOperatorExternalId" : { - "type" : "string" - }, - "paymentOptionId" : { - "type" : "integer", - "format" : "int64" - }, - "debtPositionId" : { - "type" : "integer", - "format" : "int64" - }, - "totalAmountCents" : { - "type" : "integer", - "format" : "int64" - }, - "status" : { - "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] - }, - "multiDebtor" : { - "type" : "boolean" - }, - "dueDate" : { - "type" : "string", - "format" : "date-time" - }, - "description" : { - "type" : "string" - }, - "paymentOptionType" : { - "type" : "string", - "enum" : [ "SINGLE_INSTALLMENT", "INSTALMENTS", "DOWN_PAYMENT" ] - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "PagedModelPaymentOption" : { + "CollectionModelPaymentOption" : { "type" : "object", "properties" : { "_embedded" : { @@ -3757,16 +3738,13 @@ "paymentOptions" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/PaymentOption" + "$ref" : "#/components/schemas/PaymentOptionResponse" } } } }, "_links" : { "$ref" : "#/components/schemas/Links" - }, - "page" : { - "$ref" : "#/components/schemas/PageMetadata" } } }, @@ -3789,25 +3767,6 @@ } } }, - "CollectionModelInstallmentNoPII" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "installmentNoPIIs" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/InstallmentNoPIIResponse" - } - } - } - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, "ReceiptNoPII" : { "type" : "object", "properties" : { @@ -3946,54 +3905,28 @@ } } }, - "Transfer" : { + "DebtPositionTypeWithCount" : { "type" : "object", "properties" : { - "creationDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateOperatorExternalId" : { - "type" : "string" - }, - "transferId" : { - "type" : "integer", - "format" : "int64" - }, - "installmentId" : { - "type" : "integer", - "format" : "int64" - }, - "orgFiscalCode" : { - "type" : "string" - }, - "orgName" : { - "type" : "string" - }, - "amountCents" : { + "debtPositionTypeId" : { "type" : "integer", "format" : "int64" }, - "remittanceInformation" : { + "code" : { "type" : "string" }, - "stamp" : { - "$ref" : "#/components/schemas/Stamp" - }, - "iban" : { + "description" : { "type" : "string" }, - "postalIban" : { - "type" : "string" + "updateDate" : { + "type" : "string", + "format" : "date-time" }, - "category" : { - "type" : "string" + "activeOrganizations" : { + "type" : "integer", + "format" : "int32" }, - "transferIndex" : { + "brokerId" : { "type" : "integer", "format" : "int64" }, @@ -4002,16 +3935,16 @@ } } }, - "PagedModelTransfer" : { + "PagedModelDebtPositionTypeWithCount" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "transfers" : { + "debtPositionTypeWithCounts" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/Transfer" + "$ref" : "#/components/schemas/DebtPositionTypeWithCount" } } } @@ -4024,7 +3957,7 @@ } } }, - "DebtPosition" : { + "PaymentOption" : { "type" : "object", "properties" : { "creationDate" : { @@ -4038,62 +3971,51 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionId" : { + "paymentOptionId" : { "type" : "integer", "format" : "int64" }, - "iupdOrg" : { - "type" : "string" - }, - "description" : { - "type" : "string" - }, - "status" : { - "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] - }, - "ingestionFlowFileId" : { + "debtPositionId" : { "type" : "integer", "format" : "int64" }, - "ingestionFlowFileLineNumber" : { + "totalAmountCents" : { "type" : "integer", "format" : "int64" }, - "organizationId" : { - "type" : "integer", - "format" : "int64" + "status" : { + "type" : "string", + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] }, - "debtPositionTypeOrgId" : { - "type" : "integer", - "format" : "int64" + "multiDebtor" : { + "type" : "boolean" }, - "notificationDate" : { + "dueDate" : { "type" : "string", "format" : "date-time" }, - "validityDate" : { - "type" : "string", - "format" : "date-time" + "description" : { + "type" : "string" }, - "flagIuvVolatile" : { - "type" : "boolean" + "paymentOptionType" : { + "type" : "string", + "enum" : [ "SINGLE_INSTALLMENT", "INSTALMENTS", "DOWN_PAYMENT" ] }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPosition" : { + "PagedModelPaymentOption" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositions" : { + "paymentOptions" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPosition" + "$ref" : "#/components/schemas/PaymentOption" } } } @@ -4106,16 +4028,16 @@ } } }, - "CollectionModelPaymentOption" : { + "CollectionModelInstallmentNoPII" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "paymentOptions" : { + "installmentNoPIIs" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/PaymentOptionResponse" + "$ref" : "#/components/schemas/InstallmentNoPIIResponse" } } } @@ -4125,7 +4047,7 @@ } } }, - "DebtPositionTypeOrg" : { + "InstallmentNoPII" : { "type" : "object", "properties" : { "creationDate" : { @@ -4139,102 +4061,89 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionTypeOrgId" : { + "installmentId" : { "type" : "integer", "format" : "int64" }, - "debtPositionTypeId" : { + "paymentOptionId" : { "type" : "integer", "format" : "int64" }, - "organizationId" : { - "type" : "integer", - "format" : "int64" + "status" : { + "type" : "string", + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] }, - "balance" : { + "iupdPagopa" : { "type" : "string" }, - "code" : { + "iud" : { "type" : "string" }, - "description" : { + "iuv" : { "type" : "string" }, - "iban" : { + "iur" : { "type" : "string" }, - "postalIban" : { + "iuf" : { "type" : "string" }, - "postalAccountCode" : { + "nav" : { "type" : "string" }, - "holderPostalCc" : { - "type" : "string" - }, - "orgSector" : { - "type" : "string" - }, - "xsdDefinitionRef" : { + "dueDate" : { + "type" : "string", + "format" : "date-time" + }, + "paymentTypeCode" : { "type" : "string" }, "amountCents" : { "type" : "integer", "format" : "int64" }, - "externalPaymentUrl" : { - "type" : "string" - }, - "flagAnonymousFiscalCode" : { - "type" : "boolean" - }, - "flagMandatoryDueDate" : { - "type" : "boolean" - }, - "flagSpontaneous" : { - "type" : "boolean" + "notificationFeeCents" : { + "type" : "integer", + "format" : "int64" }, - "flagNotifyIo" : { - "type" : "boolean" + "remittanceInformation" : { + "type" : "string" }, - "ioTemplateMessage" : { + "humanFriendlyRemittanceInformation" : { "type" : "string" }, - "flagActive" : { - "type" : "boolean" + "balance" : { + "type" : "string" }, - "flagNotifyOutcomePush" : { - "type" : "boolean" + "legacyPaymentMetadata" : { + "type" : "string" }, - "notifyOutcomePushOrgSilServiceId" : { + "personalDataId" : { "type" : "integer", "format" : "int64" }, - "flagAmountActualization" : { - "type" : "boolean" - }, - "amountActualizationOrgSilServiceId" : { - "type" : "integer", - "format" : "int64" + "debtorEntityType" : { + "type" : "string" }, - "flagExternal" : { - "type" : "boolean" + "debtorFiscalCodeHash" : { + "type" : "string", + "format" : "byte" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPositionTypeOrg" : { + "PagedModelInstallmentNoPII" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypeOrgs" : { + "installmentNoPIIs" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionTypeOrg" + "$ref" : "#/components/schemas/InstallmentNoPII" } } } @@ -4247,7 +4156,26 @@ } } }, - "InstallmentNoPII" : { + "CollectionModelTransfer" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "transfers" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/TransferResponse" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "DebtPositionTypeOrgOperators" : { "type" : "object", "properties" : { "creationDate" : { @@ -4261,89 +4189,110 @@ "updateOperatorExternalId" : { "type" : "string" }, - "installmentId" : { + "debtPositionTypeOrgOperatorId" : { "type" : "integer", "format" : "int64" }, - "paymentOptionId" : { + "debtPositionTypeOrgId" : { "type" : "integer", "format" : "int64" }, - "status" : { - "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] - }, - "iupdPagopa" : { - "type" : "string" - }, - "iud" : { - "type" : "string" - }, - "iuv" : { + "operatorExternalUserId" : { "type" : "string" }, - "iur" : { - "type" : "string" + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "PagedModelDebtPositionTypeOrgOperators" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "debtPositionTypeOrgOperatorses" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/DebtPositionTypeOrgOperators" + } + } + } }, - "iuf" : { - "type" : "string" + "_links" : { + "$ref" : "#/components/schemas/Links" }, - "nav" : { - "type" : "string" + "page" : { + "$ref" : "#/components/schemas/PageMetadata" + } + } + }, + "Transfer" : { + "type" : "object", + "properties" : { + "creationDate" : { + "type" : "string", + "format" : "date-time" }, - "dueDate" : { + "updateDate" : { "type" : "string", "format" : "date-time" }, - "paymentTypeCode" : { + "updateOperatorExternalId" : { "type" : "string" }, - "amountCents" : { + "transferId" : { "type" : "integer", "format" : "int64" }, - "notificationFeeCents" : { + "installmentId" : { "type" : "integer", "format" : "int64" }, - "remittanceInformation" : { + "orgFiscalCode" : { "type" : "string" }, - "humanFriendlyRemittanceInformation" : { + "orgName" : { "type" : "string" }, - "balance" : { + "amountCents" : { + "type" : "integer", + "format" : "int64" + }, + "remittanceInformation" : { "type" : "string" }, - "legacyPaymentMetadata" : { + "stamp" : { + "$ref" : "#/components/schemas/Stamp" + }, + "iban" : { "type" : "string" }, - "personalDataId" : { - "type" : "integer", - "format" : "int64" + "postalIban" : { + "type" : "string" }, - "debtorEntityType" : { + "category" : { "type" : "string" }, - "debtorFiscalCodeHash" : { - "type" : "string", - "format" : "byte" + "transferIndex" : { + "type" : "integer", + "format" : "int64" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelInstallmentNoPII" : { + "PagedModelTransfer" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "installmentNoPIIs" : { + "transfers" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/InstallmentNoPII" + "$ref" : "#/components/schemas/Transfer" } } } @@ -4356,65 +4305,116 @@ } } }, - "CollectionModelTransfer" : { + "DebtPositionTypeOrg" : { "type" : "object", "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "transfers" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/TransferResponse" - } - } - } + "creationDate" : { + "type" : "string", + "format" : "date-time" + }, + "updateDate" : { + "type" : "string", + "format" : "date-time" + }, + "updateOperatorExternalId" : { + "type" : "string" + }, + "debtPositionTypeOrgId" : { + "type" : "integer", + "format" : "int64" }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "DebtPositionTypeWithCount" : { - "type" : "object", - "properties" : { "debtPositionTypeId" : { "type" : "integer", "format" : "int64" }, + "organizationId" : { + "type" : "integer", + "format" : "int64" + }, + "balance" : { + "type" : "string" + }, "code" : { "type" : "string" }, "description" : { "type" : "string" }, - "updateDate" : { - "type" : "string", - "format" : "date-time" + "iban" : { + "type" : "string" }, - "activeOrganizations" : { + "postalIban" : { + "type" : "string" + }, + "postalAccountCode" : { + "type" : "string" + }, + "holderPostalCc" : { + "type" : "string" + }, + "orgSector" : { + "type" : "string" + }, + "xsdDefinitionRef" : { + "type" : "string" + }, + "amountCents" : { "type" : "integer", - "format" : "int32" + "format" : "int64" }, - "brokerId" : { + "externalPaymentUrl" : { + "type" : "string" + }, + "flagAnonymousFiscalCode" : { + "type" : "boolean" + }, + "flagMandatoryDueDate" : { + "type" : "boolean" + }, + "flagSpontaneous" : { + "type" : "boolean" + }, + "flagNotifyIo" : { + "type" : "boolean" + }, + "ioTemplateMessage" : { + "type" : "string" + }, + "flagActive" : { + "type" : "boolean" + }, + "flagNotifyOutcomePush" : { + "type" : "boolean" + }, + "notifyOutcomePushOrgSilServiceId" : { "type" : "integer", "format" : "int64" }, + "flagAmountActualization" : { + "type" : "boolean" + }, + "amountActualizationOrgSilServiceId" : { + "type" : "integer", + "format" : "int64" + }, + "flagExternal" : { + "type" : "boolean" + }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPositionTypeWithCount" : { + "PagedModelDebtPositionTypeOrg" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypeWithCounts" : { + "debtPositionTypeOrgs" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionTypeWithCount" + "$ref" : "#/components/schemas/DebtPositionTypeOrg" } } } @@ -5545,7 +5545,7 @@ "properties" : { "code" : { "type" : "string", - "enum" : [ "DEBT_POSITION_BAD_REQUEST", "DEBT_POSITION_CONFLICT", "DEBT_POSITION_FORBIDDEN", "DEBT_POSITION_GENERIC_ERROR" ] + "enum" : [ "DEBT_POSITION_BAD_REQUEST", "DEBT_POSITION_CONFLICT", "DEBT_POSITION_FORBIDDEN", "DEBT_POSITION_GENERIC_ERROR", "DEBT_POSITION_NOT_FOUND" ] }, "message" : { "type" : "string" From 78d6ed87642b88ac3c34235b429b7a8f8a5cc33f Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 16:43:26 +0100 Subject: [PATCH 09/13] P4ADEV-1779 use faker to generate mock installment data --- .../pu/debtpositions/mapper/InstallmentPIIMapper.java | 3 ++- .../pu/debtpositions/mapper/InstallmentPIIMapperTest.java | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) 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 4f426e2..2d3a903 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 @@ -9,6 +9,7 @@ import org.springframework.stereotype.Service; import java.util.List; +import java.util.Optional; @Service public class InstallmentPIIMapper { @@ -81,7 +82,7 @@ public Installment map(InstallmentNoPII installmentNoPII) { .updateDate(installmentNoPII.getUpdateDate()) .updateOperatorExternalId(installmentNoPII.getUpdateOperatorExternalId()) .debtor(pii.getDebtor()) - .transfers(List.copyOf(installmentNoPII.getTransfers())) + .transfers(Optional.ofNullable(installmentNoPII.getTransfers()).map(List::copyOf).orElse(List.of())) .noPII(installmentNoPII) .build(); } 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 deaf7d7..45db351 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 @@ -32,8 +32,6 @@ class InstallmentPIIMapperTest { @Mock private PersonalDataService personalDataServiceMock; - private final PodamFactory podamFactory = TestUtils.getPodamFactory(); - @BeforeEach void init(){ mapper = new InstallmentPIIMapper(dataCipherServiceMock,personalDataServiceMock); @@ -87,8 +85,8 @@ void testMapWithNoPIINotNull(){ @Test void testMapInstallmentNoPII(){ //given - InstallmentNoPII installmentNoPII = podamFactory.manufacturePojo(InstallmentNoPII.class); - InstallmentPIIDTO installmentPIIDTO = podamFactory.manufacturePojo(InstallmentPIIDTO.class); + InstallmentNoPII installmentNoPII = buildInstallmentNoPII(); + InstallmentPIIDTO installmentPIIDTO = buildInstallmentPIIDTO(); Mockito.when(personalDataServiceMock.get(installmentNoPII.getPersonalDataId(), InstallmentPIIDTO.class)).thenReturn(installmentPIIDTO); //when From ded8bbdbe5395ea84165bf618761590cd83c2b59 Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 16:43:41 +0100 Subject: [PATCH 10/13] P4ADEV-1779 remove podam dependency --- build.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6fe0443..db687b1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,7 +42,6 @@ val micrometerVersion = "1.4.1" val postgresJdbcVersion = "42.7.4" val bouncycastleVersion = "1.79" val mapStructVersion = "1.6.3" -val podamVersion = "8.0.2.RELEASE" dependencies { implementation("org.springframework.boot:spring-boot-starter") @@ -83,7 +82,6 @@ dependencies { testImplementation ("org.projectlombok:lombok") testAnnotationProcessor("org.projectlombok:lombok") testImplementation("com.h2database:h2") - testImplementation("uk.co.jemos.podam:podam:$podamVersion") } tasks.withType { From 9e74e5d0e7d21c74d3ca35196f1f4c16bc27ef1e Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 17:19:00 +0100 Subject: [PATCH 11/13] P4ADEV-1779 update generated.openapi.json --- openapi/generated.openapi.json | 667 ++++++++++++++++++--------------- 1 file changed, 369 insertions(+), 298 deletions(-) diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index 8c95bcc..9c3feb5 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -15,6 +15,9 @@ "tags" : [ { "name" : "debt-position", "description" : "the debt-position API" + }, { + "name" : "installment", + "description" : "the installment API" }, { "name" : "receipt", "description" : "the receipt API" @@ -3457,6 +3460,74 @@ "BearerAuth" : [ ] } ] } + }, + "/installments/{organizationId}/{nav}" : { + "get" : { + "tags" : [ "installment" ], + "operationId" : "getInstallmentsByOrganizationIdAndNav", + "parameters" : [ { + "name" : "organizationId", + "in" : "path", + "description" : "The ID of the organization", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int64" + } + }, { + "name" : "nav", + "in" : "path", + "description" : "The nav of the installments", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "Ok", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InstallmentDTO" + } + } + } + } + }, + "400" : { + "description" : "Invalid request", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InstallmentDTO" + } + } + } + } + }, + "500" : { + "description" : "Internal server error", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InstallmentDTO" + } + } + } + } + } + }, + "security" : [ { + "BearerAuth" : [ ] + } ] + } } }, "components" : { @@ -3700,7 +3771,7 @@ } } }, - "DebtPositionType" : { + "Transfer" : { "type" : "object", "properties" : { "creationDate" : { @@ -3714,62 +3785,58 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionTypeId" : { + "transferId" : { "type" : "integer", "format" : "int64" }, - "brokerId" : { + "installmentId" : { "type" : "integer", "format" : "int64" }, - "code" : { + "orgFiscalCode" : { "type" : "string" }, - "description" : { + "orgName" : { "type" : "string" }, - "orgType" : { - "type" : "string" + "amountCents" : { + "type" : "integer", + "format" : "int64" }, - "macroArea" : { + "remittanceInformation" : { "type" : "string" }, - "serviceType" : { - "type" : "string" + "stamp" : { + "$ref" : "#/components/schemas/Stamp" }, - "collectingReason" : { + "iban" : { "type" : "string" }, - "taxonomyCode" : { + "postalIban" : { "type" : "string" }, - "flagAnonymousFiscalCode" : { - "type" : "boolean" - }, - "flagMandatoryDueDate" : { - "type" : "boolean" - }, - "flagNotifyIo" : { - "type" : "boolean" - }, - "ioTemplateMessage" : { + "category" : { "type" : "string" }, + "transferIndex" : { + "type" : "integer", + "format" : "int64" + }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPositionType" : { + "PagedModelTransfer" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypes" : { + "transfers" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionType" + "$ref" : "#/components/schemas/Transfer" } } } @@ -3782,6 +3849,20 @@ } } }, + "Stamp" : { + "type" : "object", + "properties" : { + "stampType" : { + "type" : "string" + }, + "stampHashDocument" : { + "type" : "string" + }, + "stampProvincialResidence" : { + "type" : "string" + } + } + }, "DebtPositionTypeOrgOperators" : { "type" : "object", "properties" : { @@ -3834,7 +3915,7 @@ } } }, - "DebtPositionTypeOrg" : { + "DebtPositionType" : { "type" : "object", "properties" : { "creationDate" : { @@ -3848,50 +3929,33 @@ "updateOperatorExternalId" : { "type" : "string" }, - "debtPositionTypeOrgId" : { - "type" : "integer", - "format" : "int64" - }, "debtPositionTypeId" : { "type" : "integer", "format" : "int64" }, - "organizationId" : { + "brokerId" : { "type" : "integer", "format" : "int64" }, - "balance" : { - "type" : "string" - }, "code" : { "type" : "string" }, "description" : { "type" : "string" }, - "iban" : { - "type" : "string" - }, - "postalIban" : { - "type" : "string" - }, - "postalAccountCode" : { + "orgType" : { "type" : "string" }, - "holderPostalCc" : { + "macroArea" : { "type" : "string" }, - "orgSector" : { + "serviceType" : { "type" : "string" }, - "xsdDefinitionRef" : { + "collectingReason" : { "type" : "string" }, - "amountCents" : { - "type" : "integer", - "format" : "int64" - }, - "externalPaymentUrl" : { + "taxonomyCode" : { "type" : "string" }, "flagAnonymousFiscalCode" : { @@ -3900,50 +3964,27 @@ "flagMandatoryDueDate" : { "type" : "boolean" }, - "flagSpontaneous" : { - "type" : "boolean" - }, "flagNotifyIo" : { "type" : "boolean" }, "ioTemplateMessage" : { "type" : "string" }, - "flagActive" : { - "type" : "boolean" - }, - "flagNotifyOutcomePush" : { - "type" : "boolean" - }, - "notifyOutcomePushOrgSilServiceId" : { - "type" : "integer", - "format" : "int64" - }, - "flagAmountActualization" : { - "type" : "boolean" - }, - "amountActualizationOrgSilServiceId" : { - "type" : "integer", - "format" : "int64" - }, - "flagExternal" : { - "type" : "boolean" - }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPositionTypeOrg" : { + "PagedModelDebtPositionType" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypeOrgs" : { + "debtPositionTypes" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionTypeOrg" + "$ref" : "#/components/schemas/DebtPositionType" } } } @@ -3956,21 +3997,7 @@ } } }, - "Stamp" : { - "type" : "object", - "properties" : { - "stampType" : { - "type" : "string" - }, - "stampHashDocument" : { - "type" : "string" - }, - "stampProvincialResidence" : { - "type" : "string" - } - } - }, - "Transfer" : { + "PaymentOption" : { "type" : "object", "properties" : { "creationDate" : { @@ -3984,58 +4011,51 @@ "updateOperatorExternalId" : { "type" : "string" }, - "transferId" : { + "paymentOptionId" : { "type" : "integer", "format" : "int64" }, - "installmentId" : { + "debtPositionId" : { "type" : "integer", "format" : "int64" }, - "orgFiscalCode" : { - "type" : "string" - }, - "orgName" : { - "type" : "string" - }, - "amountCents" : { + "totalAmountCents" : { "type" : "integer", "format" : "int64" }, - "remittanceInformation" : { - "type" : "string" - }, - "stamp" : { - "$ref" : "#/components/schemas/Stamp" + "status" : { + "type" : "string", + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] }, - "iban" : { - "type" : "string" + "multiDebtor" : { + "type" : "boolean" }, - "postalIban" : { - "type" : "string" + "dueDate" : { + "type" : "string", + "format" : "date-time" }, - "category" : { + "description" : { "type" : "string" }, - "transferIndex" : { - "type" : "integer", - "format" : "int64" + "paymentOptionType" : { + "type" : "string", + "enum" : [ "SINGLE_INSTALLMENT", "INSTALMENTS", "DOWN_PAYMENT" ] }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelTransfer" : { + "PagedModelPaymentOption" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "transfers" : { + "paymentOptions" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/Transfer" + "$ref" : "#/components/schemas/PaymentOption" } } } @@ -4048,109 +4068,154 @@ } } }, - "InstallmentNoPII" : { + "CollectionModelInstallmentNoPII" : { "type" : "object", "properties" : { - "creationDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateOperatorExternalId" : { - "type" : "string" + "_embedded" : { + "type" : "object", + "properties" : { + "installmentNoPIIs" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InstallmentNoPIIResponse" + } + } + } }, - "installmentId" : { - "type" : "integer", - "format" : "int64" + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "CollectionModelObject" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "objects" : { + "type" : "array", + "items" : { + "type" : "object" + } + } + } }, - "paymentOptionId" : { + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "DebtPositionTypeOrg" : { + "type" : "object", + "properties" : { + "creationDate" : { + "type" : "string", + "format" : "date-time" + }, + "updateDate" : { + "type" : "string", + "format" : "date-time" + }, + "updateOperatorExternalId" : { + "type" : "string" + }, + "debtPositionTypeOrgId" : { "type" : "integer", "format" : "int64" }, - "status" : { - "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] + "debtPositionTypeId" : { + "type" : "integer", + "format" : "int64" }, - "iupdPagopa" : { + "organizationId" : { + "type" : "integer", + "format" : "int64" + }, + "balance" : { "type" : "string" }, - "iud" : { + "code" : { "type" : "string" }, - "iuv" : { + "description" : { "type" : "string" }, - "iur" : { + "iban" : { "type" : "string" }, - "iuf" : { + "postalIban" : { "type" : "string" }, - "nav" : { + "postalAccountCode" : { "type" : "string" }, - "dueDate" : { - "type" : "string", - "format" : "date-time" + "holderPostalCc" : { + "type" : "string" }, - "paymentTypeCode" : { + "orgSector" : { "type" : "string" }, - "amountCents" : { - "type" : "integer", - "format" : "int64" + "xsdDefinitionRef" : { + "type" : "string" }, - "notificationFeeCents" : { + "amountCents" : { "type" : "integer", "format" : "int64" }, - "remittanceInformation" : { + "externalPaymentUrl" : { "type" : "string" }, - "humanFriendlyRemittanceInformation" : { - "type" : "string" + "flagAnonymousFiscalCode" : { + "type" : "boolean" }, - "balance" : { - "type" : "string" + "flagMandatoryDueDate" : { + "type" : "boolean" }, - "legacyPaymentMetadata" : { + "flagSpontaneous" : { + "type" : "boolean" + }, + "flagNotifyIo" : { + "type" : "boolean" + }, + "ioTemplateMessage" : { "type" : "string" }, - "personalDataId" : { + "flagActive" : { + "type" : "boolean" + }, + "flagNotifyOutcomePush" : { + "type" : "boolean" + }, + "notifyOutcomePushOrgSilServiceId" : { "type" : "integer", "format" : "int64" }, - "debtorEntityType" : { - "type" : "string" - }, - "debtorFiscalCodeHash" : { - "type" : "string", - "format" : "byte" + "flagAmountActualization" : { + "type" : "boolean" }, - "syncStatusFrom" : { - "type" : "string" + "amountActualizationOrgSilServiceId" : { + "type" : "integer", + "format" : "int64" }, - "syncStatusTo" : { - "type" : "string" + "flagExternal" : { + "type" : "boolean" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelInstallmentNoPII" : { + "PagedModelDebtPositionTypeOrg" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "installmentNoPIIs" : { + "debtPositionTypeOrgs" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/InstallmentNoPII" + "$ref" : "#/components/schemas/DebtPositionTypeOrg" } } } @@ -4163,84 +4228,80 @@ } } }, - "CollectionModelTransfer" : { + "DebtPosition" : { "type" : "object", "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "transfers" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/TransferResponse" - } - } - } + "creationDate" : { + "type" : "string", + "format" : "date-time" }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "CollectionModelObject" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "objects" : { - "type" : "array", - "items" : { - "type" : "object" - } - } - } + "updateDate" : { + "type" : "string", + "format" : "date-time" }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "DebtPositionTypeWithCount" : { - "type" : "object", - "properties" : { - "debtPositionTypeId" : { + "updateOperatorExternalId" : { + "type" : "string" + }, + "debtPositionId" : { "type" : "integer", "format" : "int64" }, - "code" : { + "iupdOrg" : { "type" : "string" }, "description" : { "type" : "string" }, - "updateDate" : { + "status" : { "type" : "string", - "format" : "date-time" + "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] }, - "activeOrganizations" : { + "debtPositionOrigin" : { + "type" : "string", + "enum" : [ "ORDINARY", "SPONTANEOUS", "SECONDARY_ORG", "RECEIPT_FILE", "RECEIPT_PAGOPA", "REPORTING_PAGOPA" ] + }, + "ingestionFlowFileId" : { "type" : "integer", - "format" : "int32" + "format" : "int64" }, - "brokerId" : { + "ingestionFlowFileLineNumber" : { + "type" : "integer", + "format" : "int64" + }, + "organizationId" : { + "type" : "integer", + "format" : "int64" + }, + "debtPositionTypeOrgId" : { "type" : "integer", "format" : "int64" }, + "notificationDate" : { + "type" : "string", + "format" : "date-time" + }, + "validityDate" : { + "type" : "string", + "format" : "date-time" + }, + "flagIuvVolatile" : { + "type" : "boolean" + }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPositionTypeWithCount" : { + "PagedModelDebtPosition" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositionTypeWithCounts" : { + "debtPositions" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPositionTypeWithCount" + "$ref" : "#/components/schemas/DebtPosition" } } } @@ -4253,7 +4314,26 @@ } } }, - "PaymentOption" : { + "CollectionModelPaymentOption" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "paymentOptions" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/PaymentOptionResponse" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "InstallmentNoPII" : { "type" : "object", "properties" : { "creationDate" : { @@ -4267,51 +4347,95 @@ "updateOperatorExternalId" : { "type" : "string" }, - "paymentOptionId" : { - "type" : "integer", - "format" : "int64" - }, - "debtPositionId" : { + "installmentId" : { "type" : "integer", "format" : "int64" }, - "totalAmountCents" : { + "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", "INSTALMENTS", "DOWN_PAYMENT" ] + "format" : "byte" + }, + "syncStatusFrom" : { + "type" : "string" + }, + "syncStatusTo" : { + "type" : "string" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelPaymentOption" : { + "PagedModelInstallmentNoPII" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "paymentOptions" : { + "installmentNoPIIs" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/PaymentOption" + "$ref" : "#/components/schemas/InstallmentNoPII" } } } @@ -4324,16 +4448,16 @@ } } }, - "CollectionModelInstallmentNoPII" : { + "CollectionModelTransfer" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "installmentNoPIIs" : { + "transfers" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/InstallmentNoPIIResponse" + "$ref" : "#/components/schemas/TransferResponse" } } } @@ -4343,80 +4467,46 @@ } } }, - "DebtPosition" : { + "DebtPositionTypeWithCount" : { "type" : "object", "properties" : { - "creationDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateDate" : { - "type" : "string", - "format" : "date-time" - }, - "updateOperatorExternalId" : { - "type" : "string" - }, - "debtPositionId" : { + "debtPositionTypeId" : { "type" : "integer", "format" : "int64" }, - "iupdOrg" : { + "code" : { "type" : "string" }, "description" : { "type" : "string" }, - "status" : { - "type" : "string", - "enum" : [ "TO_SYNC", "REPORTED", "PAID", "PARTIALLY_PAID", "CANCELLED", "INVALID", "EXPIRED", "UNPAID", "DRAFT" ] - }, - "debtPositionOrigin" : { + "updateDate" : { "type" : "string", - "enum" : [ "ORDINARY", "SPONTANEOUS", "SECONDARY_ORG", "RECEIPT_FILE", "RECEIPT_PAGOPA", "REPORTING_PAGOPA" ] - }, - "ingestionFlowFileId" : { - "type" : "integer", - "format" : "int64" - }, - "ingestionFlowFileLineNumber" : { - "type" : "integer", - "format" : "int64" + "format" : "date-time" }, - "organizationId" : { + "activeOrganizations" : { "type" : "integer", - "format" : "int64" + "format" : "int32" }, - "debtPositionTypeOrgId" : { + "brokerId" : { "type" : "integer", "format" : "int64" }, - "notificationDate" : { - "type" : "string", - "format" : "date-time" - }, - "validityDate" : { - "type" : "string", - "format" : "date-time" - }, - "flagIuvVolatile" : { - "type" : "boolean" - }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelDebtPosition" : { + "PagedModelDebtPositionTypeWithCount" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "debtPositions" : { + "debtPositionTypeWithCounts" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/DebtPosition" + "$ref" : "#/components/schemas/DebtPositionTypeWithCount" } } } @@ -4429,25 +4519,6 @@ } } }, - "CollectionModelPaymentOption" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "paymentOptions" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/PaymentOptionResponse" - } - } - } - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, "DebtPositionTypeOrgOperatorsRequestBody" : { "type" : "object", "properties" : { @@ -5519,7 +5590,7 @@ "properties" : { "code" : { "type" : "string", - "enum" : [ "DEBT_POSITION_BAD_REQUEST", "DEBT_POSITION_CONFLICT", "DEBT_POSITION_FORBIDDEN", "DEBT_POSITION_GENERIC_ERROR" ] + "enum" : [ "DEBT_POSITION_BAD_REQUEST", "DEBT_POSITION_CONFLICT", "DEBT_POSITION_FORBIDDEN", "DEBT_POSITION_GENERIC_ERROR", "DEBT_POSITION_NOT_FOUND" ] }, "message" : { "type" : "string" From f07bbe23670da48bdbcd29b435fc117263810359 Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 17:39:21 +0100 Subject: [PATCH 12/13] P4ADEV-1779 update installment mappers for syncStatus field --- .../pagopa/pu/debtpositions/mapper/InstallmentMapper.java | 1 + .../pagopa/pu/debtpositions/mapper/InstallmentPIIMapper.java | 5 +++++ 2 files changed, 6 insertions(+) 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 7a77eef..250feb3 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 @@ -82,6 +82,7 @@ public InstallmentDTO mapToDto(Installment installment){ .installmentId(installment.getInstallmentId()) .paymentOptionId(installment.getPaymentOptionId()) .status(installment.getStatus()) + .syncStatus(installment.getSyncStatus()) .iupdPagopa(installment.getIupdPagopa()) .iud(installment.getIud()) .iuv(installment.getIuv()) 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 8ed3917..96f2974 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 @@ -4,6 +4,7 @@ import it.gov.pagopa.pu.debtpositions.citizen.service.PersonalDataService; import it.gov.pagopa.pu.debtpositions.dto.Installment; import it.gov.pagopa.pu.debtpositions.dto.InstallmentPIIDTO; +import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentSyncStatus; import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; import org.springframework.data.util.Pair; import org.springframework.stereotype.Service; @@ -65,6 +66,10 @@ public Installment map(InstallmentNoPII installmentNoPII) { .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()) From 90c32f73a7fa3dee1d49ede7ad1546116f156c9a Mon Sep 17 00:00:00 2001 From: serdimic Date: Mon, 27 Jan 2025 17:39:44 +0100 Subject: [PATCH 13/13] P4ADEV-1779 rollback remove podam dependency (still used in some context) --- build.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index db687b1..6fe0443 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,6 +42,7 @@ val micrometerVersion = "1.4.1" val postgresJdbcVersion = "42.7.4" val bouncycastleVersion = "1.79" val mapStructVersion = "1.6.3" +val podamVersion = "8.0.2.RELEASE" dependencies { implementation("org.springframework.boot:spring-boot-starter") @@ -82,6 +83,7 @@ dependencies { testImplementation ("org.projectlombok:lombok") testAnnotationProcessor("org.projectlombok:lombok") testImplementation("com.h2database:h2") + testImplementation("uk.co.jemos.podam:podam:$podamVersion") } tasks.withType {