Skip to content

Commit 9228e9a

Browse files
[SELC-8136] feat: add rea, shareCapital and businessRegisterPlace in createInstitutionFromIpa (#139)
1 parent 9dfe622 commit 9228e9a

File tree

12 files changed

+189
-8
lines changed

12 files changed

+189
-8
lines changed

apps/institution-ms/app/src/main/docs/openapi.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3396,6 +3396,9 @@
33963396
"title" : "InstitutionFromIpaPost",
33973397
"type" : "object",
33983398
"properties" : {
3399+
"businessRegisterPlace" : {
3400+
"type" : "string"
3401+
},
33993402
"geographicTaxonomies" : {
34003403
"type" : "array",
34013404
"items" : {
@@ -3406,6 +3409,12 @@
34063409
"type" : "string",
34073410
"enum" : [ "AS", "CON", "GPU", "GSP", "PA", "PG", "PRV", "PRV_PF", "PSP", "PT", "REC", "SA", "SCEC", "SCP" ]
34083411
},
3412+
"rea" : {
3413+
"type" : "string"
3414+
},
3415+
"shareCapital" : {
3416+
"type" : "string"
3417+
},
34093418
"subunitCode" : {
34103419
"type" : "string"
34113420
},

apps/institution-ms/app/src/test/resources/features/institution.feature

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ Feature: Institution
248248
| attributes[0].code | L6 |
249249
| attributes[0].description | Comuni e loro Consorzi e Associazioni |
250250
And The response body contains field "id"
251+
And The response body doesn't contain field "rea"
252+
And The response body doesn't contain field "shareCapital"
253+
And The response body doesn't contain field "businessRegisterPlace"
251254
# UPDATE
252255
Given User login with username "j.doe" and password "test"
253256
And The following request body:
@@ -292,6 +295,117 @@ Feature: Institution
292295
| attributes[0].code | L6 |
293296
| attributes[0].description | Comuni e loro Consorzi e Associazioni |
294297
And The response body contains field "id"
298+
And The response body doesn't contain field "rea"
299+
And The response body doesn't contain field "shareCapital"
300+
And The response body doesn't contain field "businessRegisterPlace"
301+
302+
@RemoveInstitutionIdAfterScenario
303+
@only
304+
Scenario: Successfully create and update simple institution from IPA with rea, shareCapital and businessRegisterPlace
305+
# CREATE
306+
Given User login with username "j.doe" and password "test"
307+
And The following request body:
308+
"""
309+
{
310+
"taxCode": "00297110389",
311+
"description": "Test description",
312+
"geographicTaxonomies": [
313+
{
314+
"code": "1",
315+
"desc": "first geo"
316+
},
317+
{
318+
"code": "2",
319+
"desc": "second geo"
320+
}
321+
],
322+
"institutionType": "PA",
323+
"supportEmail": "supportmail@test.com",
324+
"supportPhone": "0000000000",
325+
"rea": "RM-12345",
326+
"shareCapital": "9999",
327+
"businessRegisterPlace": "business register place"
328+
}
329+
"""
330+
When I send a POST request to "/institutions/from-ipa"
331+
Then The status code is 201
332+
And The response body contains the list "geographicTaxonomies" of size 2
333+
And The response body contains the list "attributes" of size 1
334+
And The response body contains:
335+
| externalId | 00297110389 |
336+
| taxCode | 00297110389 |
337+
| origin | IPA |
338+
| originId | c_d548 |
339+
| istatCode | 038008 |
340+
| digitalAddress | comune.ferrara@cert.comune.fe.it |
341+
| zipCode | 44121 |
342+
| city | FERRARA |
343+
| county | FE |
344+
| country | IT |
345+
| supportEmail | supportmail@test.com |
346+
| supportPhone | 0000000000 |
347+
| description | Comune di Ferrara |
348+
| rea | RM-12345 |
349+
| shareCapital | 9999 |
350+
| businessRegisterPlace | business register place |
351+
| geographicTaxonomies[0].code | 1 |
352+
| geographicTaxonomies[0].desc | first geo |
353+
| geographicTaxonomies[1].code | 2 |
354+
| geographicTaxonomies[1].desc | second geo |
355+
| attributes[0].origin | IPA |
356+
| attributes[0].code | L6 |
357+
| attributes[0].description | Comuni e loro Consorzi e Associazioni |
358+
And The response body contains field "id"
359+
# UPDATE
360+
Given User login with username "j.doe" and password "test"
361+
And The following request body:
362+
"""
363+
{
364+
"taxCode": "00297110389",
365+
"description": "Test description",
366+
"geographicTaxonomies": [
367+
{
368+
"code": "2",
369+
"desc": "second geo"
370+
}
371+
],
372+
"institutionType": "PA",
373+
"supportEmail": "updatedsupportmail@test.com",
374+
"supportPhone": "1111111111",
375+
"rea": "RM-12346",
376+
"shareCapital": "1000",
377+
"businessRegisterPlace": "business register place 1"
378+
}
379+
"""
380+
When I send a POST request to "/institutions/from-ipa"
381+
Then The status code is 201
382+
And The response body contains the list "geographicTaxonomies" of size 2
383+
And The response body contains the list "attributes" of size 1
384+
And The response body contains:
385+
| externalId | 00297110389 |
386+
| taxCode | 00297110389 |
387+
| origin | IPA |
388+
| originId | c_d548 |
389+
| istatCode | 038008 |
390+
| digitalAddress | comune.ferrara@cert.comune.fe.it |
391+
| zipCode | 44121 |
392+
| city | FERRARA |
393+
| county | FE |
394+
| country | IT |
395+
| supportEmail | updatedsupportmail@test.com |
396+
| supportPhone | 1111111111 |
397+
| description | Comune di Ferrara |
398+
| rea | RM-12346 |
399+
| shareCapital | 1000 |
400+
| businessRegisterPlace | business register place 1 |
401+
| geographicTaxonomies[0].code | 1 |
402+
| geographicTaxonomies[0].desc | first geo |
403+
| geographicTaxonomies[1].code | 2 |
404+
| geographicTaxonomies[1].desc | second geo |
405+
| attributes[0].origin | IPA |
406+
| attributes[0].code | L6 |
407+
| attributes[0].description | Comuni e loro Consorzi e Associazioni |
408+
And The response body contains field "id"
295409

296410
@RemoveSubunitAndParentInstitutionAfterScenario
297411
Scenario: Successfully create and update AOO institution from IPA
@@ -349,6 +463,9 @@ Feature: Institution
349463
| rootParent.description | Comune di Ferrara |
350464
And The response body contains field "id"
351465
And The response body contains field "rootParent.id"
466+
And The response body doesn't contain field "rea"
467+
And The response body doesn't contain field "shareCapital"
468+
And The response body doesn't contain field "businessRegisterPlace"
352469
# UPDATE
353470
Given User login with username "j.doe" and password "test"
354471
And The following request body:
@@ -398,6 +515,9 @@ Feature: Institution
398515
| rootParent.description | Comune di Ferrara |
399516
And The response body contains field "id"
400517
And The response body contains field "rootParent.id"
518+
And The response body doesn't contain field "rea"
519+
And The response body doesn't contain field "shareCapital"
520+
And The response body doesn't contain field "businessRegisterPlace"
401521

402522
@RemoveSubunitAndParentInstitutionAfterScenario
403523
Scenario: Successfully create and update UO institution from IPA
@@ -454,6 +574,9 @@ Feature: Institution
454574
| rootParent.description | Comune di Ferrara |
455575
And The response body contains field "id"
456576
And The response body contains field "rootParent.id"
577+
And The response body doesn't contain field "rea"
578+
And The response body doesn't contain field "shareCapital"
579+
And The response body doesn't contain field "businessRegisterPlace"
457580
# UPDATE
458581
Given User login with username "j.doe" and password "test"
459582
And The following request body:
@@ -504,6 +627,9 @@ Feature: Institution
504627
| rootParent.description | Comune di Ferrara |
505628
And The response body contains field "id"
506629
And The response body contains field "rootParent.id"
630+
And The response body doesn't contain field "rea"
631+
And The response body doesn't contain field "shareCapital"
632+
And The response body doesn't contain field "businessRegisterPlace"
507633

508634
Scenario: Bad request with null taxCode creating institution from IPA
509635
Given User login with username "j.doe" and password "test"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package it.pagopa.selfcare.mscore.model.institution;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
@Data
9+
@Builder
10+
@AllArgsConstructor
11+
@NoArgsConstructor
12+
public class InstitutionAdditionalInfoForIpa {
13+
private String rea;
14+
private String shareCapital;
15+
private String businessRegisterPlace;
16+
}

apps/institution-ms/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface InstitutionService {
2525

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

28-
Institution createInstitutionFromIpa(String taxCode, InstitutionPaSubunitType subunitType, String subunitCode, List<InstitutionGeographicTaxonomies> geographicTaxonomies, String supportEmail, String supportPhone);
28+
Institution createInstitutionFromIpa(String taxCode, InstitutionPaSubunitType subunitType, String subunitCode, List<InstitutionGeographicTaxonomies> geographicTaxonomies, String supportEmail, String supportPhone, InstitutionAdditionalInfoForIpa additionalInfoForIpa);
2929

3030
Institution createInstitutionFromPda(Institution institution, String injectionInstitutionType);
3131

apps/institution-ms/core/src/main/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public List<Institution> getInstitutions(String taxCode, String subunitCode, Str
113113
}
114114

115115
@Override
116-
public Institution createInstitutionFromIpa(String taxCode, InstitutionPaSubunitType subunitType, String subunitCode, List<InstitutionGeographicTaxonomies> geographicTaxonomies, String supportEmail, String supportPhone) {
116+
public Institution createInstitutionFromIpa(String taxCode, InstitutionPaSubunitType subunitType, String subunitCode, List<InstitutionGeographicTaxonomies> geographicTaxonomies, String supportEmail, String supportPhone, InstitutionAdditionalInfoForIpa additionalInfoForIpa) {
117117
CreateInstitutionStrategy institutionStrategy = createInstitutionStrategyFactory.createInstitutionStrategyIpa();
118118
return institutionStrategy.createInstitution(CreateInstitutionStrategyInput.builder()
119119
.taxCode(taxCode)
@@ -122,6 +122,9 @@ public Institution createInstitutionFromIpa(String taxCode, InstitutionPaSubunit
122122
.geographicTaxonomies(geographicTaxonomies)
123123
.supportEmail(supportEmail)
124124
.supportPhone(supportPhone)
125+
.rea(additionalInfoForIpa.getRea())
126+
.shareCapital(additionalInfoForIpa.getShareCapital())
127+
.businessRegisterPlace(additionalInfoForIpa.getBusinessRegisterPlace())
125128
.build());
126129
}
127130

apps/institution-ms/core/src/main/java/it/pagopa/selfcare/mscore/core/strategy/CreateInstitutionStrategyCommon.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ protected static void setContacts(CreateInstitutionStrategyInput strategyInput,
6060
}
6161
}
6262

63+
protected static void setAdditionalDataForIpa(CreateInstitutionStrategyInput strategyInput, Institution toSavedOrUpdate) {
64+
if (strategyInput.getRea() != null) {
65+
toSavedOrUpdate.setRea(strategyInput.getRea());
66+
}
67+
68+
if (strategyInput.getShareCapital() != null) {
69+
toSavedOrUpdate.setShareCapital(strategyInput.getShareCapital());
70+
}
71+
72+
if (strategyInput.getBusinessRegisterPlace() != null) {
73+
toSavedOrUpdate.setBusinessRegisterPlace(strategyInput.getBusinessRegisterPlace());
74+
}
75+
}
76+
6377

6478

6579

apps/institution-ms/core/src/main/java/it/pagopa/selfcare/mscore/core/strategy/CreateInstitutionStrategyIpa.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ public Institution createInstitution(CreateInstitutionStrategyInput strategyInpu
6161
}
6262
toSavedOrUpdate.setGeographicTaxonomies(strategyInput.getGeographicTaxonomies());
6363
setContacts(strategyInput, toSavedOrUpdate);
64-
64+
setAdditionalDataForIpa(strategyInput, toSavedOrUpdate);
6565
} else {
6666
//Institution exists but other fields could be updated
6767
toSavedOrUpdate = institutions.get(0);
6868
setUpdatedFields(strategyInput, institutions.get(0));
69+
setAdditionalDataForIpa(strategyInput, toSavedOrUpdate);
6970
}
7071

7172
try {

apps/institution-ms/core/src/main/java/it/pagopa/selfcare/mscore/core/strategy/input/CreateInstitutionStrategyInput.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ public class CreateInstitutionStrategyInput {
2121
private String supportPhone;
2222
private String istatCode;
2323
private String legalForm;
24+
private String rea;
25+
private String shareCapital;
26+
private String businessRegisterPlace;
2427
}

apps/institution-ms/core/src/test/java/it/pagopa/selfcare/mscore/core/InstitutionServiceImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,13 @@ void testGetInstitutionsFails() {
359359
}
360360

361361
/**
362-
* Method under test: {@link InstitutionServiceImpl#createInstitutionFromIpa(String, InstitutionPaSubunitType, String, List, String, String)}
362+
* Method under test: {@link InstitutionServiceImpl#createInstitutionFromIpa(String, InstitutionPaSubunitType, String, List, String, String, InstitutionAdditionalInfoForIpa)}
363363
*/
364364
@Test
365365
void testCreateInstitutionFromIpa() {
366366
when(createInstitutionStrategyFactory.createInstitutionStrategyIpa()).thenReturn(createInstitutionStrategy);
367367
when(createInstitutionStrategy.createInstitution(any())).thenReturn(new Institution());
368-
Institution institution = institutionServiceImpl.createInstitutionFromIpa("id", InstitutionPaSubunitType.AOO,"id", List.of(), "email", "phone");
368+
Institution institution = institutionServiceImpl.createInstitutionFromIpa("id", InstitutionPaSubunitType.AOO,"id", List.of(), "email", "phone", new InstitutionAdditionalInfoForIpa());
369369
assertNotNull(institution);
370370
}
371371

apps/institution-ms/web/src/main/java/it/pagopa/selfcare/mscore/web/controller/InstitutionController.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,15 @@ public ResponseEntity<InstitutionResponse> createInstitutionFromIpa(@RequestBody
135135
.map(geoTaxonomies -> geoTaxonomies.stream().map(institutionResourceMapper::toInstitutionGeographicTaxonomies).toList())
136136
.orElse(List.of());
137137

138+
InstitutionAdditionalInfoForIpa additionalInfoForIpa = InstitutionAdditionalInfoForIpa.builder()
139+
.rea(institutionFromIpaPost.getRea())
140+
.shareCapital(institutionFromIpaPost.getShareCapital())
141+
.businessRegisterPlace(institutionFromIpaPost.getBusinessRegisterPlace())
142+
.build();
143+
138144
Institution saved = institutionService.createInstitutionFromIpa(institutionFromIpaPost.getTaxCode(),
139145
institutionFromIpaPost.getSubunitType(), institutionFromIpaPost.getSubunitCode(), geographicTaxonomies,
140-
institutionFromIpaPost.getSupportEmail(), institutionFromIpaPost.getSupportPhone());
146+
institutionFromIpaPost.getSupportEmail(), institutionFromIpaPost.getSupportPhone(), additionalInfoForIpa);
141147
return ResponseEntity.status(HttpStatus.CREATED).body(institutionResourceMapper.toInstitutionResponse(saved));
142148
}
143149

0 commit comments

Comments
 (0)