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

Commit

Permalink
[SELC-5022] Feat: Removed /external/institution/pn-pg API and related…
Browse files Browse the repository at this point in the history
… methods (#511)
  • Loading branch information
flaminiaScarciofolo authored Jun 14, 2024
1 parent 427834d commit fe2a1d0
Show file tree
Hide file tree
Showing 14 changed files with 0 additions and 360 deletions.
83 changes: 0 additions & 83 deletions app/src/main/resources/swagger/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,68 +514,6 @@
} ]
}
},
"/external/institutions/pn-pg" : {
"post" : {
"tags" : [ "External" ],
"summary" : "create an institution (PG) using external institution id fetching data from info-camere",
"description" : "create an institution (PG) using external institution id fetching data from info-camere",
"operationId" : "createPnPgInstitutionUsingPOST",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/CreatePnPgInstitutionRequest"
}
}
}
},
"responses" : {
"201" : {
"description" : "Created",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/InstitutionPnPgResponse"
}
}
}
},
"400" : {
"description" : "Bad Request",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"404" : {
"description" : "Not Found",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"409" : {
"description" : "Conflict",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
}
},
"security" : [ {
"bearerAuth" : [ "global" ]
} ]
}
},
"/external/institutions/{externalId}" : {
"get" : {
"tags" : [ "External" ],
Expand Down Expand Up @@ -2720,18 +2658,6 @@
}
}
},
"CreatePnPgInstitutionRequest" : {
"title" : "CreatePnPgInstitutionRequest",
"type" : "object",
"properties" : {
"description" : {
"type" : "string"
},
"taxId" : {
"type" : "string"
}
}
},
"CreatedAtRequest" : {
"title" : "CreatedAtRequest",
"type" : "object",
Expand Down Expand Up @@ -3199,15 +3125,6 @@
}
}
},
"InstitutionPnPgResponse" : {
"title" : "InstitutionPnPgResponse",
"type" : "object",
"properties" : {
"id" : {
"type" : "string"
}
}
},
"InstitutionProduct" : {
"title" : "InstitutionProduct",
"type" : "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public interface InstitutionConnector {

List<Institution> findAllByIds(List<String> ids);

Institution saveOrRetrievePnPg(Institution newInstitution);

List<String> findByExternalIdsAndProductId(List<ValidInstitution> externalIds, String productId);

Institution updateOnboardedProductCreatedAt(String institutionId, String productId, OffsetDateTime createdAt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ public Institution save(Institution institution) {
return institutionMapper.convertToInstitution(repository.save(entity));
}

@Override
public Institution saveOrRetrievePnPg(Institution institution) {
final InstitutionEntity entity = institutionMapper.convertToInstitutionEntity(institution);
return findByExternalId(institution.getExternalId())
.orElse(institutionMapper.convertToInstitution(repository.save(entity)));
}

@Override
public List<String> findByExternalIdsAndProductId(List<ValidInstitution> validInstitutionList, String productId) {
List<String> externalIds = validInstitutionList.stream().map(ValidInstitution::getId).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,126 +338,6 @@ void testFindInstitutionProduct() {
assertThrows(ResourceNotFoundException.class, () -> institutionConnectorImpl.findByExternalIdAndProductId("externalId", "productId"));
}

/**
* Method under test: {@link InstitutionConnectorImpl#saveOrRetrievePnPg(Institution)}
*/
@Test
void testSaveOrRetrievePnPg() {
InstitutionEntity institutionEntity = TestUtils.createSimpleInstitutionEntity();

when(institutionRepository.save(org.mockito.Mockito.any())).thenReturn(institutionEntity);
when(institutionRepository.find(org.mockito.Mockito.any(), org.mockito.Mockito.any())).thenReturn(new ArrayList<>());
Institution actualSaveOrRetrievePnPgResult = institutionConnectorImpl.saveOrRetrievePnPg(new Institution());
assertEquals("42 Main St", actualSaveOrRetrievePnPgResult.getAddress());
assertTrue(actualSaveOrRetrievePnPgResult.isImported());
assertEquals("21654", actualSaveOrRetrievePnPgResult.getZipCode());
assertNull(actualSaveOrRetrievePnPgResult.getUpdatedAt());
assertEquals("Tax Code", actualSaveOrRetrievePnPgResult.getTaxCode());
assertEquals("6625550144", actualSaveOrRetrievePnPgResult.getSupportPhone());
assertEquals("jane.doe@example.org", actualSaveOrRetrievePnPgResult.getSupportEmail());
assertEquals("Share Capital", actualSaveOrRetrievePnPgResult.getShareCapital());
assertEquals("Rea", actualSaveOrRetrievePnPgResult.getRea());
assertEquals("42", actualSaveOrRetrievePnPgResult.getOriginId());
assertEquals("Business Register Place", actualSaveOrRetrievePnPgResult.getBusinessRegisterPlace());
assertEquals("42 Main St", actualSaveOrRetrievePnPgResult.getDigitalAddress());
assertEquals("42", actualSaveOrRetrievePnPgResult.getExternalId());
assertNull(actualSaveOrRetrievePnPgResult.getCreatedAt());
assertEquals(Origin.MOCK.getValue(), actualSaveOrRetrievePnPgResult.getOrigin());
assertEquals(InstitutionType.PA, actualSaveOrRetrievePnPgResult.getInstitutionType());
assertEquals("42", actualSaveOrRetrievePnPgResult.getId());
assertEquals("The characteristics of someone or something", actualSaveOrRetrievePnPgResult.getDescription());
}

/**
* Method under test: {@link InstitutionConnectorImpl#saveOrRetrievePnPg(Institution)}
*/
@Test
void testSaveOrRetrievePnPg2() {
BillingEntity billingEntity = new BillingEntity();
billingEntity.setPublicServices(true);
billingEntity.setRecipientCode("Recipient Code");
billingEntity.setVatNumber("42");

DataProtectionOfficerEntity dataProtectionOfficerEntity = new DataProtectionOfficerEntity();
dataProtectionOfficerEntity.setAddress("42 Main St");
dataProtectionOfficerEntity.setEmail("jane.doe@example.org");
dataProtectionOfficerEntity.setPec("Pec");

PaymentServiceProviderEntity paymentServiceProviderEntity = new PaymentServiceProviderEntity();
paymentServiceProviderEntity.setAbiCode("Abi Code");
paymentServiceProviderEntity.setBusinessRegisterNumber("42");
paymentServiceProviderEntity.setLegalRegisterName("Legal Register Name");
paymentServiceProviderEntity.setLegalRegisterNumber("42");
paymentServiceProviderEntity.setVatNumberGroup(true);

DataProtectionOfficerEntity dataProtectionOfficerEntity1 = new DataProtectionOfficerEntity();
dataProtectionOfficerEntity1.setAddress("42 Main St");
dataProtectionOfficerEntity1.setEmail("jane.doe@example.org");
dataProtectionOfficerEntity1.setPec("Pec");

PaymentServiceProviderEntity paymentServiceProviderEntity1 = new PaymentServiceProviderEntity();
paymentServiceProviderEntity1.setAbiCode("Abi Code");
paymentServiceProviderEntity1.setBusinessRegisterNumber("42");
paymentServiceProviderEntity1.setLegalRegisterName("Legal Register Name");
paymentServiceProviderEntity1.setLegalRegisterNumber("42");
paymentServiceProviderEntity1.setVatNumberGroup(true);

AttributesEntity attributesEntity = new AttributesEntity();
attributesEntity.setCode("Code");
attributesEntity.setDescription("The characteristics of someone or something");
attributesEntity.setOrigin("Origin");

ArrayList<AttributesEntity> attributesEntityList = new ArrayList<>();
attributesEntityList.add(attributesEntity);
InstitutionEntity institutionEntity = mock(InstitutionEntity.class);
when(institutionEntity.isImported()).thenReturn(true);
when(institutionEntity.getDataProtectionOfficer()).thenReturn(dataProtectionOfficerEntity1);
when(institutionEntity.getPaymentServiceProvider()).thenReturn(paymentServiceProviderEntity1);
when(institutionEntity.getInstitutionType()).thenReturn(InstitutionType.PA);
when(institutionEntity.getOrigin()).thenReturn(Origin.MOCK);
when(institutionEntity.getAddress()).thenReturn("42 Main St");
when(institutionEntity.getBusinessRegisterPlace()).thenReturn("Business Register Place");
when(institutionEntity.getDescription()).thenReturn("The characteristics of someone or something");
when(institutionEntity.getDigitalAddress()).thenReturn("42 Main St");
when(institutionEntity.getExternalId()).thenReturn("42");
when(institutionEntity.getId()).thenReturn("42");
when(institutionEntity.getOriginId()).thenReturn("42");
when(institutionEntity.getRea()).thenReturn("Rea");
when(institutionEntity.getShareCapital()).thenReturn("Share Capital");
when(institutionEntity.getSupportEmail()).thenReturn("jane.doe@example.org");
when(institutionEntity.getSupportPhone()).thenReturn("6625550144");
when(institutionEntity.getTaxCode()).thenReturn("Tax Code");
when(institutionEntity.getZipCode()).thenReturn("21654");
when(institutionEntity.getCreatedAt()).thenReturn(null);
when(institutionEntity.getUpdatedAt()).thenReturn(null);
when(institutionEntity.getAttributes()).thenReturn(attributesEntityList);
when(institutionEntity.getGeographicTaxonomies()).thenReturn(new ArrayList<>());
when(institutionEntity.getOnboarding()).thenReturn(new ArrayList<>());

when(institutionRepository.save(org.mockito.Mockito.any())).thenReturn(institutionEntity);
when(institutionRepository.find(org.mockito.Mockito.any(), org.mockito.Mockito.any())).thenReturn(new ArrayList<>());
Institution actualSaveOrRetrievePnPgResult = institutionConnectorImpl.saveOrRetrievePnPg(new Institution());
assertEquals("42 Main St", actualSaveOrRetrievePnPgResult.getAddress());
assertTrue(actualSaveOrRetrievePnPgResult.isImported());
assertEquals("21654", actualSaveOrRetrievePnPgResult.getZipCode());
assertNull(actualSaveOrRetrievePnPgResult.getUpdatedAt());
assertEquals("Tax Code", actualSaveOrRetrievePnPgResult.getTaxCode());
assertEquals("6625550144", actualSaveOrRetrievePnPgResult.getSupportPhone());
assertEquals("jane.doe@example.org", actualSaveOrRetrievePnPgResult.getSupportEmail());
assertEquals("Share Capital", actualSaveOrRetrievePnPgResult.getShareCapital());
assertEquals("Rea", actualSaveOrRetrievePnPgResult.getRea());
assertEquals("42", actualSaveOrRetrievePnPgResult.getOriginId());
List<Attributes> attributes = actualSaveOrRetrievePnPgResult.getAttributes();
assertEquals(1, attributes.size());
assertEquals("Business Register Place", actualSaveOrRetrievePnPgResult.getBusinessRegisterPlace());
assertEquals("42 Main St", actualSaveOrRetrievePnPgResult.getDigitalAddress());
assertEquals("42", actualSaveOrRetrievePnPgResult.getExternalId());
assertNull(actualSaveOrRetrievePnPgResult.getCreatedAt());
assertEquals(InstitutionType.PA, actualSaveOrRetrievePnPgResult.getInstitutionType());
assertEquals("42", actualSaveOrRetrievePnPgResult.getId());
assertEquals("The characteristics of someone or something", actualSaveOrRetrievePnPgResult.getDescription());
}

/**
* Method under test: {@link InstitutionConnectorImpl#findByExternalIdsAndProductId(List, String)}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ public interface ExternalService {
List<Onboarding> retrieveInstitutionProductsByExternalId(String externalId, List<RelationshipState> states);

List<Institution> retrieveInstitutionByIds(List<String> ids);

Institution createPnPgInstitution(String taxId, String description);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public List<Institution> retrieveInstitutionByIds(List<String> ids) {
return institutionService.retrieveInstitutionByIds(ids);
}

@Override
public Institution createPnPgInstitution(String taxId, String description) {
return institutionService.createPnPgInstitution(taxId, description);
}

@Override
public List<GeographicTaxonomies> retrieveInstitutionGeoTaxonomiesByExternalId(String externalId) {
log.info("Retrieving geographic taxonomies for institution having externalId {}", externalId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public interface InstitutionService {

List<Institution> retrieveInstitutionByIds(List<String> ids);

Institution createPnPgInstitution(String taxId, String description);

Institution updateInstitution(String institutionId, InstitutionUpdate institutionUpdate, String userId);

void updateInstitutionDelegation(String institutionId, boolean delegation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
@Service
public class InstitutionServiceImpl implements InstitutionService {


private static final String REQUIRED_INSTITUTION_MESSAGE = "An institution id is required";
private final InstitutionConnector institutionConnector;
private final UserApiConnector userApiConnector;
private final DelegationConnector delegationConnector;
Expand Down Expand Up @@ -211,19 +209,6 @@ public Institution createInstitutionByExternalId(String externalId) {
}
}

@Override
public Institution createPnPgInstitution(String taxId, String description) {
Institution newInstitution = new Institution();
newInstitution.setExternalId(taxId);
newInstitution.setDescription(description);
newInstitution.setInstitutionType(InstitutionType.PG);
newInstitution.setTaxCode(taxId);
newInstitution.setCreatedAt(OffsetDateTime.now());
newInstitution.setOrigin(Origin.INFOCAMERE.getValue());
newInstitution.setOriginId(taxId); //TODO: CHE CAMPO USARE
return institutionConnector.saveOrRetrievePnPg(newInstitution);
}

@Override
public Institution createPgInstitution(String taxId, String description, boolean existsInRegistry, SelfCareUser selfCareUser) {
return institutionConnector.findByExternalId(taxId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,30 +151,6 @@ void testRetrieveInstitutionByIds2() {
verify(institutionService).retrieveInstitutionByIds(any());
}

/**
* Method under test: {@link ExternalServiceImpl#createPnPgInstitution(String, String)}
*/
@Test
void testCreatePnPgInstitution() {
Institution institution = new Institution();
when(institutionService.createPnPgInstitution(any(), any())).thenReturn(institution);
assertSame(institution,
externalServiceImpl.createPnPgInstitution("42", "The characteristics of someone or something"));
verify(institutionService).createPnPgInstitution(any(), any());
}

/**
* Method under test: {@link ExternalServiceImpl#createPnPgInstitution(String, String)}
*/
@Test
void testCreatePnPgInstitution2() {
when(institutionService.createPnPgInstitution(any(), any()))
.thenThrow(new InvalidRequestException("An error occurred", "Code"));
assertThrows(InvalidRequestException.class,
() -> externalServiceImpl.createPnPgInstitution("42", "The characteristics of someone or something"));
verify(institutionService).createPnPgInstitution(any(), any());
}

/**
* Method under test: {@link ExternalServiceImpl#retrieveInstitutionGeoTaxonomiesByExternalId(String)}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,6 @@ void testCreateInstitutionByExternalId6() {
verify(institutionConnector).findByExternalId(any());
}

/**
* Method under test: {@link InstitutionServiceImpl#createPnPgInstitution(String, String)}
*/
@Test
void testCreatePnPgInstitution2() {

when(institutionConnector.saveOrRetrievePnPg(any())).thenAnswer(answer -> answer.getArguments()[0]);

institutionServiceImpl.createPnPgInstitution("42", "The characteristics of someone or something");
verify(institutionConnector).saveOrRetrievePnPg(any());
}

/**
* Method under test: {@link InstitutionServiceImpl#createPgInstitution(String, String, boolean, SelfCareUser)}
*/
Expand Down Expand Up @@ -510,7 +498,6 @@ void testCreatePgInstitution14() {
*/
@Test
void testRetrieveInstitutionProducts() {
PartyRegistryProxyConnector partyRegistryProxyConnector = mock(PartyRegistryProxyConnector.class);
Institution institution = new Institution();
Onboarding onboarding = new Onboarding();
onboarding.setStatus(RelationshipState.PENDING);
Expand Down Expand Up @@ -764,17 +751,6 @@ void testRetrieveInstitutionByIds2() {
verify(institutionConnector).findAllByIds(any());
}

/**
* Method under test: {@link InstitutionServiceImpl#retrieveInstitutionProduct(String, String)}
*/
@Test
void testGetInstitutionProduct() {
Institution institution = new Institution();
when(institutionConnector.findByExternalIdAndProductId(any(), any())).thenReturn(institution);
assertSame(institution, institutionServiceImpl.retrieveInstitutionProduct("42", "42"));
verify(institutionConnector).findByExternalIdAndProductId(any(), any());
}

/**
* Method under test: {@link InstitutionServiceImpl#retrieveInstitutionProduct(String, String)}
*/
Expand Down
Loading

0 comments on commit fe2a1d0

Please sign in to comment.