diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtils.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtils.java deleted file mode 100644 index a86c7a469..000000000 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtils.java +++ /dev/null @@ -1,177 +0,0 @@ -package it.pagopa.selfcare.mscore.core.util; - -import it.pagopa.selfcare.commons.base.security.PartyRole; -import it.pagopa.selfcare.commons.base.utils.InstitutionType; -import it.pagopa.selfcare.commons.base.utils.Origin; -import it.pagopa.selfcare.mscore.constant.CustomError; -import it.pagopa.selfcare.mscore.constant.Env; -import it.pagopa.selfcare.mscore.constant.RelationshipState; -import it.pagopa.selfcare.mscore.exception.InvalidRequestException; -import it.pagopa.selfcare.mscore.exception.ResourceConflictException; -import it.pagopa.selfcare.mscore.model.institution.Billing; -import it.pagopa.selfcare.mscore.model.institution.Institution; -import it.pagopa.selfcare.mscore.model.institution.InstitutionUpdate; -import it.pagopa.selfcare.mscore.model.institution.Onboarding; -import it.pagopa.selfcare.mscore.model.onboarding.OnboardedProduct; -import it.pagopa.selfcare.mscore.model.onboarding.OnboardingRequest; -import it.pagopa.selfcare.mscore.model.user.UserToOnboard; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; - -import java.time.OffsetDateTime; -import java.util.*; -import java.util.stream.Collectors; - -import static it.pagopa.selfcare.mscore.constant.CustomError.ONBOARDING_INVALID_UPDATES; -import static it.pagopa.selfcare.mscore.core.util.UtilEnumList.PRODUCT_RELATIONSHIP_STATES; - -@Slf4j -@NoArgsConstructor(access = AccessLevel.NONE) -public class OnboardingInstitutionUtils { - - public static void checkIfProductAlreadyOnboarded(Institution institution, String productId) { - log.info("START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}", institution.getExternalId(), productId); - if (institution.getOnboarding() != null) { - Optional optionalOnboarding = institution.getOnboarding().stream() - .filter(onboarding -> productId.equalsIgnoreCase(onboarding.getProductId()) - && RelationshipState.ACTIVE == onboarding.getStatus()) - .findAny(); - if (optionalOnboarding.isPresent() && !PRODUCT_RELATIONSHIP_STATES.contains(optionalOnboarding.get().getStatus())) { - throw new ResourceConflictException(String.format(CustomError.PRODUCT_ALREADY_ONBOARDED.getMessage(), productId, institution.getExternalId()), CustomError.PRODUCT_ALREADY_ONBOARDED.getCode()); - } - } - log.info("END - checkIfProductAlreadyOnboarded without error"); - } - - public static void validateOnboarding(Billing billing, boolean checkRecipientCode) { - if (billing == null - || StringUtils.isEmpty(billing.getVatNumber()) - || (checkRecipientCode && StringUtils.isEmpty(billing.getRecipientCode()))) { - throw new InvalidRequestException(CustomError.ONBOARDING_BILLING_ERROR.getCode(), CustomError.ONBOARDING_BILLING_ERROR.getMessage()); - } - } - - public static void validateOverridingData(InstitutionUpdate institutionUpdate, Institution institution) { - log.info("START - validateOverridingData for institution having externalId: {} and origin: {}", institution.getExternalId(), institution.getOrigin()); - if (Origin.IPA.getValue().equalsIgnoreCase(institution.getOrigin())) { - validateIpaOverriding(institutionUpdate, institution); - } else if (!Origin.INFOCAMERE.getValue().equalsIgnoreCase(institution.getOrigin())) { - validateDefaultOverriding(institutionUpdate, institution); - } - - log.info("END - validateOverridingData without error"); - } - - private static void validateIpaOverriding(InstitutionUpdate institutionUpdate, Institution institution) { - if (isInvalidOverride(institution.getDescription(), institutionUpdate.getDescription()) - || isInvalidOverride(institution.getTaxCode(), institutionUpdate.getTaxCode()) - || isInvalidOverride(institution.getDigitalAddress(), institutionUpdate.getDigitalAddress()) - || isInvalidOverride(institution.getZipCode(), institutionUpdate.getZipCode()) - || isInvalidOverride(institution.getAddress(), institutionUpdate.getAddress()) - ) { - throw new InvalidRequestException(String.format(ONBOARDING_INVALID_UPDATES.getMessage(), institution.getExternalId()), ONBOARDING_INVALID_UPDATES.getCode()); - } - } - - private static void validateDefaultOverriding(InstitutionUpdate institutionUpdate, Institution institution) { - if (isInvalidOverride(institution.getDigitalAddress(), institutionUpdate.getDigitalAddress())) { - throw new InvalidRequestException(String.format(ONBOARDING_INVALID_UPDATES.getMessage(), institution.getExternalId()), ONBOARDING_INVALID_UPDATES.getCode()); - } - } - - private static boolean isInvalidOverride(String startValue, String toValue) { - if (!StringUtils.isEmpty(startValue) && !StringUtils.isEmpty(toValue)) { - return !startValue.equalsIgnoreCase(toValue); - } - return StringUtils.isEmpty(startValue) && !StringUtils.isEmpty(toValue); - } - - public static RelationshipState getStatus(InstitutionUpdate institutionUpdate, InstitutionType institutionType, String institutionOrigin, String productId) { - if (Objects.nonNull(institutionUpdate) && Objects.nonNull(institutionUpdate.getInstitutionType())) { - return getStatusByInstitutionType(institutionUpdate.getInstitutionType(), productId, institutionOrigin); - } - - if (Objects.nonNull(institutionType)) { - return getStatusByInstitutionType(institutionType, productId, institutionOrigin); - } - - return null; - } - - private static RelationshipState getStatusByInstitutionType(InstitutionType institutionType, String productId, String institutionOrigin) { - switch (institutionType) { - case PA: - case SA: - case AS: - return RelationshipState.PENDING; - case PG: - return RelationshipState.ACTIVE; - default: - if (InstitutionType.GSP == institutionType && "prod-interop".equals(productId) && "IPA".equals(institutionOrigin)) { - return RelationshipState.PENDING; - } - return RelationshipState.TOBEVALIDATED; - - } - } - - public static void verifyUsers(List users, List role) { - List userList = new ArrayList<>(); - users.forEach(onboardedUser -> { - if (!role.contains(onboardedUser.getRole())) { - userList.add(onboardedUser); - } - }); - if (!userList.isEmpty()) { - List userRoleList = userList.stream().map(UserToOnboard::getRole).collect(Collectors.toList()); - throw new InvalidRequestException(String.format(CustomError.ROLES_NOT_ADMITTED_ERROR.getMessage(), StringUtils.join(userRoleList, ", ")), CustomError.ROLES_NOT_ADMITTED_ERROR.getCode()); - } - } - - public static String getValidManagerId(List users) { - log.debug("START - getOnboardingValidManager for users list size: {}", users.size()); - - return users.stream() - .filter(userToOnboard -> PartyRole.MANAGER == userToOnboard.getRole()) - .map(UserToOnboard::getId) - .findAny() - .orElseThrow(() -> new InvalidRequestException(CustomError.MANAGER_NOT_FOUND_GENERIC_ERROR.getMessage(), - CustomError.MANAGER_NOT_FOUND_GENERIC_ERROR.getCode())); - } - - public static OnboardedProduct constructOperatorProduct(UserToOnboard user, String productId) { - OnboardedProduct onboardedProduct = new OnboardedProduct(); - onboardedProduct.setRelationshipId(UUID.randomUUID().toString()); - onboardedProduct.setProductId(productId); - onboardedProduct.setRole(user.getRole()); - onboardedProduct.setProductRole(user.getProductRole()); - onboardedProduct.setStatus(RelationshipState.ACTIVE); - onboardedProduct.setCreatedAt(OffsetDateTime.now()); - if (user.getEnv() != null) { - onboardedProduct.setEnv(user.getEnv()); - } else { - onboardedProduct.setEnv(Env.ROOT); - } - return onboardedProduct; - } - - public static OnboardedProduct constructProduct(UserToOnboard userToOnboard, OnboardingRequest request, Institution institution) { - OnboardedProduct onboardedProduct = new OnboardedProduct(); - onboardedProduct.setRelationshipId(UUID.randomUUID().toString()); - onboardedProduct.setProductId(request.getProductId()); - onboardedProduct.setRole(userToOnboard.getRole()); - onboardedProduct.setProductRole(userToOnboard.getProductRole()); - onboardedProduct.setStatus(getStatus(request.getInstitutionUpdate(), - institution.getInstitutionType(), institution.getOrigin(), request.getProductId())); - - onboardedProduct.setCreatedAt(OffsetDateTime.now()); - onboardedProduct.setUpdatedAt(OffsetDateTime.now()); - if (userToOnboard.getEnv() != null) { - onboardedProduct.setEnv(userToOnboard.getEnv()); - } - return onboardedProduct; - } - -} diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/util/PdfMapper.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/util/PdfMapper.java deleted file mode 100644 index a1515f57f..000000000 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/util/PdfMapper.java +++ /dev/null @@ -1,222 +0,0 @@ -package it.pagopa.selfcare.mscore.core.util; - -import it.pagopa.selfcare.commons.base.utils.InstitutionType; -import it.pagopa.selfcare.mscore.constant.Origin; -import it.pagopa.selfcare.mscore.constant.PricingPlan; -import it.pagopa.selfcare.mscore.exception.InvalidRequestException; -import it.pagopa.selfcare.mscore.model.institution.Institution; -import it.pagopa.selfcare.mscore.model.institution.InstitutionGeographicTaxonomies; -import it.pagopa.selfcare.mscore.model.institution.InstitutionUpdate; -import it.pagopa.selfcare.mscore.model.onboarding.OnboardingRequest; -import it.pagopa.selfcare.mscore.model.user.User; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.util.StringUtils; - -import java.util.*; -import java.util.stream.Collectors; - -import static it.pagopa.selfcare.mscore.constant.GenericError.MANAGER_EMAIL_NOT_FOUND; -import static it.pagopa.selfcare.mscore.constant.ProductId.PROD_IO; -import static it.pagopa.selfcare.mscore.core.util.Constants.*; - -@Slf4j -@NoArgsConstructor(access = AccessLevel.NONE) -public class PdfMapper { - - private static final String[] PLAN_LIST = {"C1", "C2", "C3", "C4", "C5", "C6", "C7"}; - - public static Map setUpCommonData(User validManager, List users, Institution institution, OnboardingRequest request, List geographicTaxonomies, InstitutionType institutionType) { - log.info("START - setupCommonData"); - if (validManager.getWorkContacts() != null && validManager.getWorkContacts().containsKey(institution.getId())) { - Map map = new HashMap<>(); - map.put("institutionName", institution.getDescription()); - map.put("address", institution.getAddress()); - map.put("institutionTaxCode", institution.getTaxCode()); - map.put("zipCode", institution.getZipCode()); - map.put("managerName", validManager.getName()); - map.put("managerSurname", validManager.getFamilyName()); - map.put("originId", institution.getOriginId() != null ? institution.getOriginId() : ""); - map.put("institutionMail", institution.getDigitalAddress()); - map.put("managerTaxCode", validManager.getFiscalCode()); - map.put("managerEmail", validManager.getWorkContacts().get(institution.getId()).getEmail()); - map.put("delegates", delegatesToText(users, institution.getId())); - map.put("institutionType", decodeInstitutionType(institutionType)); - if (request.getBillingRequest() != null) { - map.put("institutionVatNumber", request.getBillingRequest().getVatNumber()); - } else { - map.put("institutionVatNumber", ""); - } - if (geographicTaxonomies != null && !geographicTaxonomies.isEmpty()) { - map.put("institutionGeoTaxonomies", geographicTaxonomies.stream().map(InstitutionGeographicTaxonomies::getDesc).collect(Collectors.toList())); - } - if(institution.getSubunitType() != null && (institution.getSubunitType().equals(InstitutionPaSubunitType.AOO.name()) || institution.getSubunitType().equals(InstitutionPaSubunitType.UO.name()))){ - map.put("parentInfo", " ente centrale " + institution.getParentDescription()); - } else { - map.put("parentInfo", ""); - } - return map; - } else { - throw new InvalidRequestException(MANAGER_EMAIL_NOT_FOUND.getMessage(), MANAGER_EMAIL_NOT_FOUND.getCode()); - } - } - - public static void setupPSPData(Map map, User validManager, Institution institution) { - log.info("START - setupPSPData"); - if (institution.getPaymentServiceProvider() != null) { - map.put("legalRegisterNumber", institution.getPaymentServiceProvider().getLegalRegisterNumber()); - map.put("legalRegisterName", institution.getPaymentServiceProvider().getLegalRegisterName()); - map.put("vatNumberGroup", institution.getPaymentServiceProvider().isVatNumberGroup() ? "partita iva di gruppo" : ""); - map.put("institutionRegister", institution.getPaymentServiceProvider().getBusinessRegisterNumber()); - map.put("institutionAbi", institution.getPaymentServiceProvider().getAbiCode()); - } - if (institution.getDataProtectionOfficer() != null) { - map.put("dataProtectionOfficerAddress", institution.getDataProtectionOfficer().getAddress()); - map.put("dataProtectionOfficerEmail", institution.getDataProtectionOfficer().getEmail()); - map.put("dataProtectionOfficerPec", institution.getDataProtectionOfficer().getPec()); - } - if (validManager.getWorkContacts() != null && validManager.getWorkContacts().containsKey(institution.getId())) { - map.put("managerPEC", validManager.getWorkContacts().get(institution.getId()).getEmail()); - } - } - - public static void setupProdIOData(Map map, User validManager, Institution institution, OnboardingRequest request, InstitutionType institutionType) { - log.info("START - setupProdIOData"); - map.put("institutionTypeCode", institutionType); - decodePricingPlan(request.getPricingPlan(), request.getProductId(), map); - if (StringUtils.hasText(institution.getOrigin())) { - map.put("originIdLabelValue", Origin.IPA.getValue().equalsIgnoreCase(institution.getOrigin()) ? - "
  • codice di iscrizione all’Indice delle Pubbliche Amministrazioni e dei gestori di pubblici servizi (I.P.A.) ${originId}
  • " - : ""); - } - addInstitutionRegisterLabelValue(institution, map); - if (request.getBillingRequest() != null) { - map.put("institutionRecipientCode", request.getBillingRequest().getRecipientCode()); - } - - String underscore = "_______________"; - map.put("GPSinstitutionName", InstitutionType.GSP == institutionType ? institution.getDescription() : underscore); - map.put("GPSmanagerName", InstitutionType.GSP == institutionType ? validManager.getName() : underscore); - map.put("GPSmanagerSurname", InstitutionType.GSP == institutionType ? validManager.getFamilyName() : underscore); - map.put("GPSmanagerTaxCode", InstitutionType.GSP == institutionType ? validManager.getFiscalCode() : underscore); - - map.put(INSTITUTION_REA, Optional.ofNullable(institution.getRea()).orElse(underscore)); - map.put(INSTITUTION_SHARE_CAPITAL, Optional.ofNullable(institution.getShareCapital()).orElse(underscore)); - map.put(INSTITUTION_BUSINESS_REGISTER_PLACE, Optional.ofNullable(institution.getBusinessRegisterPlace()).orElse(underscore)); - - addPricingPlan(request, map); - } - - public static void setupSAProdInteropData(Map map, InstitutionUpdate institutionUpdate) { - log.info("START - setupSAProdInteropData"); - String underscore = "_______________"; - map.put(INSTITUTION_REA, Optional.ofNullable(institutionUpdate.getRea()).orElse(underscore)); - map.put(INSTITUTION_SHARE_CAPITAL, Optional.ofNullable(institutionUpdate.getShareCapital()).orElse(underscore)); - map.put(INSTITUTION_BUSINESS_REGISTER_PLACE, Optional.ofNullable(institutionUpdate.getBusinessRegisterPlace()).orElse(underscore)); - //override originId to not fill ipa code in case of SA - if(InstitutionType.SA.equals(institutionUpdate.getInstitutionType())) - map.put("originId", underscore); - } - - public static void setupProdPNData(Map map, Institution institution, OnboardingRequest request) { - log.info("START - setupProdPNData"); - addInstitutionRegisterLabelValue(institution, map); - if (request.getBillingRequest() != null) { - map.put("institutionRecipientCode", request.getBillingRequest().getRecipientCode()); - } - } - - - private static void addPricingPlan(OnboardingRequest request, Map map) { - if (StringUtils.hasText(request.getPricingPlan()) && Arrays.stream(PLAN_LIST).anyMatch(s -> s.equalsIgnoreCase(request.getPricingPlan()))) { - map.put(PRICING_PLAN_PREMIUM, request.getPricingPlan().replace("C", "")); - map.put(PRICING_PLAN_PREMIUM_CHECKBOX, "X"); - } else { - map.put(PRICING_PLAN_PREMIUM, ""); - map.put(PRICING_PLAN_PREMIUM_CHECKBOX, ""); - } - - map.put(PRICING_PLAN_PREMIUM_BASE, Optional.ofNullable(request.getPricingPlan()).orElse("")); - - if (StringUtils.hasText(request.getPricingPlan()) && "C0".equalsIgnoreCase(request.getPricingPlan())) { - map.put(PRICING_PLAN_PREMIUM_BASE_CHECKBOX, "X"); - } else { - map.put(PRICING_PLAN_PREMIUM_BASE_CHECKBOX, ""); - } - } - - private static void addInstitutionRegisterLabelValue(Institution institution, Map map) { - if (institution.getPaymentServiceProvider() != null - && StringUtils.hasText(institution.getPaymentServiceProvider().getBusinessRegisterNumber())) { - map.put("number", institution.getPaymentServiceProvider().getBusinessRegisterNumber()); - map.put("institutionRegisterLabelValue", "
  • codice di iscrizione all’Indice delle Pubbliche Amministrazioni e dei gestori di pubblici servizi (I.P.A.) ${number}
  • \n"); - } else { - map.put("institutionRegisterLabelValue", ""); - } - } - - private static void decodePricingPlan(String pricingPlan, String productId, Map map) { - if (PricingPlan.FA.name().equals(pricingPlan)) { - map.put(PRICING_PLAN_FAST_CHECKBOX, "X"); - map.put(PRICING_PLAN_BASE_CHECKBOX, ""); - map.put(PRICING_PLAN_PREMIUM_CHECKBOX, ""); - map.put(PRICING_PLAN, PricingPlan.FA.getValue()); - return; - } - if (PROD_IO.getValue().equalsIgnoreCase(productId)) { - map.put(PRICING_PLAN_FAST_CHECKBOX, ""); - map.put(PRICING_PLAN_BASE_CHECKBOX, "X"); - map.put(PRICING_PLAN_PREMIUM_CHECKBOX, ""); - map.put(PRICING_PLAN, PricingPlan.BASE.getValue()); - } else { - map.put(PRICING_PLAN_FAST_CHECKBOX, ""); - map.put(PRICING_PLAN_BASE_CHECKBOX, ""); - map.put(PRICING_PLAN_PREMIUM_CHECKBOX, "X"); - map.put(PRICING_PLAN, PricingPlan.PREMIUM.getValue()); - } - } - - private static String decodeInstitutionType(InstitutionType institutionType) { - switch (institutionType) { - case PA: - return "Pubblica Amministrazione"; - case GSP: - return "Gestore di servizi pubblici"; - case PT: - return "Partner tecnologico"; - case SCP: - return "Società a controllo pubblico"; - case PSP: - return "Prestatori Servizi di Pagamento"; - default: - return ""; - - } - } - - private static String delegatesToText(List users, String institutionId) { - StringBuilder builder = new StringBuilder(); - users.forEach(user -> { - builder - .append("
    ") - .append("

    Nome e Cognome: ") - .append(user.getName()).append(" ") - .append(user.getFamilyName()) - .append(" 

    \n") - .append("

    Codice Fiscale: ") - .append(user.getFiscalCode()) - .append("

    \n") - .append("

    Amm.ne/Ente/Società:

    \n") - .append("

    Qualifica/Posizione:

    \n") - .append("

    e-mail: "); - if (user.getWorkContacts() != null && user.getWorkContacts().containsKey(institutionId)) { - builder.append(user.getWorkContacts().get(institutionId).getEmail()); - } - builder.append(" 

    \n") - .append("

    PEC:  

    \n") - .append("
    "); - }); - return builder.toString(); - } -} diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtilsTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtilsTest.java deleted file mode 100644 index 6ffe33e24..000000000 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/util/OnboardingInstitutionUtilsTest.java +++ /dev/null @@ -1,808 +0,0 @@ -package it.pagopa.selfcare.mscore.core.util; - -import it.pagopa.selfcare.commons.base.security.PartyRole; -import it.pagopa.selfcare.commons.base.utils.InstitutionType; -import it.pagopa.selfcare.mscore.constant.Env; -import it.pagopa.selfcare.mscore.constant.RelationshipState; -import it.pagopa.selfcare.mscore.constant.TokenType; -import it.pagopa.selfcare.mscore.core.TestUtils; -import it.pagopa.selfcare.mscore.exception.InvalidRequestException; -import it.pagopa.selfcare.mscore.exception.ResourceConflictException; -import it.pagopa.selfcare.mscore.model.institution.*; -import it.pagopa.selfcare.mscore.model.onboarding.Contract; -import it.pagopa.selfcare.mscore.model.onboarding.OnboardedProduct; -import it.pagopa.selfcare.mscore.model.onboarding.OnboardingRequest; -import it.pagopa.selfcare.mscore.model.user.UserToOnboard; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.List; - -import static it.pagopa.selfcare.mscore.core.util.TestUtils.dummyInstitutionPa; -import static org.junit.jupiter.api.Assertions.*; - -class OnboardingInstitutionUtilsTest { - - /** - * Method under test: {@link OnboardingInstitutionUtils#verifyUsers(List, List)} - */ - @Test - void testVerifyUsers2() { - UserToOnboard userToOnboard = new UserToOnboard(); - userToOnboard.setEmail("jane.doe@example.org"); - userToOnboard.setEnv(Env.ROOT); - userToOnboard.setId("42"); - userToOnboard.setName("Name"); - userToOnboard.setProductRole(""); - userToOnboard.setRole(PartyRole.MANAGER); - userToOnboard.setSurname("Doe"); - userToOnboard.setTaxCode("Tax Code"); - - ArrayList userToOnboardList = new ArrayList<>(); - userToOnboardList.add(userToOnboard); - List states = new ArrayList<>(); - assertThrows(InvalidRequestException.class, - () -> OnboardingInstitutionUtils.verifyUsers(userToOnboardList, states)); - } - - /** - * Method under test: {@link OnboardingInstitutionUtils#verifyUsers(List, List)} - */ - @Test - void testVerifyUsers3() { - UserToOnboard userToOnboard = new UserToOnboard(); - userToOnboard.setEmail("jane.doe@example.org"); - userToOnboard.setEnv(Env.ROOT); - userToOnboard.setId("42"); - userToOnboard.setName("Name"); - userToOnboard.setProductRole(""); - userToOnboard.setRole(PartyRole.MANAGER); - userToOnboard.setSurname("Doe"); - userToOnboard.setTaxCode("Tax Code"); - - UserToOnboard userToOnboard1 = new UserToOnboard(); - userToOnboard1.setEmail("jane.doe@example.org"); - userToOnboard1.setEnv(Env.ROOT); - userToOnboard1.setId("42"); - userToOnboard1.setName(", "); - userToOnboard1.setProductRole(""); - userToOnboard1.setRole(PartyRole.MANAGER); - userToOnboard1.setSurname("Doe"); - userToOnboard1.setTaxCode(", "); - - ArrayList userToOnboardList = new ArrayList<>(); - userToOnboardList.add(userToOnboard1); - userToOnboardList.add(userToOnboard); - List states = new ArrayList<>(); - assertThrows(InvalidRequestException.class, - () -> OnboardingInstitutionUtils.verifyUsers(userToOnboardList, states)); - } - /** - * Method under test: {@link OnboardingInstitutionUtils#checkIfProductAlreadyOnboarded(Institution, String)} - */ - @Test - void testCheckIfProductAlreadyOnboarded() { - Institution institution = new Institution(); - - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode("Recipient Code"); - billing.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - List stringList = new ArrayList<>(); - institutionUpdate.setGeographicTaxonomies(stringList); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - OnboardingInstitutionUtils.checkIfProductAlreadyOnboarded(institution, onboardingRequest.getProductId()); - assertFalse(institution.isImported()); - assertSame(billing, onboardingRequest.getBillingRequest()); - assertTrue(onboardingRequest.getSignContract()); - assertSame(contract, onboardingRequest.getContract()); - assertSame(institutionUpdate, onboardingRequest.getInstitutionUpdate()); - assertEquals("Pricing Plan", onboardingRequest.getPricingPlan()); - assertEquals("42", onboardingRequest.getInstitutionExternalId()); - assertEquals("42", onboardingRequest.getProductId()); - assertEquals("Product Name", onboardingRequest.getProductName()); - } - - - /** - * Method under test: {@link OnboardingInstitutionUtils#checkIfProductAlreadyOnboarded(Institution, String)} - */ - @Test - void testCheckIfProductAlreadyOnboarded3() { - - Institution institution = dummyInstitutionPa(); - - Billing billing1 = new Billing(); - billing1.setPublicServices(true); - billing1.setRecipientCode("Recipient Code"); - billing1.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - DataProtectionOfficer dataProtectionOfficer1 = new DataProtectionOfficer(); - dataProtectionOfficer1.setAddress("42 Main St"); - dataProtectionOfficer1.setEmail("jane.doe@example.org"); - dataProtectionOfficer1.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider1 = new PaymentServiceProvider(); - paymentServiceProvider1.setAbiCode("Abi Code"); - paymentServiceProvider1.setBusinessRegisterNumber("42"); - paymentServiceProvider1.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider1.setLegalRegisterNumber("42"); - paymentServiceProvider1.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer1); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider1); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing1); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - - assertDoesNotThrow(() -> OnboardingInstitutionUtils.checkIfProductAlreadyOnboarded(institution, onboardingRequest.getProductId())); - } - - /** - * Method under test: {@link OnboardingInstitutionUtils#checkIfProductAlreadyOnboarded(Institution, String)} - */ - @Test - void testCheckIfProductAlreadyOnboarded4() { - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - billing.setVatNumber("42"); - - Premium premium = new Premium(); - premium.setContract( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - premium.setStatus(RelationshipState.PENDING); - - Onboarding onboarding = new Onboarding(); - onboarding.setBilling(billing); - onboarding.setContract( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - onboarding.setCreatedAt(null); - onboarding.setPricingPlan( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - onboarding.setProductId("42"); - onboarding.setStatus(RelationshipState.PENDING); - onboarding.setUpdatedAt(null); - - ArrayList onboardingList = new ArrayList<>(); - onboardingList.add(onboarding); - Institution institution = dummyInstitutionPa(); - institution.setOnboarding(onboardingList); - - Billing billing2 = new Billing(); - billing2.setPublicServices(true); - billing2.setRecipientCode("Recipient Code"); - billing2.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - DataProtectionOfficer dataProtectionOfficer1 = new DataProtectionOfficer(); - dataProtectionOfficer1.setAddress("42 Main St"); - dataProtectionOfficer1.setEmail("jane.doe@example.org"); - dataProtectionOfficer1.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider1 = new PaymentServiceProvider(); - paymentServiceProvider1.setAbiCode("Abi Code"); - paymentServiceProvider1.setBusinessRegisterNumber("42"); - paymentServiceProvider1.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider1.setLegalRegisterNumber("42"); - paymentServiceProvider1.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer1); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - ArrayList stringList = new ArrayList<>(); - institutionUpdate.setGeographicTaxonomies(stringList); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider1); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing2); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - - assertDoesNotThrow(() -> OnboardingInstitutionUtils.checkIfProductAlreadyOnboarded(institution, onboardingRequest.getProductId())); - } - - /** - * Method under test: {@link OnboardingInstitutionUtils#checkIfProductAlreadyOnboarded(Institution, String)} - */ - @Test - void testCheckIfProductAlreadyOnboarded5() { - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - billing.setVatNumber("42"); - - Premium premium = new Premium(); - premium.setContract( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - premium.setStatus(RelationshipState.PENDING); - - Onboarding onboarding = new Onboarding(); - onboarding.setBilling(billing); - onboarding.setContract( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - onboarding.setCreatedAt(null); - onboarding.setPricingPlan( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - onboarding.setProductId( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - onboarding.setStatus(RelationshipState.PENDING); - onboarding.setUpdatedAt(null); - - ArrayList onboardingList = new ArrayList<>(); - onboardingList.add(onboarding); - Institution institution = dummyInstitutionPa(); - institution.setOnboarding(onboardingList); - - Billing billing1 = new Billing(); - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - - Billing billing2 = new Billing(); - billing2.setPublicServices(true); - billing2.setRecipientCode("Recipient Code"); - billing2.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - DataProtectionOfficer dataProtectionOfficer1 = new DataProtectionOfficer(); - dataProtectionOfficer1.setAddress("42 Main St"); - dataProtectionOfficer1.setEmail("jane.doe@example.org"); - dataProtectionOfficer1.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider1 = new PaymentServiceProvider(); - paymentServiceProvider1.setAbiCode("Abi Code"); - paymentServiceProvider1.setBusinessRegisterNumber("42"); - paymentServiceProvider1.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider1.setLegalRegisterNumber("42"); - paymentServiceProvider1.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer1); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - ArrayList stringList = new ArrayList<>(); - institutionUpdate.setGeographicTaxonomies(stringList); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider1); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing2); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - - assertDoesNotThrow(() -> OnboardingInstitutionUtils.checkIfProductAlreadyOnboarded(institution, onboardingRequest.getProductId())); - } - - - /** - * Method under test: {@link OnboardingInstitutionUtils#checkIfProductAlreadyOnboarded(Institution, String)} - */ - @Test - void testCheckIfProductAlreadyOnboarded8() { - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - billing.setVatNumber("42"); - - Premium premium = new Premium(); - premium.setContract( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - premium.setStatus(RelationshipState.PENDING); - - Onboarding onboarding = new Onboarding(); - onboarding.setBilling(billing); - onboarding.setContract( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - onboarding.setCreatedAt(null); - onboarding.setPricingPlan( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - onboarding.setProductId("42"); - onboarding.setStatus(RelationshipState.PENDING); - onboarding.setUpdatedAt(null); - - Billing billing1 = new Billing(); - billing1.setPublicServices(true); - billing1.setRecipientCode( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - billing1.setVatNumber("42"); - - Premium premium1 = new Premium(); - premium1.setContract( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - premium1.setStatus(RelationshipState.PENDING); - - Onboarding onboarding1 = new Onboarding(); - onboarding1.setBilling(billing1); - onboarding1.setContract( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - onboarding1.setCreatedAt(null); - onboarding1.setPricingPlan( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - onboarding1.setProductId("Product Id"); - onboarding1.setStatus(RelationshipState.PENDING); - onboarding1.setUpdatedAt(null); - - ArrayList onboardingList = new ArrayList<>(); - onboardingList.add(onboarding1); - onboardingList.add(onboarding); - Institution institution = dummyInstitutionPa(); - institution.setOnboarding(onboardingList); - - Billing billing2 = new Billing(); - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - - Billing billing3 = new Billing(); - billing3.setPublicServices(true); - billing3.setRecipientCode("Recipient Code"); - billing3.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - DataProtectionOfficer dataProtectionOfficer1 = new DataProtectionOfficer(); - dataProtectionOfficer1.setAddress("42 Main St"); - dataProtectionOfficer1.setEmail("jane.doe@example.org"); - dataProtectionOfficer1.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider1 = new PaymentServiceProvider(); - paymentServiceProvider1.setAbiCode("Abi Code"); - paymentServiceProvider1.setBusinessRegisterNumber("42"); - paymentServiceProvider1.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider1.setLegalRegisterNumber("42"); - paymentServiceProvider1.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer1); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - ArrayList stringList = new ArrayList<>(); - institutionUpdate.setGeographicTaxonomies(stringList); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider1); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing3); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - - assertDoesNotThrow(() -> OnboardingInstitutionUtils.checkIfProductAlreadyOnboarded(institution, onboardingRequest.getProductId())); - } - - /** - * Method under test: {@link OnboardingInstitutionUtils#checkIfProductAlreadyOnboarded(Institution, String)} - */ - @Test - void testCheckIfProductAlreadyOnboarded9() { - Onboarding onboarding = new Onboarding(); - onboarding.setContract( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - onboarding.setCreatedAt(null); - onboarding.setPricingPlan( - "START - checkIfProductAlreadyOnboarded for institution having externalId: {} and productId: {}"); - onboarding.setProductId("42"); - onboarding.setStatus(RelationshipState.ACTIVE); - onboarding.setUpdatedAt(null); - - ArrayList onboardingList = new ArrayList<>(); - onboardingList.add(onboarding); - - Institution institution = dummyInstitutionPa(); - institution.setOnboarding(onboardingList); - - Billing billing3 = new Billing(); - billing3.setPublicServices(true); - billing3.setRecipientCode("Recipient Code"); - billing3.setVatNumber("42"); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - ArrayList stringList = new ArrayList<>(); - institutionUpdate.setGeographicTaxonomies(stringList); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - assertThrows(ResourceConflictException.class, - () -> OnboardingInstitutionUtils.checkIfProductAlreadyOnboarded(institution, onboardingRequest.getProductId()), - "Product 42 already onboarded for institution having externalId 42"); - } - - /** - * Method under test: {@link OnboardingInstitutionUtils#validateOnboarding(Billing, boolean)} - */ - @Test - void testValidatePaOnboarding() { - Billing billing = TestUtils.createSimpleBilling(); - - Contract contract = TestUtils.createSimpleContract(); - - InstitutionUpdate institutionUpdate = TestUtils.createSimpleInstitutionUpdate(); - - OnboardingRequest onboardingRequest = TestUtils.dummyOnboardingRequest(); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - OnboardingInstitutionUtils.validateOnboarding(onboardingRequest.getBillingRequest(), true); - assertSame(billing, onboardingRequest.getBillingRequest()); - assertTrue(onboardingRequest.getSignContract()); - assertSame(contract, onboardingRequest.getContract()); - assertSame(institutionUpdate, onboardingRequest.getInstitutionUpdate()); - assertEquals(TokenType.INSTITUTION, onboardingRequest.getTokenType()); - assertEquals("Pricing Plan", onboardingRequest.getPricingPlan()); - assertEquals("42", onboardingRequest.getInstitutionExternalId()); - assertEquals("prod-io", onboardingRequest.getProductId()); - assertEquals("Product Name", onboardingRequest.getProductName()); - } - - /** - * Method under test: {@link OnboardingInstitutionUtils#validateOnboarding(Billing, boolean)} - */ - @Test - void testValidatePaOnboarding4() { - Billing billing = TestUtils.createSimpleBilling(); - billing.setRecipientCode(null); - - Contract contract = TestUtils.createSimpleContract(); - - InstitutionUpdate institutionUpdate = TestUtils.createSimpleInstitutionUpdate(); - - OnboardingRequest onboardingRequest = TestUtils.dummyOnboardingRequest(); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - assertThrows(InvalidRequestException.class, - () -> OnboardingInstitutionUtils.validateOnboarding(onboardingRequest.getBillingRequest(), true)); - } - - /** - * Method under test: - * {@link OnboardingInstitutionUtils#validateOverridingData(InstitutionUpdate, Institution)} - */ - @Test - void testValidateOverridingData() { - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setCity("Oxford"); - institutionUpdate.setCountry("GB"); - institutionUpdate.setCounty("3"); - institutionUpdate.setDataProtectionOfficer(new DataProtectionOfficer("42 Main St", "jane.doe@example.org", "Pec")); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setIvassCode("Ivass Code"); - institutionUpdate - .setPaymentServiceProvider(new PaymentServiceProvider("Abi Code", "42", "Legal Register Name", "42", true)); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("6625550144"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - assertThrows(InvalidRequestException.class, - () -> OnboardingInstitutionUtils.validateOverridingData(institutionUpdate, new Institution())); - } - - /** - * Method under test: - * {@link OnboardingInstitutionUtils#validateOverridingData(InstitutionUpdate, Institution)} - */ - @Test - void testValidateOverridingData2() { - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setCity("Oxford"); - institutionUpdate.setCountry("GB"); - institutionUpdate.setCounty("3"); - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer("42 Main St", "jane.doe@example.org", - "Pec"); - - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setIvassCode("Ivass Code"); - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider("Abi Code", "42", "Legal Register Name", - "42", true); - - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("6625550144"); - institutionUpdate.setZipCode(null); - institutionUpdate.setAddress("via del corso"); - - Institution institution = new Institution(); - institution.setOrigin("IPA"); - institution.setZipCode(null); - institution.setExternalId("42"); - institution.setAddress("via roma"); - institution.setDigitalAddress(null); - institution.setDescription(null); - institution.setTaxCode(null); - - assertThrows(InvalidRequestException.class, - () -> OnboardingInstitutionUtils.validateOverridingData(institutionUpdate, institution)); - } - - - /** - * Method under test: {@link OnboardingInstitutionUtils#constructOperatorProduct(UserToOnboard, String)} - */ - @Test - void testConstructOperatorProduct() { - UserToOnboard userToOnboard = new UserToOnboard(); - userToOnboard.setEmail("jane.doe@example.org"); - userToOnboard.setEnv(Env.ROOT); - userToOnboard.setId("42"); - userToOnboard.setName("Name"); - userToOnboard.setProductRole(""); - userToOnboard.setRole(PartyRole.MANAGER); - userToOnboard.setSurname("Doe"); - userToOnboard.setTaxCode("Tax Code"); - String productId = "42"; - - OnboardedProduct actualConstructOperatorProductResult = OnboardingInstitutionUtils - .constructOperatorProduct(userToOnboard, productId); - assertEquals(RelationshipState.ACTIVE, actualConstructOperatorProductResult.getStatus()); - assertEquals(PartyRole.MANAGER, actualConstructOperatorProductResult.getRole()); - assertEquals(productId, actualConstructOperatorProductResult.getProductId()); - assertEquals(Env.ROOT, actualConstructOperatorProductResult.getEnv()); - } - - /** - * Method under test: {@link OnboardingInstitutionUtils#constructOperatorProduct(UserToOnboard, String)} - */ - @Test - void testConstructOperatorProduct2() { - UserToOnboard userToOnboard = new UserToOnboard(); - userToOnboard.setEmail("jane.doe@example.org"); - userToOnboard.setEnv(null); - userToOnboard.setId("42"); - userToOnboard.setName("Name"); - userToOnboard.setProductRole(""); - userToOnboard.setRole(PartyRole.MANAGER); - userToOnboard.setSurname("Doe"); - userToOnboard.setTaxCode("Tax Code"); - String productId = "42"; - - OnboardedProduct actualConstructOperatorProductResult = OnboardingInstitutionUtils - .constructOperatorProduct(userToOnboard, productId); - assertEquals(RelationshipState.ACTIVE, actualConstructOperatorProductResult.getStatus()); - assertEquals(PartyRole.MANAGER, actualConstructOperatorProductResult.getRole()); - assertEquals("42", actualConstructOperatorProductResult.getProductId()); - assertEquals(Env.ROOT, actualConstructOperatorProductResult.getEnv()); - } - - @Test - void testConstructProduct() { - UserToOnboard userToOnboard = new UserToOnboard(); - userToOnboard.setEmail("jane.doe@example.org"); - userToOnboard.setEnv(Env.ROOT); - userToOnboard.setId("42"); - userToOnboard.setName("Name"); - userToOnboard.setProductRole(""); - userToOnboard.setRole(PartyRole.MANAGER); - userToOnboard.setSurname("Doe"); - userToOnboard.setTaxCode("Tax Code"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setInstitutionType(InstitutionType.PG); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setContract(new Contract()); - OnboardedProduct actualConstructProductResult = OnboardingInstitutionUtils.constructProduct(userToOnboard, - onboardingRequest, new Institution()); - assertEquals(RelationshipState.ACTIVE, actualConstructProductResult.getStatus()); - assertEquals(PartyRole.MANAGER, actualConstructProductResult.getRole()); - assertEquals(Env.ROOT, actualConstructProductResult.getEnv()); - } - - @Test - void testConstructProduct2() { - UserToOnboard userToOnboard = new UserToOnboard(); - userToOnboard.setEmail("jane.doe@example.org"); - userToOnboard.setEnv(Env.ROOT); - userToOnboard.setId("42"); - userToOnboard.setName("Name"); - userToOnboard.setProductRole(""); - userToOnboard.setRole(PartyRole.MANAGER); - userToOnboard.setSurname("Doe"); - userToOnboard.setTaxCode("Tax Code"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setContract(new Contract()); - - Institution institution = new Institution(); - institution.setInstitutionType(InstitutionType.PA); - OnboardedProduct actualConstructProductResult = OnboardingInstitutionUtils.constructProduct(userToOnboard, - onboardingRequest, institution); - assertEquals(RelationshipState.PENDING, actualConstructProductResult.getStatus()); - assertEquals(PartyRole.MANAGER, actualConstructProductResult.getRole()); - assertEquals(Env.ROOT, actualConstructProductResult.getEnv()); - } - - @Test - void testValidateSaOnboarding() { - Billing billing = TestUtils.createSimpleBilling(); - billing.setRecipientCode(null); - - Contract contract = TestUtils.createSimpleContract(); - - InstitutionUpdate institutionUpdate = TestUtils.createSimpleInstitutionUpdateSA(); - - OnboardingRequest onboardingRequest = TestUtils.dummyOnboardingRequest(); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - OnboardingInstitutionUtils.validateOnboarding(onboardingRequest.getBillingRequest(), false); - assertSame(billing, onboardingRequest.getBillingRequest()); - assertTrue(onboardingRequest.getSignContract()); - assertSame(contract, onboardingRequest.getContract()); - assertSame(institutionUpdate, onboardingRequest.getInstitutionUpdate()); - assertEquals(TokenType.INSTITUTION, onboardingRequest.getTokenType()); - assertEquals("Pricing Plan", onboardingRequest.getPricingPlan()); - assertEquals("42", onboardingRequest.getInstitutionExternalId()); - assertEquals("prod-io", onboardingRequest.getProductId()); - assertEquals("Product Name", onboardingRequest.getProductName()); - } - - @Test - void testValidateSaOnboardingNull() { - Billing billing = TestUtils.createSimpleBilling(); - billing.setVatNumber(null); - - Contract contract = TestUtils.createSimpleContract(); - - InstitutionUpdate institutionUpdate = TestUtils.createSimpleInstitutionUpdateSA(); - - OnboardingRequest onboardingRequest = TestUtils.dummyOnboardingRequest(); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - assertThrows(InvalidRequestException.class, - () -> OnboardingInstitutionUtils.validateOnboarding(onboardingRequest.getBillingRequest(), false)); - } -} - diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/util/PdfMapperTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/util/PdfMapperTest.java deleted file mode 100644 index 5374e9612..000000000 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/util/PdfMapperTest.java +++ /dev/null @@ -1,1442 +0,0 @@ -package it.pagopa.selfcare.mscore.core.util; - -import it.pagopa.selfcare.commons.base.utils.InstitutionType; -import it.pagopa.selfcare.mscore.constant.Origin; -import it.pagopa.selfcare.mscore.exception.InvalidRequestException; -import it.pagopa.selfcare.mscore.model.Certification; -import it.pagopa.selfcare.mscore.model.CertifiedField; -import it.pagopa.selfcare.mscore.model.institution.*; -import it.pagopa.selfcare.mscore.model.onboarding.Contract; -import it.pagopa.selfcare.mscore.model.onboarding.ContractImported; -import it.pagopa.selfcare.mscore.model.onboarding.OnboardingRequest; -import it.pagopa.selfcare.mscore.model.user.User; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static it.pagopa.selfcare.mscore.core.util.TestUtils.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -class PdfMapperTest { - - @Test - void testSetUpCommonData0() { - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - CertifiedField emailCert = new CertifiedField<>(); - emailCert.setValue("email"); - WorkContact workContact = new WorkContact(); - workContact.setEmail(emailCert); - Map map = new HashMap<>(); - map.put("id", workContact); - user.setWorkContacts(map); - ArrayList users = new ArrayList<>(); - Institution institution = new Institution(); - institution.setId("id"); - - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode("Recipient Code"); - billing.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - ContractImported contractImported = new ContractImported(); - contractImported.setContractType("Contract Type"); - contractImported.setFileName("foo.txt"); - contractImported.setFilePath("/directory/foo.txt"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - assertEquals(14, PdfMapper.setUpCommonData(user, users, institution, onboardingRequest, new ArrayList<>(), InstitutionType.PA).size()); - } - /** - * Method under test: {@link PdfMapper#setUpCommonData(User, List, Institution, OnboardingRequest, List, InstitutionType)} - */ - @Test - void testSetUpCommonData() { - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - user.setWorkContacts(new HashMap<>()); - ArrayList users = new ArrayList<>(); - Institution institution = new Institution(); - institution.setInstitutionType(InstitutionType.PT); - - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode("Recipient Code"); - billing.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - ContractImported contractImported = new ContractImported(); - contractImported.setContractType("Contract Type"); - contractImported.setFileName("foo.txt"); - contractImported.setFilePath("/directory/foo.txt"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - List geographicTaxonomies = new ArrayList<>(); - geographicTaxonomies.add(new InstitutionGeographicTaxonomies()); - assertThrows(InvalidRequestException.class, () -> PdfMapper.setUpCommonData(user, users, institution, onboardingRequest, geographicTaxonomies, InstitutionType.PA)); - } - - /** - * Method under test: {@link PdfMapper#setUpCommonData(User, List, Institution, OnboardingRequest, List, InstitutionType)} - */ - @Test - void testSetUpCommonData2() { - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - CertifiedField emailCert = new CertifiedField<>(); - emailCert.setValue("email"); - WorkContact workContact = new WorkContact(); - workContact.setEmail(emailCert); - Map map = new HashMap<>(); - map.put("id", workContact); - user.setWorkContacts(map); - ArrayList users = new ArrayList<>(); - Institution institution = new Institution(); - institution.setId("id"); - institution.setInstitutionType(InstitutionType.GSP); - - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode("Recipient Code"); - billing.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - ContractImported contractImported = new ContractImported(); - contractImported.setContractType("Contract Type"); - contractImported.setFileName("foo.txt"); - contractImported.setFilePath("/directory/foo.txt"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.GSP); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - assertEquals(14, PdfMapper.setUpCommonData(user, users, institution, onboardingRequest, null, InstitutionType.PA).size()); - } - - /** - * Method under test: {@link PdfMapper#setUpCommonData(User, List, Institution, OnboardingRequest, List, InstitutionType)} - */ - @Test - void testSetUpCommonData3() { - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - CertifiedField emailCert = new CertifiedField<>(); - emailCert.setValue("email"); - WorkContact workContact = new WorkContact(); - workContact.setEmail(emailCert); - Map map = new HashMap<>(); - map.put("id", workContact); - user.setWorkContacts(map); - - CertifiedField certifiedField3 = new CertifiedField<>(); - certifiedField3.setCertification(Certification.NONE); - certifiedField3.setValue("42"); - - CertifiedField certifiedField4 = new CertifiedField<>(); - certifiedField4.setCertification(Certification.NONE); - certifiedField4.setValue("42"); - - CertifiedField certifiedField5 = new CertifiedField<>(); - certifiedField5.setCertification(Certification.NONE); - certifiedField5.setValue("42"); - - User user1 = new User(); - user1.setEmail(certifiedField3); - user1.setFamilyName(certifiedField4); - user1.setFiscalCode("START - setupCommonData"); - user1.setId("42"); - user1.setName(certifiedField5); - CertifiedField emailCert2 = new CertifiedField<>(); - emailCert2.setValue("email"); - WorkContact workContact2 = new WorkContact(); - workContact2.setEmail(emailCert2); - Map map2 = new HashMap<>(); - map2.put("id", workContact2); - user1.setWorkContacts(map2); - - ArrayList userList = new ArrayList<>(); - userList.add(user1); - Institution institution = new Institution(); - institution.setId("id"); - institution.setInstitutionType(InstitutionType.SCP); - - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode("Recipient Code"); - billing.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - ContractImported contractImported = new ContractImported(); - contractImported.setContractType("Contract Type"); - contractImported.setFileName("foo.txt"); - contractImported.setFilePath("/directory/foo.txt"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PT); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - assertEquals(14, - PdfMapper.setUpCommonData(user, userList, institution, onboardingRequest, new ArrayList<>(), InstitutionType.PT).size()); - } - - /** - * Method under test: {@link PdfMapper#setUpCommonData(User, List, Institution, OnboardingRequest, List, InstitutionType)} - */ - @Test - void testSetUpCommonData4() { - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - CertifiedField emailCert = new CertifiedField<>(); - emailCert.setValue("email"); - WorkContact workContact = new WorkContact(); - workContact.setEmail(emailCert); - Map map = new HashMap<>(); - map.put("id", workContact); - user.setWorkContacts(map); - - CertifiedField certifiedField3 = new CertifiedField<>(); - certifiedField3.setCertification(Certification.NONE); - certifiedField3.setValue("42"); - - CertifiedField certifiedField4 = new CertifiedField<>(); - certifiedField4.setCertification(Certification.NONE); - certifiedField4.setValue("42"); - - CertifiedField certifiedField5 = new CertifiedField<>(); - certifiedField5.setCertification(Certification.NONE); - certifiedField5.setValue("42"); - - User user1 = new User(); - user1.setEmail(certifiedField3); - user1.setFamilyName(certifiedField4); - user1.setFiscalCode("START - setupCommonData"); - user1.setId("42"); - user1.setName(certifiedField5); - WorkContact workContact1 = new WorkContact(); - workContact1.setEmail(emailCert); - Map map1 = new HashMap<>(); - map1.put("id", workContact1); - user1.setWorkContacts(map1); - - CertifiedField certifiedField6 = new CertifiedField<>(); - certifiedField6.setCertification(Certification.NONE); - certifiedField6.setValue("42"); - - CertifiedField certifiedField7 = new CertifiedField<>(); - certifiedField7.setCertification(Certification.NONE); - certifiedField7.setValue("42"); - - CertifiedField certifiedField8 = new CertifiedField<>(); - certifiedField8.setCertification(Certification.NONE); - certifiedField8.setValue("42"); - - User user2 = new User(); - user2.setEmail(certifiedField6); - user2.setFamilyName(certifiedField7); - user2.setFiscalCode("START - setupCommonData"); - user2.setId("42"); - user2.setName(certifiedField8); - WorkContact workContact2 = new WorkContact(); - workContact2.setEmail(emailCert); - Map map2 = new HashMap<>(); - map2.put("id", workContact2); - user2.setWorkContacts(map2); - - ArrayList userList = new ArrayList<>(); - userList.add(user2); - userList.add(user1); - Institution institution = new Institution(); - institution.setId("id"); - institution.setInstitutionType(InstitutionType.PSP); - - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode("Recipient Code"); - billing.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - ContractImported contractImported = new ContractImported(); - contractImported.setContractType("Contract Type"); - contractImported.setFileName("foo.txt"); - contractImported.setFilePath("/directory/foo.txt"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.SCP); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - assertEquals(14, - PdfMapper.setUpCommonData(user, userList, institution, onboardingRequest, new ArrayList<>(), InstitutionType.PSP).size()); - } - - /** - * Method under test: {@link PdfMapper#setUpCommonData(User, List, Institution, OnboardingRequest, List, InstitutionType)} - */ - @Test - void testSetUpCommonData6() { - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - WorkContact workContact1 = new WorkContact(); - CertifiedField emailCert = new CertifiedField<>(); - workContact1.setEmail(emailCert); - Map map1 = new HashMap<>(); - map1.put("42", workContact1); - user.setWorkContacts(map1); - ArrayList users = new ArrayList<>(); - Institution institution = dummyInstitutionPa(); - - Billing billing1 = new Billing(); - billing1.setPublicServices(true); - billing1.setRecipientCode("Recipient Code"); - billing1.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - ContractImported contractImported = new ContractImported(); - contractImported.setContractType("Contract Type"); - contractImported.setFileName("foo.txt"); - contractImported.setFilePath("/directory/foo.txt"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider1 = new PaymentServiceProvider(); - paymentServiceProvider1.setAbiCode("Abi Code"); - paymentServiceProvider1.setBusinessRegisterNumber("42"); - paymentServiceProvider1.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider1.setLegalRegisterNumber("42"); - paymentServiceProvider1.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PSP); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider1); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing1); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - assertEquals(14, - PdfMapper.setUpCommonData(user, users, institution, onboardingRequest, new ArrayList<>(), InstitutionType.PSP).size()); - } - - /** - * Method under test: {@link PdfMapper#setUpCommonData(User, List, Institution, OnboardingRequest, List, InstitutionType)} - */ - @Test - void testSetUpCommonDataAoo() { - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - CertifiedField emailCert = new CertifiedField<>(); - emailCert.setValue("email"); - WorkContact workContact = new WorkContact(); - workContact.setEmail(emailCert); - Map map = new HashMap<>(); - map.put("id", workContact); - user.setWorkContacts(map); - ArrayList users = new ArrayList<>(); - Institution institution = new Institution(); - institution.setId("id"); - institution.setInstitutionType(InstitutionType.PA); - institution.setSubunitType(InstitutionPaSubunitType.AOO.name()); - - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode("Recipient Code"); - billing.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - ContractImported contractImported = new ContractImported(); - contractImported.setContractType("Contract Type"); - contractImported.setFileName("foo.txt"); - contractImported.setFilePath("/directory/foo.txt"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = dummyOnboardingRequest(billing, contract, institutionUpdate); - - assertEquals(14, PdfMapper.setUpCommonData(user, users, institution, onboardingRequest, null, InstitutionType.PA).size()); - } - - /** - * Method under test: {@link PdfMapper#setUpCommonData(User, List, Institution, OnboardingRequest, List, InstitutionType)} - */ - @Test - void testSetUpCommonDataUo() { - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - CertifiedField emailCert = new CertifiedField<>(); - emailCert.setValue("email"); - WorkContact workContact = new WorkContact(); - workContact.setEmail(emailCert); - Map map = new HashMap<>(); - map.put("id", workContact); - user.setWorkContacts(map); - ArrayList users = new ArrayList<>(); - Institution institution = new Institution(); - institution.setId("id"); - institution.setInstitutionType(InstitutionType.PA); - institution.setSubunitType(InstitutionPaSubunitType.UO.name()); - - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode("Recipient Code"); - billing.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - ContractImported contractImported = new ContractImported(); - contractImported.setContractType("Contract Type"); - contractImported.setFileName("foo.txt"); - contractImported.setFilePath("/directory/foo.txt"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = dummyOnboardingRequest(billing, contract, institutionUpdate); - - assertEquals(14, PdfMapper.setUpCommonData(user, users, institution, onboardingRequest, null, InstitutionType.PA).size()); - } - - /** - * Method under test: {@link PdfMapper#setupPSPData(Map, User, Institution)} - */ - @Test - void testSetupPSPData() { - HashMap stringObjectMap = new HashMap<>(); - - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - user.setWorkContacts(new HashMap<>()); - PdfMapper.setupPSPData(stringObjectMap, user, new Institution()); - assertEquals(0, stringObjectMap.size()); - } - - /** - * Method under test: {@link PdfMapper#setupPSPData(Map, User, Institution)} - */ - @Test - void testSetupPSPData3() { - HashMap stringObjectMap = new HashMap<>(); - - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - user.setWorkContacts(new HashMap<>()); - - PdfMapper.setupPSPData(stringObjectMap, user, dummyInstitutionGsp()); - assertEquals(8, stringObjectMap.size()); - } - - /** - * Method under test: {@link PdfMapper#setupPSPData(Map, User, Institution)} - */ - @Test - void testSetupPSPData4() { - HashMap stringObjectMap = new HashMap<>(); - - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - user.setWorkContacts(new HashMap<>()); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("START - setupPSPData"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("START - setupPSPData"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - Institution institution = new Institution(); - institution.setPaymentServiceProvider(paymentServiceProvider); - PdfMapper.setupPSPData(stringObjectMap, user, institution); - assertEquals(5, stringObjectMap.size()); - } - - /** - * Method under test: {@link PdfMapper#setupPSPData(Map, User, Institution)} - */ - @Test - void testSetupPSPData5() { - HashMap stringObjectMap = new HashMap<>(); - - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - user.setWorkContacts(new HashMap<>()); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("START - setupPSPData"); - - Institution institution = new Institution(); - institution.setDataProtectionOfficer(dataProtectionOfficer); - PdfMapper.setupPSPData(stringObjectMap, user, institution); - assertEquals(3, stringObjectMap.size()); - } - - /** - * Method under test: {@link PdfMapper#setupProdIOData(Map, User, Institution, OnboardingRequest, InstitutionType)} - */ - @Test - void testSetupProdIOData1() { - HashMap stringObjectMap = new HashMap<>(); - - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - user.setWorkContacts(new HashMap<>()); - Institution institution = new Institution(); - institution.setInstitutionType(InstitutionType.PA); - institution.setOrigin(Origin.IPA.name()); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - institution.setPaymentServiceProvider(paymentServiceProvider); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("C1"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - PdfMapper.setupProdIOData(stringObjectMap, user, institution, onboardingRequest, InstitutionType.PA); - assertEquals(18, stringObjectMap.size()); - } - - /** - * Method under test: {@link PdfMapper#setupProdIOData(Map, User, Institution, OnboardingRequest, InstitutionType)} - */ - @Test - void testSetupProdIOData() { - HashMap stringObjectMap = new HashMap<>(); - - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - user.setWorkContacts(new HashMap<>()); - Institution institution = new Institution(); - institution.setInstitutionType(InstitutionType.PA); - institution.setOrigin(Origin.IPA.name()); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - institution.setPaymentServiceProvider(paymentServiceProvider); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("C0"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - PdfMapper.setupProdIOData(stringObjectMap, user, institution, onboardingRequest, InstitutionType.PA); - assertEquals(18, stringObjectMap.size()); - } - - /** - * Method under test: {@link PdfMapper#setupProdIOData(Map, User, Institution, OnboardingRequest, InstitutionType)} - */ - @Test - void testSetupProdIOData3() { - HashMap stringObjectMap = new HashMap<>(); - - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - user.setWorkContacts(new HashMap<>()); - - Institution institution = dummyInstitutionPt(); - - Billing billing1 = new Billing(); - billing1.setPublicServices(true); - billing1.setRecipientCode("Recipient Code"); - billing1.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - ContractImported contractImported = new ContractImported(); - contractImported.setContractType("Contract Type"); - contractImported.setFileName("foo.txt"); - contractImported.setFilePath("/directory/foo.txt"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider1 = new PaymentServiceProvider(); - paymentServiceProvider1.setAbiCode("Abi Code"); - paymentServiceProvider1.setBusinessRegisterNumber("42"); - paymentServiceProvider1.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider1.setLegalRegisterNumber("42"); - paymentServiceProvider1.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider1); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing1); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - PdfMapper.setupProdIOData(stringObjectMap, user, institution, onboardingRequest, InstitutionType.PA); - assertEquals(18, stringObjectMap.size()); - } - - /** - * Method under test: {@link PdfMapper#setupProdIOData(Map, User, Institution, OnboardingRequest, InstitutionType)} - */ - @Test - void testSetupProdIOData4() { - HashMap stringObjectMap = new HashMap<>(); - - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - user.setWorkContacts(new HashMap<>()); - Institution institution = new Institution(); - - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode("Recipient Code"); - billing.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - ContractImported contractImported = new ContractImported(); - contractImported.setContractType("Contract Type"); - contractImported.setFileName("foo.txt"); - contractImported.setFilePath("/directory/foo.txt"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("FA"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - PdfMapper.setupProdIOData(stringObjectMap, user, institution, onboardingRequest, InstitutionType.PA); - assertEquals(17, stringObjectMap.size()); - } - - /** - * Method under test: {@link PdfMapper#setupProdIOData(Map, User, Institution, OnboardingRequest, InstitutionType)} - */ - @Test - void testSetupProdIOData5() { - HashMap stringObjectMap = new HashMap<>(); - - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - user.setWorkContacts(new HashMap<>()); - Institution institution = new Institution(); - - Billing billing = new Billing(); - billing.setPublicServices(true); - billing.setRecipientCode("Recipient Code"); - billing.setVatNumber("42"); - - Contract contract = new Contract(); - contract.setPath("Path"); - contract.setVersion("1.0.2"); - - ContractImported contractImported = new ContractImported(); - contractImported.setContractType("Contract Type"); - contractImported.setFileName("foo.txt"); - contractImported.setFilePath("/directory/foo.txt"); - - DataProtectionOfficer dataProtectionOfficer = new DataProtectionOfficer(); - dataProtectionOfficer.setAddress("42 Main St"); - dataProtectionOfficer.setEmail("jane.doe@example.org"); - dataProtectionOfficer.setPec("Pec"); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDataProtectionOfficer(dataProtectionOfficer); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setPaymentServiceProvider(paymentServiceProvider); - institutionUpdate.setRea("Rea"); - institutionUpdate.setShareCapital("Share Capital"); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.setContract(contract); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("Pricing Plan"); - onboardingRequest.setProductId("prod-io"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - PdfMapper.setupProdIOData(stringObjectMap, user, institution, onboardingRequest, InstitutionType.PA); - assertEquals(17, stringObjectMap.size()); - } - @Test - void testSetupProdPNData() { - HashMap stringObjectMap = new HashMap<>(); - - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setCertification(Certification.NONE); - certifiedField.setValue("42"); - - CertifiedField certifiedField1 = new CertifiedField<>(); - certifiedField1.setCertification(Certification.NONE); - certifiedField1.setValue("42"); - - CertifiedField certifiedField2 = new CertifiedField<>(); - certifiedField2.setCertification(Certification.NONE); - certifiedField2.setValue("42"); - - User user = new User(); - user.setEmail(certifiedField); - user.setFamilyName(certifiedField1); - user.setFiscalCode("Fiscal Code"); - user.setId("42"); - user.setName(certifiedField2); - user.setWorkContacts(new HashMap<>()); - Institution institution = new Institution(); - institution.setInstitutionType(InstitutionType.PA); - institution.setOrigin(Origin.IPA.name()); - - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.PA); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - Billing billing = new Billing(); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("C1"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.getBillingRequest().setRecipientCode("42"); - PdfMapper.setupProdPNData(stringObjectMap, institution, onboardingRequest); - assertEquals(2, stringObjectMap.size()); - } - - /** - * Method under test: {@link PdfMapper#setupSAProdInteropData(Map, InstitutionUpdate)} - */ - @Test - void testSetupSAProdInterop() { - HashMap stringObjectMap = new HashMap<>(); - - Institution institution = new Institution(); - institution.setInstitutionType(InstitutionType.SA); - institution.setOrigin(Origin.ANAC.name()); - - PaymentServiceProvider paymentServiceProvider = new PaymentServiceProvider(); - paymentServiceProvider.setAbiCode("Abi Code"); - paymentServiceProvider.setBusinessRegisterNumber("42"); - paymentServiceProvider.setLegalRegisterName("Legal Register Name"); - paymentServiceProvider.setLegalRegisterNumber("42"); - paymentServiceProvider.setVatNumberGroup(true); - - institution.setPaymentServiceProvider(paymentServiceProvider); - - InstitutionUpdate institutionUpdate = new InstitutionUpdate(); - institutionUpdate.setAddress("42 Main St"); - institutionUpdate.setRea("rea"); - institutionUpdate.setShareCapital("1111"); - institutionUpdate.setBusinessRegisterPlace("Business Register Place"); - institutionUpdate.setDescription("The characteristics of someone or something"); - institutionUpdate.setDigitalAddress("42 Main St"); - institutionUpdate.setGeographicTaxonomies(new ArrayList<>()); - institutionUpdate.setImported(true); - institutionUpdate.setInstitutionType(InstitutionType.SA); - institutionUpdate.setSupportEmail("jane.doe@example.org"); - institutionUpdate.setSupportPhone("4105551212"); - institutionUpdate.setTaxCode("Tax Code"); - institutionUpdate.setZipCode("21654"); - - Billing billing = new Billing(); - - OnboardingRequest onboardingRequest = new OnboardingRequest(); - onboardingRequest.setInstitutionExternalId("42"); - onboardingRequest.setInstitutionUpdate(institutionUpdate); - onboardingRequest.setPricingPlan("C1"); - onboardingRequest.setProductId("42"); - onboardingRequest.setProductName("Product Name"); - onboardingRequest.setSignContract(true); - onboardingRequest.setUsers(new ArrayList<>()); - onboardingRequest.setBillingRequest(billing); - onboardingRequest.getBillingRequest().setRecipientCode("42"); - - PdfMapper.setupSAProdInteropData(stringObjectMap, institutionUpdate); - assertEquals(4, stringObjectMap.size()); - } - -} -