Skip to content

Commit

Permalink
[SELC-5807] feat: Added fields for PSP template
Browse files Browse the repository at this point in the history
  • Loading branch information
giampieroferrara authored Nov 19, 2024
1 parent c828a22 commit a253eff
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package it.pagopa.selfcare.onboarding.utils;

import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_IO;
import static it.pagopa.selfcare.onboarding.utils.GenericError.MANAGER_EMAIL_NOT_FOUND;

import it.pagopa.selfcare.onboarding.common.InstitutionType;
import it.pagopa.selfcare.onboarding.common.Origin;
import it.pagopa.selfcare.onboarding.common.PricingPlan;
import it.pagopa.selfcare.onboarding.entity.*;
import it.pagopa.selfcare.onboarding.exception.GenericOnboardingException;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.openapi.quarkus.user_registry_json.model.CertifiableFieldResourceOfstring;
import org.openapi.quarkus.user_registry_json.model.UserResource;

import java.util.*;

import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_IO;
import static it.pagopa.selfcare.onboarding.utils.GenericError.MANAGER_EMAIL_NOT_FOUND;


public class PdfMapper {

private static final String UNDERSCORE = "_______________";
Expand Down Expand Up @@ -105,6 +103,8 @@ public static void setupPSPData(Map<String, Object> map, UserResource validManag
map.put("legalRegisterNumber", institution.getPaymentServiceProvider().getLegalRegisterNumber());
map.put("legalRegisterName", institution.getPaymentServiceProvider().getLegalRegisterName());
map.put("vatNumberGroup", institution.getPaymentServiceProvider().isVatNumberGroup() ? "partita iva di gruppo" : "");
map.put("vatNumberGroupCheckbox1", institution.getPaymentServiceProvider().isVatNumberGroup()? "X" : "");
map.put("vatNumberGroupCheckbox2", !institution.getPaymentServiceProvider().isVatNumberGroup()? "X" : "");
map.put("institutionRegister", institution.getPaymentServiceProvider().getBusinessRegisterNumber());
map.put("institutionAbi", institution.getPaymentServiceProvider().getAbiCode());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package it.pagopa.selfcare.onboarding.utils;

import static org.junit.jupiter.api.Assertions.assertEquals;

import it.pagopa.selfcare.onboarding.common.InstitutionType;
import it.pagopa.selfcare.onboarding.common.PartyRole;
import it.pagopa.selfcare.onboarding.entity.Institution;
import it.pagopa.selfcare.onboarding.entity.Onboarding;
import it.pagopa.selfcare.onboarding.entity.User;
import java.util.List;
import java.util.UUID;
import org.junit.jupiter.api.Test;

public class InstitutionUtilsTest {

@Test
void getCurrentInstitutionTypeTest() {
// given
Onboarding onboarding = createDummyOnboarding();

// when
String result = InstitutionUtils.getCurrentInstitutionType(onboarding);

// then
assertEquals("PSP", result);
}

@Test
void getCurrentInstitutionTypeTest_shouldReturnDefault_whenInstitutionTypeIsNull() {
// given
Onboarding onboarding = createDummyOnboarding();
onboarding.getInstitution().setInstitutionType(null);

// when
String result = InstitutionUtils.getCurrentInstitutionType(onboarding);

// then
assertEquals("default", result);
}

@Test
void getCurrentInstitutionTypeTest_shouldReturnDefault_whenInstitutionIsNotNull() {
// given
Onboarding onboarding = createDummyOnboarding();
onboarding.setInstitution(new Institution());
// when
String result = InstitutionUtils.getCurrentInstitutionType(onboarding);

// then
assertEquals("default", result);
}

@Test
void getCurrentInstitutionTypeTest_shouldReturnDefault_whenInstitutionIsNull() {
// given
Onboarding onboarding = createDummyOnboarding();
onboarding.setInstitution(null);
// when
String result = InstitutionUtils.getCurrentInstitutionType(onboarding);

// then
assertEquals("default", result);
}

private Onboarding createDummyOnboarding() {
Onboarding onboarding = new Onboarding();
onboarding.setId(UUID.randomUUID().toString());
onboarding.setProductId("prod-pagopa");

Institution institution = new Institution();
institution.setTaxCode("taxCode");
institution.setSubunitCode("subunitCode");
institution.setInstitutionType(InstitutionType.PSP);
onboarding.setInstitution(institution);

User user = new User();
user.setId("actual-user-id");
user.setRole(PartyRole.MANAGER);
onboarding.setUsers(List.of(user));
return onboarding;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class InstitutionUtils {
public static String getCurrentInstitutionType(Onboarding onboarding) {
String institutionType = Product.CONTRACT_TYPE_DEFAULT;

if (Objects.nonNull(onboarding.getInstitution().getInstitutionType())) {
if (Objects.nonNull(onboarding.getInstitution())
&& Objects.nonNull(onboarding.getInstitution().getInstitutionType())) {
institutionType = onboarding.getInstitution().getInstitutionType().name();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void getCurrentInstitutionTypeTest() {
// then
assertEquals("PSP", result);
}

@Test
void getCurrentInstitutionTypeTest_shouldReturnDefault_whenInstitutionTypeIsNull() {
// given
Expand All @@ -38,6 +38,30 @@ void getCurrentInstitutionTypeTest_shouldReturnDefault_whenInstitutionTypeIsNull
assertEquals("default", result);
}

@Test
void getCurrentInstitutionTypeTest_shouldReturnDefault_whenInstitutionIsNotNull() {
// given
Onboarding onboarding = createDummyOnboarding();
onboarding.setInstitution(new Institution());
// when
String result = InstitutionUtils.getCurrentInstitutionType(onboarding);

// then
assertEquals("default", result);
}

@Test
void getCurrentInstitutionTypeTest_shouldReturnDefault_whenInstitutionIsNull() {
// given
Onboarding onboarding = createDummyOnboarding();
onboarding.setInstitution(null);
// when
String result = InstitutionUtils.getCurrentInstitutionType(onboarding);

// then
assertEquals("default", result);
}

private Onboarding createDummyOnboarding() {
Onboarding onboarding = new Onboarding();
onboarding.setId(UUID.randomUUID().toString());
Expand Down

0 comments on commit a253eff

Please sign in to comment.