diff --git a/apps/onboarding-functions/pom.xml b/apps/onboarding-functions/pom.xml index 61c5e765a..e375585c6 100644 --- a/apps/onboarding-functions/pom.xml +++ b/apps/onboarding-functions/pom.xml @@ -193,17 +193,17 @@ it.pagopa.selfcare onboarding-sdk-crypto - 0.4.0 + 0.4.1 it.pagopa.selfcare onboarding-sdk-azure-storage - 0.4.0 + 0.4.1 it.pagopa.selfcare onboarding-sdk-product - 0.4.0 + 0.4.1 org.apache.commons diff --git a/apps/onboarding-ms/pom.xml b/apps/onboarding-ms/pom.xml index 0b34b8b2f..0fa11ce1f 100644 --- a/apps/onboarding-ms/pom.xml +++ b/apps/onboarding-ms/pom.xml @@ -243,12 +243,12 @@ it.pagopa.selfcare onboarding-sdk-azure-storage - 0.4.0 + 0.4.1 it.pagopa.selfcare onboarding-sdk-product - 0.4.0 + 0.4.1 diff --git a/apps/pom.xml b/apps/pom.xml index 62180cdae..2050f606d 100644 --- a/apps/pom.xml +++ b/apps/pom.xml @@ -16,7 +16,7 @@ it.pagopa.selfcare onboarding-sdk-common - 0.4.0 + 0.4.1 diff --git a/libs/onboarding-sdk-azure-storage/pom.xml b/libs/onboarding-sdk-azure-storage/pom.xml index e0b53e6d5..946de1e7b 100644 --- a/libs/onboarding-sdk-azure-storage/pom.xml +++ b/libs/onboarding-sdk-azure-storage/pom.xml @@ -6,7 +6,7 @@ it.pagopa.selfcare onboarding-sdk-pom - 0.4.0 + 0.4.1 ../onboarding-sdk-pom diff --git a/libs/onboarding-sdk-common/pom.xml b/libs/onboarding-sdk-common/pom.xml index 8d59ebe10..e380556c8 100644 --- a/libs/onboarding-sdk-common/pom.xml +++ b/libs/onboarding-sdk-common/pom.xml @@ -4,7 +4,7 @@ it.pagopa.selfcare onboarding-sdk-pom - 0.4.0 + 0.4.1 ../onboarding-sdk-pom onboarding-sdk-common diff --git a/libs/onboarding-sdk-crypto/pom.xml b/libs/onboarding-sdk-crypto/pom.xml index 0ee3014cd..c470b7397 100644 --- a/libs/onboarding-sdk-crypto/pom.xml +++ b/libs/onboarding-sdk-crypto/pom.xml @@ -4,7 +4,7 @@ it.pagopa.selfcare onboarding-sdk-pom - 0.4.0 + 0.4.1 ../onboarding-sdk-pom onboarding-sdk-crypto diff --git a/libs/onboarding-sdk-pom/pom.xml b/libs/onboarding-sdk-pom/pom.xml index 78e65a0aa..472f5c72b 100644 --- a/libs/onboarding-sdk-pom/pom.xml +++ b/libs/onboarding-sdk-pom/pom.xml @@ -6,7 +6,7 @@ onboarding-sdk-pom pom onboarding-sdk-pom - 0.4.0 + 0.4.1 17 diff --git a/libs/onboarding-sdk-product/pom.xml b/libs/onboarding-sdk-product/pom.xml index d54bbc7b7..96a01c197 100644 --- a/libs/onboarding-sdk-product/pom.xml +++ b/libs/onboarding-sdk-product/pom.xml @@ -4,12 +4,12 @@ it.pagopa.selfcare onboarding-sdk-pom - 0.4.0 + 0.4.1 ../onboarding-sdk-pom onboarding-sdk-product onboarding-sdk-product - 0.4.0 + 0.4.1 2.15.2 diff --git a/libs/onboarding-sdk-product/src/main/java/it/pagopa/selfcare/product/entity/PHASE_ADDITION_ALLOWED.java b/libs/onboarding-sdk-product/src/main/java/it/pagopa/selfcare/product/entity/PHASE_ADDITION_ALLOWED.java index 6c4cb863e..acab1b80e 100644 --- a/libs/onboarding-sdk-product/src/main/java/it/pagopa/selfcare/product/entity/PHASE_ADDITION_ALLOWED.java +++ b/libs/onboarding-sdk-product/src/main/java/it/pagopa/selfcare/product/entity/PHASE_ADDITION_ALLOWED.java @@ -9,7 +9,10 @@ public enum PHASE_ADDITION_ALLOWED { DASHBOARD("dashboard"), //Phase on dashboard "Aggiunta Utenti" when a sign contract is needed - DASHBOARD_ASYNC("dashboard-async"); + DASHBOARD_ASYNC("dashboard-async"), + + //Phase on dashboard "Aggiunta Utenti" for aggregators when a sign contract is needed + DASHBOARD_AGGREGATOR("dashboard-aggregator"); public final String value; diff --git a/libs/onboarding-sdk-product/src/main/java/it/pagopa/selfcare/product/entity/Product.java b/libs/onboarding-sdk-product/src/main/java/it/pagopa/selfcare/product/entity/Product.java index f926b4374..e61c66955 100644 --- a/libs/onboarding-sdk-product/src/main/java/it/pagopa/selfcare/product/entity/Product.java +++ b/libs/onboarding-sdk-product/src/main/java/it/pagopa/selfcare/product/entity/Product.java @@ -1,9 +1,10 @@ package it.pagopa.selfcare.product.entity; import it.pagopa.selfcare.onboarding.common.PartyRole; +import org.apache.commons.lang3.StringUtils; + import java.time.Instant; import java.util.*; -import org.apache.commons.lang3.StringUtils; public class Product { @@ -36,6 +37,7 @@ public class Product { private List consumers; private Map institutionContractMappings; private Map userContractMappings; + private Map userAggregatorContractMappings; public String getId() { return id; @@ -300,6 +302,14 @@ public void setUserContractMappings(Map userContractMa this.userContractMappings = userContractMappings; } + public Map getUserAggregatorContractMappings() { + return userAggregatorContractMappings; + } + + public void setUserAggregatorContractMappings(Map userAggregatorContractMappings) { + this.userAggregatorContractMappings = userAggregatorContractMappings; + } + public String getAlias() { return alias; } @@ -347,4 +357,24 @@ && getInstitutionContractMappings().containsKey(institutionType)) { } return contractTemplate; } + + /** + * This method returns ContractTemplate associate with a specific InstitutionType for UserAggregatorContract. + * In case none InstitutionType exists on contractMapping, it returns the default ContractTemplate. + * + * @param institutionType InstitutionType + * @return ContractTemplate + */ + public ContractTemplate getUserAggregatorContractTemplate(String institutionType) { + ContractTemplate userAggregatorContractTemplate = new ContractTemplate(); + if (Objects.nonNull(getUserAggregatorContractMappings())) { + if (Objects.nonNull(institutionType) + && getUserAggregatorContractMappings().containsKey(institutionType)) { + userAggregatorContractTemplate = getUserAggregatorContractMappings().get(institutionType); + } else if (getUserAggregatorContractMappings().containsKey(CONTRACT_TYPE_DEFAULT)) { + userAggregatorContractTemplate = getUserAggregatorContractMappings().get(CONTRACT_TYPE_DEFAULT); + } + } + return userAggregatorContractTemplate; + } } diff --git a/libs/onboarding-sdk-product/src/test/java/it/pagopa/selfcare/product/entity/ProductTest.java b/libs/onboarding-sdk-product/src/test/java/it/pagopa/selfcare/product/entity/ProductTest.java index 68a129af5..094c549f6 100644 --- a/libs/onboarding-sdk-product/src/test/java/it/pagopa/selfcare/product/entity/ProductTest.java +++ b/libs/onboarding-sdk-product/src/test/java/it/pagopa/selfcare/product/entity/ProductTest.java @@ -1,16 +1,10 @@ package it.pagopa.selfcare.product.entity; -import static org.junit.jupiter.api.Assertions.*; - import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import it.pagopa.selfcare.onboarding.common.InstitutionType; import it.pagopa.selfcare.onboarding.common.PartyRole; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.*; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.DisplayName; @@ -18,6 +12,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.*; + +import static org.junit.jupiter.api.Assertions.*; + public class ProductTest { private static final Logger log = LoggerFactory.getLogger(ProductTest.class); @@ -277,4 +278,58 @@ void productTest() { .asText()); assertEquals(product.getStatus().toString(), jsonNode.get("status").asText()); } + + @Test + void testGetUserAggregatorContractTemplate_WithValidInstitutionType() { + // Setup + Product product = new Product(); + Map mappings = new HashMap<>(); + ContractTemplate contractTemplate = new ContractTemplate(); + contractTemplate.setContractTemplatePath("path"); + contractTemplate.setContractTemplatePath("version"); + mappings.put("validType", contractTemplate); + product.setUserAggregatorContractMappings(mappings); + + // Execute + ContractTemplate result = product.getUserAggregatorContractTemplate("validType"); + + // Verify + assertNotNull(result); + assertEquals(mappings.get("validType"), result); + } + + @Test + void testGetUserAggregatorContractTemplate_WithDefault() { + // Setup + Product product = new Product(); + Map mappings = new HashMap<>(); + ContractTemplate contractTemplate = new ContractTemplate(); + contractTemplate.setContractTemplatePath("path"); + contractTemplate.setContractTemplatePath("version"); + mappings.put("default", contractTemplate); + product.setUserAggregatorContractMappings(mappings); + + // Execute + ContractTemplate result = product.getUserAggregatorContractTemplate("unknownType"); + + // Verify + assertNotNull(result); + assertEquals(mappings.get("default"), result); + } + + @Test + void testGetUserAggregatorContractTemplate_NoMappings() { + // Setup + Product product = new Product(); + product.setUserAggregatorContractMappings(null); + + // Execute + ContractTemplate result = product.getUserAggregatorContractTemplate("anyType"); + + // Verify + assertNotNull(result); + assertEquals(ContractTemplate.class, result.getClass()); + assertNull(result.getContractTemplatePath()); + assertNull(result.getContractTemplateVersion()); + } } diff --git a/test-coverage/pom.xml b/test-coverage/pom.xml index b42a7533a..14460340f 100644 --- a/test-coverage/pom.xml +++ b/test-coverage/pom.xml @@ -77,22 +77,22 @@ it.pagopa.selfcare onboarding-sdk-product - 0.4.0 + 0.4.1 it.pagopa.selfcare onboarding-sdk-common - 0.4.0 + 0.4.1 it.pagopa.selfcare onboarding-sdk-azure-storage - 0.4.0 + 0.4.1 it.pagopa.selfcare onboarding-sdk-crypto - 0.4.0 + 0.4.1