Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release-dev' into feature/SELC-3554
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinSi96 authored Dec 20, 2023
2 parents 465f579 + d4a5918 commit 6c8f120
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .devops/deploy-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/resources/swagger/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6038,6 +6038,12 @@
"title" : "InstitutionFromIpaPost",
"type" : "object",
"properties" : {
"geographicTaxonomies" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/GeoTaxonomies"
}
},
"subunitCode" : {
"type" : "string"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface InstitutionService {

List<Institution> getInstitutions(String taxCode, String subunitCode);

Institution createInstitutionFromIpa(String taxCode, InstitutionPaSubunitType subunitType, String subunitCode);
Institution createInstitutionFromIpa(String taxCode, InstitutionPaSubunitType subunitType, String subunitCode, List<InstitutionGeographicTaxonomies> geographicTaxonomies);

Institution createInstitutionFromPda(Institution institution, String injectionInstitutionType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@ public List<Institution> 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<InstitutionGeographicTaxonomies> geographicTaxonomies) {
CreateInstitutionStrategy institutionStrategy = createInstitutionStrategyFactory.createInstitutionStrategyIpa();
return institutionStrategy.createInstitution(CreateInstitutionStrategyInput.builder()
.taxCode(taxCode)
.subunitCode(subunitCode)
.subunitType(subunitType)
.geographicTaxonomies(geographicTaxonomies)
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
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 {

private String taxCode;
private String description;
private InstitutionPaSubunitType subunitType;
private List<InstitutionGeographicTaxonomies> geographicTaxonomies;
private String subunitCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -245,6 +250,7 @@ void shouldCreateInstitutionFromIpaAoo() {
.taxCode(dummyAreaOrganizzativaOmogenea.getCodiceFiscaleEnte())
.subunitType(InstitutionPaSubunitType.AOO)
.subunitCode(dummyAreaOrganizzativaOmogenea.getCodAoo())
.geographicTaxonomies(List.of(dummyInstitutionGeotaxonomies))
.build());

//Then
Expand All @@ -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());
Expand Down
3 changes: 3 additions & 0 deletions helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,12 @@ public ResponseEntity<InstitutionResponse> createInstitutionFromIpa(@RequestBody
throw new ValidationException("subunitCode and subunitType must both be evaluated.");
}

List<InstitutionGeographicTaxonomies> 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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.List;

@Data
public class InstitutionFromIpaPost {
Expand All @@ -12,4 +13,5 @@ public class InstitutionFromIpaPost {
private String taxCode;
private String subunitCode;
private InstitutionPaSubunitType subunitType;
private List<GeoTaxonomies> geographicTaxonomies;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -32,5 +34,7 @@ static RootParentResponse setRootParent(Institution institution) {

Billing billingRequestToBilling(BillingRequest billingRequest);

InstitutionGeographicTaxonomies toInstitutionGeographicTaxonomies(GeoTaxonomies geoTaxonomies);


}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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/")
Expand All @@ -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<List<InstitutionGeographicTaxonomies>> 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());
}

/**
Expand Down

0 comments on commit 6c8f120

Please sign in to comment.