From fe2a1d02075b034eaac1949c83daa65795ea2a4f Mon Sep 17 00:00:00 2001 From: flaminiaScarciofolo <113031535+flaminiaScarciofolo@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:32:54 +0200 Subject: [PATCH] [SELC-5022] Feat: Removed /external/institution/pn-pg API and related methods (#511) --- app/src/main/resources/swagger/api-docs.json | 83 ------------ .../mscore/api/InstitutionConnector.java | 2 - .../dao/InstitutionConnectorImpl.java | 7 - .../dao/InstitutionConnectorImplTest.java | 120 ------------------ .../selfcare/mscore/core/ExternalService.java | 2 - .../mscore/core/ExternalServiceImpl.java | 5 - .../mscore/core/InstitutionService.java | 2 - .../mscore/core/InstitutionServiceImpl.java | 15 --- .../mscore/core/ExternalServiceImplTest.java | 24 ---- .../core/InstitutionServiceImplTest.java | 24 ---- .../web/controller/ExternalController.java | 21 --- .../CreatePnPgInstitutionRequest.java | 15 --- .../institution/InstitutionPnPgResponse.java | 15 --- .../controller/ExternalControllerTest.java | 25 ---- 14 files changed, 360 deletions(-) delete mode 100644 web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/CreatePnPgInstitutionRequest.java delete mode 100644 web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/InstitutionPnPgResponse.java diff --git a/app/src/main/resources/swagger/api-docs.json b/app/src/main/resources/swagger/api-docs.json index 6ac305111..d584a9dcf 100644 --- a/app/src/main/resources/swagger/api-docs.json +++ b/app/src/main/resources/swagger/api-docs.json @@ -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" ], @@ -2720,18 +2658,6 @@ } } }, - "CreatePnPgInstitutionRequest" : { - "title" : "CreatePnPgInstitutionRequest", - "type" : "object", - "properties" : { - "description" : { - "type" : "string" - }, - "taxId" : { - "type" : "string" - } - } - }, "CreatedAtRequest" : { "title" : "CreatedAtRequest", "type" : "object", @@ -3199,15 +3125,6 @@ } } }, - "InstitutionPnPgResponse" : { - "title" : "InstitutionPnPgResponse", - "type" : "object", - "properties" : { - "id" : { - "type" : "string" - } - } - }, "InstitutionProduct" : { "title" : "InstitutionProduct", "type" : "object", diff --git a/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/InstitutionConnector.java b/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/InstitutionConnector.java index b12ce6a19..d5059d409 100644 --- a/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/InstitutionConnector.java +++ b/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/InstitutionConnector.java @@ -46,8 +46,6 @@ public interface InstitutionConnector { List findAllByIds(List ids); - Institution saveOrRetrievePnPg(Institution newInstitution); - List findByExternalIdsAndProductId(List externalIds, String productId); Institution updateOnboardedProductCreatedAt(String institutionId, String productId, OffsetDateTime createdAt); diff --git a/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/InstitutionConnectorImpl.java b/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/InstitutionConnectorImpl.java index f1f8a6787..3a6a4cd72 100644 --- a/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/InstitutionConnectorImpl.java +++ b/connector/dao/src/main/java/it/pagopa/selfcare/mscore/connector/dao/InstitutionConnectorImpl.java @@ -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 findByExternalIdsAndProductId(List validInstitutionList, String productId) { List externalIds = validInstitutionList.stream().map(ValidInstitution::getId).collect(Collectors.toList()); diff --git a/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/InstitutionConnectorImplTest.java b/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/InstitutionConnectorImplTest.java index 0f14c679e..63171c8d6 100644 --- a/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/InstitutionConnectorImplTest.java +++ b/connector/dao/src/test/java/it/pagopa/selfcare/mscore/connector/dao/InstitutionConnectorImplTest.java @@ -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 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 = 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)} */ diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/ExternalService.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/ExternalService.java index 9fe312e2c..1ae140876 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/ExternalService.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/ExternalService.java @@ -18,6 +18,4 @@ public interface ExternalService { List retrieveInstitutionProductsByExternalId(String externalId, List states); List retrieveInstitutionByIds(List ids); - - Institution createPnPgInstitution(String taxId, String description); } diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/ExternalServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/ExternalServiceImpl.java index f9a475b69..0e74f4947 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/ExternalServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/ExternalServiceImpl.java @@ -40,11 +40,6 @@ public List retrieveInstitutionByIds(List ids) { return institutionService.retrieveInstitutionByIds(ids); } - @Override - public Institution createPnPgInstitution(String taxId, String description) { - return institutionService.createPnPgInstitution(taxId, description); - } - @Override public List retrieveInstitutionGeoTaxonomiesByExternalId(String externalId) { log.info("Retrieving geographic taxonomies for institution having externalId {}", externalId); 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 97d973ea5..7a1e1faf1 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 @@ -55,8 +55,6 @@ public interface InstitutionService { List retrieveInstitutionByIds(List ids); - Institution createPnPgInstitution(String taxId, String description); - Institution updateInstitution(String institutionId, InstitutionUpdate institutionUpdate, String userId); void updateInstitutionDelegation(String institutionId, boolean delegation); 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 b64e2e0de..6a9b03b9a 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 @@ -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; @@ -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) diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/ExternalServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/ExternalServiceImplTest.java index f278c558b..fe5732cf9 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/ExternalServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/ExternalServiceImplTest.java @@ -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)} */ 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 56c0a8c3b..ecf19a0c1 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 @@ -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)} */ @@ -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); @@ -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)} */ diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ExternalController.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ExternalController.java index b3c5edc74..0dfc5ce60 100644 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ExternalController.java +++ b/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/ExternalController.java @@ -8,9 +8,7 @@ import it.pagopa.selfcare.mscore.model.institution.GeographicTaxonomies; import it.pagopa.selfcare.mscore.model.institution.Institution; import it.pagopa.selfcare.mscore.model.institution.Onboarding; -import it.pagopa.selfcare.mscore.web.model.institution.CreatePnPgInstitutionRequest; import it.pagopa.selfcare.mscore.web.model.institution.InstitutionBillingResponse; -import it.pagopa.selfcare.mscore.web.model.institution.InstitutionPnPgResponse; import it.pagopa.selfcare.mscore.web.model.institution.InstitutionResponse; import it.pagopa.selfcare.mscore.web.model.mapper.InstitutionMapperCustom; import it.pagopa.selfcare.mscore.web.model.mapper.InstitutionResourceMapper; @@ -22,7 +20,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; import java.util.List; import java.util.stream.Collectors; @@ -128,24 +125,6 @@ public ResponseEntity> retrieveInstitutionGeoTaxonomi return ResponseEntity.ok(list); } - /** - * The function persist PG institution - * - * @param request CreatePnPgInstitutionRequest - * @return InstitutionPnPgResponse - * - * * Code: 201, Message: successful operation, DataType: InstitutionPnPgResponse - * * Code: 400, Message: Bad Request, DataType: Problem - */ - @ResponseStatus(HttpStatus.CREATED) - @ApiOperation(value = "${swagger.mscore.institution.PG.create}", notes = "${swagger.mscore.institution.PG.create}") - @PostMapping(value = "/pn-pg", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity createPnPgInstitution(@RequestBody @Valid CreatePnPgInstitutionRequest request) { - CustomExceptionMessage.setCustomMessage(CREATE_INSTITUTION_ERROR); - Institution saved = externalService.createPnPgInstitution(request.getTaxId(), request.getDescription()); - return ResponseEntity.status(HttpStatus.CREATED).body(new InstitutionPnPgResponse(saved.getId())); - } - /** * The function return an institution given institution internal id * diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/CreatePnPgInstitutionRequest.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/CreatePnPgInstitutionRequest.java deleted file mode 100644 index 52010ae12..000000000 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/CreatePnPgInstitutionRequest.java +++ /dev/null @@ -1,15 +0,0 @@ -package it.pagopa.selfcare.mscore.web.model.institution; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Data -public class CreatePnPgInstitutionRequest { - - @NotEmpty(message = "taxId is required") - private String taxId; - - private String description; - -} diff --git a/web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/InstitutionPnPgResponse.java b/web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/InstitutionPnPgResponse.java deleted file mode 100644 index d3108b7ac..000000000 --- a/web/src/main/java/it/pagopa/selfcare/mscore/web/model/institution/InstitutionPnPgResponse.java +++ /dev/null @@ -1,15 +0,0 @@ -package it.pagopa.selfcare.mscore.web.model.institution; - -import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@JsonInclude(JsonInclude.Include.NON_NULL) -@AllArgsConstructor -@NoArgsConstructor -public class InstitutionPnPgResponse { - - private String id; -} diff --git a/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/ExternalControllerTest.java b/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/ExternalControllerTest.java index ddfadd13f..1a72041b8 100644 --- a/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/ExternalControllerTest.java +++ b/web/src/test/java/it/pagopa/selfcare/mscore/web/controller/ExternalControllerTest.java @@ -1,11 +1,9 @@ package it.pagopa.selfcare.mscore.web.controller; -import com.fasterxml.jackson.databind.ObjectMapper; import it.pagopa.selfcare.commons.base.utils.InstitutionType; import it.pagopa.selfcare.mscore.constant.RelationshipState; import it.pagopa.selfcare.mscore.core.ExternalService; import it.pagopa.selfcare.mscore.model.institution.*; -import it.pagopa.selfcare.mscore.web.model.institution.CreatePnPgInstitutionRequest; import it.pagopa.selfcare.mscore.web.model.mapper.InstitutionResourceMapper; import it.pagopa.selfcare.mscore.web.model.mapper.InstitutionResourceMapperImpl; import org.junit.jupiter.api.Test; @@ -14,7 +12,6 @@ import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.http.MediaType; import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; @@ -162,28 +159,6 @@ void testRetrieveInstitutionGeoTaxonomiesByExternalId() throws Exception { } - /** - * Method under test: {@link ExternalController#createPnPgInstitution(CreatePnPgInstitutionRequest)} - */ - @Test - void testCreatePnPgInstitution() throws Exception { - when(externalService.createPnPgInstitution(any(), any())).thenReturn(new Institution()); - - CreatePnPgInstitutionRequest createPnPgInstitutionRequest = new CreatePnPgInstitutionRequest(); - createPnPgInstitutionRequest.setDescription("The characteristics of someone or something"); - createPnPgInstitutionRequest.setTaxId("42"); - String content = (new ObjectMapper()).writeValueAsString(createPnPgInstitutionRequest); - MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.post("/external/institutions/pn-pg") - .contentType(MediaType.APPLICATION_JSON) - .content(content); - ResultActions actualPerformResult = MockMvcBuilders.standaloneSetup(externalController) - .build() - .perform(requestBuilder); - actualPerformResult.andExpect(MockMvcResultMatchers.status().isCreated()) - .andExpect(MockMvcResultMatchers.content().contentType("application/json")) - .andExpect(MockMvcResultMatchers.content().string("{}")); - } - /** * Method under test: {@link ExternalController#getBillingInstitutionByExternalId(String, String)} */