From 21b4583b04b8da434d798dca0ea70ba45444a7df Mon Sep 17 00:00:00 2001 From: Andrea Grillo Date: Wed, 20 Dec 2023 10:07:05 +0100 Subject: [PATCH 1/2] [SELC-3607] Increase replicas - DEV (#340) --- .devops/deploy-pipelines.yml | 2 +- helm/values-dev.yaml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.devops/deploy-pipelines.yml b/.devops/deploy-pipelines.yml index 24fc9a134..cfb37ba5a 100644 --- a/.devops/deploy-pipelines.yml +++ b/.devops/deploy-pipelines.yml @@ -184,7 +184,7 @@ stages: valueFile: "$(Pipeline.Workspace)/helm/values-${{ lower(variables.environment) }}.yaml" install: true waitForExecution: true - arguments: "--timeout 4m0s" + arguments: "--timeout 5m0s" - task: KubernetesManifest@0 displayName: Patch inputs: diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index c42fa71cb..b8de871cf 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -29,6 +29,9 @@ autoscaling: targetCPUUtilizationPercentage: 80 # targetMemoryUtilizationPercentage: 80 +pdb: + enabled: true + configEnvSpecific: JAVA_TOOL_OPTIONS: "-javaagent:/applicationinsights-agent.jar" APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL: "OFF" From d4a5918222eaed48877e14a5cce4f1ec4a3927db Mon Sep 17 00:00:00 2001 From: Manuel Rafeli Date: Wed, 20 Dec 2023 10:58:23 +0100 Subject: [PATCH 2/2] [SELC-3503] feat: enhance /institutions/from-ipa with geotaxonomy integration (#341) --- app/src/main/resources/swagger/api-docs.json | 6 ++++++ .../mscore/core/InstitutionService.java | 2 +- .../mscore/core/InstitutionServiceImpl.java | 3 ++- .../strategy/CreateInstitutionStrategyIpa.java | 2 ++ .../input/CreateInstitutionStrategyInput.java | 4 ++++ .../core/InstitutionServiceImplTest.java | 4 ++-- .../CreateInstitutionStrategyTest.java | 9 +++++++++ .../web/controller/InstitutionController.java | 6 +++++- .../institution/InstitutionFromIpaPost.java | 2 ++ .../mapper/InstitutionResourceMapper.java | 4 ++++ .../controller/InstitutionControllerTest.java | 18 +++++++++++++----- 11 files changed, 50 insertions(+), 10 deletions(-) diff --git a/app/src/main/resources/swagger/api-docs.json b/app/src/main/resources/swagger/api-docs.json index 8cdcc9899..9a817aab6 100644 --- a/app/src/main/resources/swagger/api-docs.json +++ b/app/src/main/resources/swagger/api-docs.json @@ -5962,6 +5962,12 @@ "title" : "InstitutionFromIpaPost", "type" : "object", "properties" : { + "geographicTaxonomies" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/GeoTaxonomies" + } + }, "subunitCode" : { "type" : "string" }, diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionService.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionService.java index fb0535e19..77a8a6270 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionService.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionService.java @@ -27,7 +27,7 @@ public interface InstitutionService { List getInstitutions(String taxCode, String subunitCode); - Institution createInstitutionFromIpa(String taxCode, InstitutionPaSubunitType subunitType, String subunitCode); + Institution createInstitutionFromIpa(String taxCode, InstitutionPaSubunitType subunitType, String subunitCode, List geographicTaxonomies); Institution createInstitutionFromPda(Institution institution, String injectionInstitutionType); diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImpl.java index a4c59ee3a..bec381ebc 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImpl.java @@ -127,12 +127,13 @@ public List getInstitutions(String taxCode, String subunitCode) { } @Override - public Institution createInstitutionFromIpa(String taxCode, InstitutionPaSubunitType subunitType, String subunitCode) { + public Institution createInstitutionFromIpa(String taxCode, InstitutionPaSubunitType subunitType, String subunitCode, List geographicTaxonomies) { CreateInstitutionStrategy institutionStrategy = createInstitutionStrategyFactory.createInstitutionStrategyIpa(); return institutionStrategy.createInstitution(CreateInstitutionStrategyInput.builder() .taxCode(taxCode) .subunitCode(subunitCode) .subunitType(subunitType) + .geographicTaxonomies(geographicTaxonomies) .build()); } diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/strategy/CreateInstitutionStrategyIpa.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/strategy/CreateInstitutionStrategyIpa.java index ee2e1bfb3..d812a39e7 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/strategy/CreateInstitutionStrategyIpa.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/strategy/CreateInstitutionStrategyIpa.java @@ -59,6 +59,8 @@ public Institution createInstitution(CreateInstitutionStrategyInput strategyInpu institution = getInstitutionEC(strategyInput.getTaxCode(), institutionProxyInfo, categoryProxyInfo); } + institution.setGeographicTaxonomies(strategyInput.getGeographicTaxonomies()); + try { return institutionConnector.save(institution); } catch (Exception e) { diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/strategy/input/CreateInstitutionStrategyInput.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/strategy/input/CreateInstitutionStrategyInput.java index 4350f81e4..a9ef5afe7 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/strategy/input/CreateInstitutionStrategyInput.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/strategy/input/CreateInstitutionStrategyInput.java @@ -1,9 +1,12 @@ package it.pagopa.selfcare.mscore.core.strategy.input; import it.pagopa.selfcare.mscore.core.util.InstitutionPaSubunitType; +import it.pagopa.selfcare.mscore.model.institution.InstitutionGeographicTaxonomies; import lombok.Builder; import lombok.Data; +import java.util.List; + @Builder @Data public class CreateInstitutionStrategyInput { @@ -11,5 +14,6 @@ public class CreateInstitutionStrategyInput { private String taxCode; private String description; private InstitutionPaSubunitType subunitType; + private List geographicTaxonomies; private String subunitCode; } diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java index 19a6223f1..50451e122 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java @@ -313,13 +313,13 @@ void testGetInstitutionsFails() { } /** - * Method under test: {@link InstitutionServiceImpl#createInstitutionFromIpa(String, InstitutionPaSubunitType, String)} + * Method under test: {@link InstitutionServiceImpl#createInstitutionFromIpa(String, InstitutionPaSubunitType, String, List)} */ @Test void testCreateInstitutionFromIpa() { when(createInstitutionStrategyFactory.createInstitutionStrategyIpa()).thenReturn(createInstitutionStrategy); when(createInstitutionStrategy.createInstitution(any())).thenReturn(new Institution()); - Institution institution = institutionServiceImpl.createInstitutionFromIpa("id", InstitutionPaSubunitType.AOO,"id"); + Institution institution = institutionServiceImpl.createInstitutionFromIpa("id", InstitutionPaSubunitType.AOO,"id", List.of()); assertNotNull(institution); } diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/strategy/CreateInstitutionStrategyTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/strategy/CreateInstitutionStrategyTest.java index eb5fa1457..22bbabbfb 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/strategy/CreateInstitutionStrategyTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/strategy/CreateInstitutionStrategyTest.java @@ -51,6 +51,7 @@ class CreateInstitutionStrategyTest { private static final AreaOrganizzativaOmogenea dummyAreaOrganizzativaOmogenea; private static final GeographicTaxonomies dummyGeotaxonomies; + private static final InstitutionGeographicTaxonomies dummyInstitutionGeotaxonomies; static { dummyInstitutionProxyInfo = new InstitutionProxyInfo(); @@ -87,6 +88,10 @@ class CreateInstitutionStrategyTest { dummyGeotaxonomies.setDescription("nomeCittà - COMUNE"); dummyGeotaxonomies.setProvinceAbbreviation("proAbbrv"); dummyGeotaxonomies.setCountryAbbreviation("countryAbbrv"); + + dummyInstitutionGeotaxonomies = new InstitutionGeographicTaxonomies(); + dummyInstitutionGeotaxonomies.setCode("code"); + dummyInstitutionGeotaxonomies.setDesc("desc"); } private UnitaOrganizzativa dummyUnitaOrganizzativa() { @@ -245,6 +250,7 @@ void shouldCreateInstitutionFromIpaAoo() { .taxCode(dummyAreaOrganizzativaOmogenea.getCodiceFiscaleEnte()) .subunitType(InstitutionPaSubunitType.AOO) .subunitCode(dummyAreaOrganizzativaOmogenea.getCodAoo()) + .geographicTaxonomies(List.of(dummyInstitutionGeotaxonomies)) .build()); //Then @@ -259,6 +265,9 @@ void shouldCreateInstitutionFromIpaAoo() { assertThat(actual.getSubunitType()).isEqualTo(InstitutionPaSubunitType.AOO.name()); assertThat(actual.getParentDescription()).isEqualTo(dummyInstitutionProxyInfo.getDescription()); assertThat(actual.getCity()).isEqualTo(dummyGeotaxonomies.getDescription().replace(" - COMUNE", "")); + assertThat(actual.getGeographicTaxonomies().size()).isEqualTo(1); + assertThat(actual.getGeographicTaxonomies().get(0).getCode()).isEqualTo(dummyInstitutionGeotaxonomies.getCode()); + verify(institutionConnector, times(2)).save(any()); verify(institutionConnector).findByTaxCodeAndSubunitCode(anyString(), anyString()); verify(partyRegistryProxyConnector).getCategory(any(), any()); diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/InstitutionController.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/InstitutionController.java index a1a6b21fa..4b0d7672f 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/InstitutionController.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/InstitutionController.java @@ -124,8 +124,12 @@ public ResponseEntity createInstitutionFromIpa(@RequestBody throw new ValidationException("subunitCode and subunitType must both be evaluated."); } + List geographicTaxonomies = Optional.ofNullable(institutionFromIpaPost.getGeographicTaxonomies()) + .map(geoTaxonomies -> geoTaxonomies.stream().map(institutionResourceMapper::toInstitutionGeographicTaxonomies).toList()) + .orElse(List.of()); + Institution saved = institutionService.createInstitutionFromIpa(institutionFromIpaPost.getTaxCode(), - institutionFromIpaPost.getSubunitType(), institutionFromIpaPost.getSubunitCode()); + institutionFromIpaPost.getSubunitType(), institutionFromIpaPost.getSubunitCode(), geographicTaxonomies); return ResponseEntity.status(HttpStatus.CREATED).body(institutionResourceMapper.toInstitutionResponse(saved)); } diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/InstitutionFromIpaPost.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/InstitutionFromIpaPost.java index c4b3c9af1..f61552b2d 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/InstitutionFromIpaPost.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/InstitutionFromIpaPost.java @@ -4,6 +4,7 @@ import lombok.Data; import javax.validation.constraints.NotNull; +import java.util.List; @Data public class InstitutionFromIpaPost { @@ -12,4 +13,5 @@ public class InstitutionFromIpaPost { private String taxCode; private String subunitCode; private InstitutionPaSubunitType subunitType; + private List geographicTaxonomies; } diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/model/mapper/InstitutionResourceMapper.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/model/mapper/InstitutionResourceMapper.java index 940a458c7..7a75b610d 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/model/mapper/InstitutionResourceMapper.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/model/mapper/InstitutionResourceMapper.java @@ -3,7 +3,9 @@ import it.pagopa.selfcare.mscore.model.institution.Billing; import it.pagopa.selfcare.mscore.model.institution.Institution; +import it.pagopa.selfcare.mscore.model.institution.InstitutionGeographicTaxonomies; import it.pagopa.selfcare.mscore.web.model.institution.BillingRequest; +import it.pagopa.selfcare.mscore.web.model.institution.GeoTaxonomies; import it.pagopa.selfcare.mscore.web.model.institution.InstitutionResponse; import it.pagopa.selfcare.mscore.web.model.institution.RootParentResponse; import org.mapstruct.Mapper; @@ -32,5 +34,7 @@ static RootParentResponse setRootParent(Institution institution) { Billing billingRequestToBilling(BillingRequest billingRequest); + InstitutionGeographicTaxonomies toInstitutionGeographicTaxonomies(GeoTaxonomies geoTaxonomies); + } diff --git a/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/InstitutionControllerTest.java b/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/InstitutionControllerTest.java index f92a28a33..aedf86def 100644 --- a/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/InstitutionControllerTest.java +++ b/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/InstitutionControllerTest.java @@ -20,10 +20,7 @@ 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.Spy; +import org.mockito.*; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.web.PageableHandlerMethodArgumentResolver; import org.springframework.http.MediaType; @@ -342,6 +339,10 @@ void shouldCreateInstitutionFromIpa() throws Exception { institutionFromIpaPost.setTaxCode("123456"); institutionFromIpaPost.setSubunitType(InstitutionPaSubunitType.AOO); institutionFromIpaPost.setSubunitCode("1234"); + GeoTaxonomies geoTaxonomies = new GeoTaxonomies(); + geoTaxonomies.setCode("code"); + geoTaxonomies.setDesc("desc"); + institutionFromIpaPost.setGeographicTaxonomies(List.of(geoTaxonomies)); String content = objectMapper.writeValueAsString(institutionFromIpaPost); Institution institution = TestUtils.createSimpleInstitutionPA(); @@ -350,7 +351,7 @@ void shouldCreateInstitutionFromIpa() throws Exception { institution.setParentDescription("parentDescription"); institution.setRootParentId("rootParentId"); - when(institutionService.createInstitutionFromIpa(any(), any(), any())).thenReturn(institution); + when(institutionService.createInstitutionFromIpa(any(), any(), any(), any())).thenReturn(institution); //Then MockHttpServletRequestBuilder requestBuilder = post("/institutions/from-ipa/") @@ -362,6 +363,13 @@ void shouldCreateInstitutionFromIpa() throws Exception { actualPerformResult.andExpect(MockMvcResultMatchers.status().isCreated()) .andExpect(MockMvcResultMatchers.content().contentType("application/json")) .andExpect(MockMvcResultMatchers.content().string("{\"id\":\"42\",\"externalId\":\"42\",\"origin\":\"MOCK\",\"originId\":\"Ipa Code\",\"description\":\"The characteristics of someone or something\",\"institutionType\":\"PA\",\"digitalAddress\":\"42 Main St\",\"address\":\"42 Main St\",\"zipCode\":\"21654\",\"taxCode\":\"Tax Code\",\"geographicTaxonomies\":[],\"attributes\":[],\"onboarding\":[],\"paymentServiceProvider\":{\"abiCode\":\"Abi Code\",\"businessRegisterNumber\":\"42\",\"legalRegisterNumber\":\"42\",\"legalRegisterName\":\"Legal Register Name\",\"vatNumberGroup\":true},\"dataProtectionOfficer\":{\"address\":\"42 Main St\",\"email\":\"jane.doe@example.org\",\"pec\":\"Pec\"},\"rootParent\":{\"description\":\"parentDescription\",\"id\":\"rootParentId\"},\"rea\":\"Rea\",\"shareCapital\":\"Share Capital\",\"imported\":false,\"subunitCode\":\"1234\",\"subunitType\":\"AOO\"}")); + + ArgumentCaptor> captorGeo = ArgumentCaptor.forClass(List.class); + verify(institutionService, times(1)) + .createInstitutionFromIpa(any(),any(),any(),captorGeo.capture()); + assertEquals(institutionFromIpaPost.getGeographicTaxonomies().size(), captorGeo.getValue().size()); + assertEquals(geoTaxonomies.getCode(), captorGeo.getValue().get(0).getCode()); + assertEquals(geoTaxonomies.getDesc(), captorGeo.getValue().get(0).getDesc()); } /**