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

Commit

Permalink
[SELC-4819] Feat: added taxCodeSfe in Institution for UO (#487)
Browse files Browse the repository at this point in the history
Co-authored-by: empassaro <emanuele.passaro@emeal.nttdata.com>
  • Loading branch information
flaminiaScarciofolo and empassaro authored May 13, 2024
1 parent d46971c commit a1db93c
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class UnitaOrganizzativa {
private String codiceIpa;
private String denominazioneEnte;
private String codiceFiscaleEnte;
private String codiceFiscaleSfe;
private String codiceUniUo;
private String codiceUniUoPadre;
private String codiceUniAoo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Institution {
private String zipCode;
private String taxCode;
private String ivassCode;
private String taxCodeSfe;
private String city;
private String county;
private String country;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class InstitutionEntity {
private String address;
private String zipCode;
private String taxCode;
private String taxCodeSfe;
private String city;
private String county;
private String country;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package it.pagopa.selfcare.mscore.connector.rest.model.registryproxy;

import com.fasterxml.jackson.annotation.JsonProperty;
import it.pagopa.selfcare.mscore.constant.Origin;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Data
public class UoResponse {

private String id;
private String codiceIpa;
private String denominazioneEnte;
private String codiceFiscaleEnte;
private String codiceFiscaleSfe;
private String codiceUniUo;
private String codiceUniUoPadre;
private String codiceUniAoo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private Institution mappingToInstitutionIPAUo(CreateInstitutionStrategyInput str
newInstitution.setAddress(unitaOrganizzativa.getIndirizzo());
newInstitution.setZipCode(unitaOrganizzativa.getCAP());
newInstitution.setTaxCode(unitaOrganizzativa.getCodiceFiscaleEnte());
newInstitution.setTaxCodeSfe(unitaOrganizzativa.getCodiceFiscaleSfe());
newInstitution.setSubunitCode(strategyInput.getSubunitCode());
newInstitution.setSubunitType(InstitutionPaSubunitType.UO.name());
newInstitution.setParentDescription(institutionProxyInfo.getDescription());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Optional;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
Expand Down Expand Up @@ -299,6 +300,7 @@ void shouldCreateInstitutionFromIpaAoo() {
void shouldCreateInstitutionFromIpaUo() {

UnitaOrganizzativa dummyUnitaOrganizzativa = dummyUnitaOrganizzativa();
dummyUnitaOrganizzativa.setCodiceFiscaleSfe("codiceFiscaleSfe");

when(institutionConnector.save(any())).thenAnswer(args -> args.getArguments()[0]);
when(institutionConnector.findByTaxCodeAndSubunitCode(anyString(), anyString()))
Expand Down Expand Up @@ -403,17 +405,64 @@ void shouldCreateInstitutionFromIpaUoRetrievingExistingEc() {
assertThat(actual.getAddress()).isEqualTo(dummyUnitaOrganizzativa.getIndirizzo());
assertThat(actual.getZipCode()).isEqualTo(dummyUnitaOrganizzativa.getCAP());
assertThat(actual.getTaxCode()).isEqualTo(dummyUnitaOrganizzativa.getCodiceFiscaleEnte());
assertThat(actual.getTaxCodeSfe()).isEqualTo(dummyUnitaOrganizzativa.getCodiceFiscaleSfe());
assertThat(actual.getSubunitCode()).isEqualTo(dummyUnitaOrganizzativa.getCodiceUniUo());
assertThat(actual.getSubunitType()).isEqualTo(InstitutionPaSubunitType.UO.name());
assertThat(actual.getParentDescription()).isEqualTo(dummyInstitutionProxyInfo.getDescription());
assertThat(actual.getPaAttributes().getAooParentCode()).isEqualTo(dummyUnitaOrganizzativa.getCodiceUniAoo());
assertThat(actual.getCity()).isEqualTo(dummyGeotaxonomies.getDescription().replace(" - COMUNE", ""));

verify(institutionConnector, times(1)).save(any());
verify(institutionConnector).findByTaxCodeAndSubunitCode(anyString(), anyString());
verify(partyRegistryProxyConnector).getCategory(any(), any());
verify(partyRegistryProxyConnector).getInstitutionById(any());
}

/**
* Method under test: {@link CreateInstitutionStrategy#createInstitution(CreateInstitutionStrategyInput)}
*/
@Test
void shouldCreateInstitutionFromIpaUoWithoutTaxCodeSfe() {

UnitaOrganizzativa dummyUnitaOrganizzativa = dummyUnitaOrganizzativa();

when(institutionConnector.save(any())).thenAnswer(args -> args.getArguments()[0]);
when(institutionConnector.findByTaxCodeAndSubunitCode(anyString(), anyString()))
.thenReturn(List.of());

when(partyRegistryProxyConnector.getCategory(any(), any())).thenReturn(dummyCategoryProxyInfo);
when(partyRegistryProxyConnector.getInstitutionById(any())).thenReturn(dummyInstitutionProxyInfo);
when(partyRegistryProxyConnector.getUoById(any())).thenReturn(dummyUnitaOrganizzativa);
when(partyRegistryProxyConnector.getExtByCode(anyString())).thenReturn(dummyGeotaxonomies).thenReturn(dummyGeotaxonomies);

Institution actual = strategyFactory.createInstitutionStrategyIpa()
.createInstitution(CreateInstitutionStrategyInput.builder()
.taxCode(dummyUnitaOrganizzativa.getCodiceFiscaleEnte())
.subunitType(InstitutionPaSubunitType.UO)
.subunitCode(dummyUnitaOrganizzativa.getCodiceUniUo())
.build());

//Then
assertThat(actual.getOriginId()).isEqualTo(dummyUnitaOrganizzativa.getId());
assertThat(actual.getDescription()).isEqualTo(dummyUnitaOrganizzativa.getDescrizioneUo());

assertThat(actual.getInstitutionType()).isEqualTo(InstitutionType.PA);
assertThat(actual.getDigitalAddress()).isEqualTo(dummyInstitutionProxyInfo.getDigitalAddress());
assertThat(actual.getAddress()).isEqualTo(dummyUnitaOrganizzativa.getIndirizzo());
assertThat(actual.getZipCode()).isEqualTo(dummyUnitaOrganizzativa.getCAP());
assertThat(actual.getTaxCode()).isEqualTo(dummyUnitaOrganizzativa.getCodiceFiscaleEnte());
assertNull(actual.getTaxCodeSfe());
assertThat(actual.getSubunitCode()).isEqualTo(dummyUnitaOrganizzativa.getCodiceUniUo());
assertThat(actual.getSubunitType()).isEqualTo(InstitutionPaSubunitType.UO.name());
assertThat(actual.getParentDescription()).isEqualTo(dummyInstitutionProxyInfo.getDescription());
assertThat(actual.getPaAttributes().getAooParentCode()).isEqualTo(dummyUnitaOrganizzativa.getCodiceUniAoo());

verify(institutionConnector, times(2)).save(any());
verify(institutionConnector).findByTaxCodeAndSubunitCode(anyString(), anyString());
verify(partyRegistryProxyConnector).getCategory(any(), any());
verify(partyRegistryProxyConnector).getInstitutionById(any());
}

/**
* Method under test: {@link CreateInstitutionStrategy#createInstitution(CreateInstitutionStrategyInput)}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static Institution dummyInstitution(InstitutionType institutionType) {

return new Institution("42", "42", Origin.SELC.name(), "START - setupCommonData",
"The characteristics of someone or something", institutionType, "42 Main St", "42 Main St", "21654",
"TaxCode","ivass", "city", "county", "country", "istatCode", billing, onboarding, geographicTaxonomies, attributes, paymentServiceProvider,
"TaxCode","ivass", "taxCodeSfe", "city", "county", "country", "istatCode", billing, onboarding, geographicTaxonomies, attributes, paymentServiceProvider,
new DataProtectionOfficer(), null, null, "START - setupCommonData", "START - setupCommonData",
"START - setupCommonData", true, OffsetDateTime.now(), OffsetDateTime.now(), null, null, null, null, new PaAttributes(),false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class InstitutionResponse {
private String address;
private String zipCode;
private String taxCode;
private String taxCodeSfe;
private String city;
private String county;
private String country;
Expand Down

0 comments on commit a1db93c

Please sign in to comment.