From 2acf1885adf561a39a1e838a9cc218d272b336d6 Mon Sep 17 00:00:00 2001 From: empassaro <113031808+empassaro@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:56:23 +0200 Subject: [PATCH] SELC-4720 feature: added originId mapping using ivassCode (#294) --- .../model/onboarding/OnboardingData.java | 1 + .../openapi/api-selfcare-onboarding-docs.json | 22 ++++++++++++++----- .../rest/mapper/OnboardingMapper.java | 11 +++++++--- .../OnboardingMsConnectorImplTest.java | 1 + .../mapper/OnboardingResourceMapper.java | 1 + 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/connector-api/src/main/java/it/pagopa/selfcare/onboarding/connector/model/onboarding/OnboardingData.java b/connector-api/src/main/java/it/pagopa/selfcare/onboarding/connector/model/onboarding/OnboardingData.java index d250cb8d..b52a31a8 100644 --- a/connector-api/src/main/java/it/pagopa/selfcare/onboarding/connector/model/onboarding/OnboardingData.java +++ b/connector-api/src/main/java/it/pagopa/selfcare/onboarding/connector/model/onboarding/OnboardingData.java @@ -40,6 +40,7 @@ public class OnboardingData { private InstitutionUpdate institutionUpdate; private InstitutionType institutionType; private String origin; + private String originId; private String pricingPlan; private String businessName; private boolean existsInRegistry; diff --git a/connector/rest/docs/openapi/api-selfcare-onboarding-docs.json b/connector/rest/docs/openapi/api-selfcare-onboarding-docs.json index be81da64..52372e6a 100644 --- a/connector/rest/docs/openapi/api-selfcare-onboarding-docs.json +++ b/connector/rest/docs/openapi/api-selfcare-onboarding-docs.json @@ -4,6 +4,13 @@ "title" : "onboarding-ms API", "version" : "1.0.0" }, + "servers" : [ { + "url" : "http://localhost:8080", + "description" : "Auto generated value" + }, { + "url" : "http://0.0.0.0:8080", + "description" : "Auto generated value" + } ], "paths" : { "/v1/onboarding" : { "get" : { @@ -759,11 +766,9 @@ } }, "BillingRequest" : { - "required" : [ "vatNumber" ], "type" : "object", "properties" : { "vatNumber" : { - "minLength" : 1, "type" : "string" }, "recipientCode" : { @@ -814,14 +819,13 @@ } }, "InstitutionBaseRequest" : { - "required" : [ "institutionType", "taxCode", "digitalAddress" ], + "required" : [ "institutionType", "digitalAddress" ], "type" : "object", "properties" : { "institutionType" : { "$ref" : "#/components/schemas/InstitutionType" }, "taxCode" : { - "minLength" : 1, "type" : "string" }, "subunitCode" : { @@ -833,6 +837,9 @@ "origin" : { "$ref" : "#/components/schemas/Origin" }, + "originId" : { + "type" : "string" + }, "city" : { "type" : "string" }, @@ -953,14 +960,13 @@ "type" : "string" }, "InstitutionPspRequest" : { - "required" : [ "institutionType", "taxCode", "digitalAddress", "paymentServiceProvider" ], + "required" : [ "institutionType", "digitalAddress", "paymentServiceProvider" ], "type" : "object", "properties" : { "institutionType" : { "$ref" : "#/components/schemas/InstitutionType" }, "taxCode" : { - "minLength" : 1, "type" : "string" }, "subunitCode" : { @@ -972,6 +978,9 @@ "origin" : { "$ref" : "#/components/schemas/Origin" }, + "originId" : { + "type" : "string" + }, "city" : { "type" : "string" }, @@ -1306,6 +1315,7 @@ "$ref" : "#/components/schemas/Origin" }, "digitalAddress" : { + "pattern" : "\\S", "type" : "string" } } diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/onboarding/connector/rest/mapper/OnboardingMapper.java b/connector/rest/src/main/java/it/pagopa/selfcare/onboarding/connector/rest/mapper/OnboardingMapper.java index 54c906d9..a98971ab 100644 --- a/connector/rest/src/main/java/it/pagopa/selfcare/onboarding/connector/rest/mapper/OnboardingMapper.java +++ b/connector/rest/src/main/java/it/pagopa/selfcare/onboarding/connector/rest/mapper/OnboardingMapper.java @@ -12,7 +12,6 @@ import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; @Mapper(componentModel = "spring") public interface OnboardingMapper { @@ -42,6 +41,9 @@ default InstitutionBaseRequest toInstitutionBase(OnboardingData onboardingData) .map(InstitutionPaSubunitType::valueOf) .orElse(null)); institution.setOrigin(Optional.ofNullable(onboardingData.getOrigin()).map(Origin::fromValue).orElse(null)); + if(Objects.nonNull(onboardingData.getOriginId())) { + institution.setOriginId(onboardingData.getOriginId()); + } if(Objects.nonNull(onboardingData.getLocation())) { institution.setCity(onboardingData.getLocation().getCity()); institution.setCountry(onboardingData.getLocation().getCountry()); @@ -54,7 +56,7 @@ default InstitutionBaseRequest toInstitutionBase(OnboardingData onboardingData) institution.geographicTaxonomies(Optional.ofNullable(onboardingData.getInstitutionUpdate().getGeographicTaxonomies()) .map(geotaxes -> geotaxes.stream() .map(this::toGeographicTaxonomyDto) - .collect(Collectors.toList())) + .toList()) .orElse(null)); institution.rea(onboardingData.getInstitutionUpdate().getRea()); institution.shareCapital(onboardingData.getInstitutionUpdate().getShareCapital()); @@ -77,6 +79,9 @@ default InstitutionPspRequest toInstitutionPsp(OnboardingData onboardingData) { .orElse(null)); institutionPsp.setOrigin(Optional.ofNullable(onboardingData.getOrigin()).map(Origin::fromValue).orElse(null)); + if(Objects.nonNull(onboardingData.getOriginId())) { + institutionPsp.setOriginId(onboardingData.getOriginId()); + } if(Objects.nonNull(onboardingData.getLocation())) { institutionPsp.setCity(onboardingData.getLocation().getCity()); institutionPsp.setCountry(onboardingData.getLocation().getCountry()); @@ -89,7 +94,7 @@ default InstitutionPspRequest toInstitutionPsp(OnboardingData onboardingData) { institutionPsp.geographicTaxonomies(Optional.ofNullable(onboardingData.getInstitutionUpdate().getGeographicTaxonomies()) .map(geotaxes -> geotaxes.stream() .map(this::toGeographicTaxonomyDto) - .collect(Collectors.toList())) + .toList()) .orElse(null)); institutionPsp.rea(onboardingData.getInstitutionUpdate().getRea()); institutionPsp.shareCapital(onboardingData.getInstitutionUpdate().getShareCapital()); diff --git a/connector/rest/src/test/java/it/pagopa/selfcare/onboarding/connector/OnboardingMsConnectorImplTest.java b/connector/rest/src/test/java/it/pagopa/selfcare/onboarding/connector/OnboardingMsConnectorImplTest.java index 4611b4d3..e97847d5 100644 --- a/connector/rest/src/test/java/it/pagopa/selfcare/onboarding/connector/OnboardingMsConnectorImplTest.java +++ b/connector/rest/src/test/java/it/pagopa/selfcare/onboarding/connector/OnboardingMsConnectorImplTest.java @@ -52,6 +52,7 @@ void onboarding_institutionDefault() { institutionUpdate.setDescription("description"); onboardingData.setBilling(billing); onboardingData.setUsers(List.of(mockInstance(new User()))); + onboardingData.setOriginId("originId"); onboardingData.setInstitutionUpdate(institutionUpdate); // when onboardingMsConnector.onboarding(onboardingData); diff --git a/web/src/main/java/it/pagopa/selfcare/onboarding/web/model/mapper/OnboardingResourceMapper.java b/web/src/main/java/it/pagopa/selfcare/onboarding/web/model/mapper/OnboardingResourceMapper.java index ff8caf4a..53ec660d 100644 --- a/web/src/main/java/it/pagopa/selfcare/onboarding/web/model/mapper/OnboardingResourceMapper.java +++ b/web/src/main/java/it/pagopa/selfcare/onboarding/web/model/mapper/OnboardingResourceMapper.java @@ -28,6 +28,7 @@ public interface OnboardingResourceMapper { @Mapping(source = "assistanceContacts.supportEmail", target = "institutionUpdate.supportEmail") @Mapping(source = "assistanceContacts.supportPhone", target = "institutionUpdate.supportPhone") @Mapping(source = "additionalInformations", target = "institutionUpdate.additionalInformations") + @Mapping(source = "ivassCode", target = "originId") OnboardingData toEntity(OnboardingProductDto dto); @Mapping(source = "billingData", target = "billing")