diff options
author | Kalkere Ramesh, Sharan <sharan.kalkere.ramesh@att.com> | 2020-03-27 10:25:31 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2020-03-27 10:25:32 -0400 |
commit | 8a87bb89e02906a97298af344de37049276fbfdc (patch) | |
tree | f5931253e030fcb15a6d44d83917d975e0e8ad40 | |
parent | 95f9c0e0b6835d96c82d777937920d3571a77ef4 (diff) |
initial commit of testing of grabbing cvnfc cust
initial commit of testing of grabbing cvnfc cust
Update SQL so it properly inserts test data
remove unnecessary test in mso catalog db
updated tosca resource installer to use list not set
fixed compilation issue in asdc rest interface test
Issue-ID: SO-2769
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I9c6e7b6cbb96d9f395903a5a54b5af567eba62f8
8 files changed, 54 insertions, 31 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java index 440270e047..0ffc213a4e 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java @@ -30,13 +30,13 @@ import java.util.List; import javax.transaction.Transactional; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.so.adapters.catalogdb.CatalogDBApplication; import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; +import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClientPortChanger; @@ -44,9 +44,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; public class NetworkCollectionCatalogDbQueryTest extends CatalogDbAdapterBaseTest { @@ -149,4 +146,16 @@ public class NetworkCollectionCatalogDbQueryTest extends CatalogDbAdapterBaseTes assertNotNull(collectionNetworkCust); logger.debug(collectionNetworkCust.getModelCustomizationUUID()); } + + @Test + public void getCvnfcCustomization() { + client.getServiceByID(serviceUUID); + String vfId = "cb82ffd8-252a-11e7-93ae-92361f002671"; + String vnfId = "68dc9a92-214c-11e7-93ae-92361f002671"; + + CvnfcConfigurationCustomization fabricConfig = + client.getCvnfcCustomization(serviceUUID, vnfId, vfId, "dadc2c8c-2bab-11e9-b210-d663bd873d95"); + assertEquals("386c9aa7-9318-48ee-a6d1-1bf0f85de385", fabricConfig.getModelCustomizationUUID()); + } + } diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql index 32c51293c2..8fd171bf64 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql +++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -213,8 +213,30 @@ VALUES ( '1', 'testNfcFunction', 'testNfcNamingCode', '2018-07-17 14:05:08', + '9bcce658-9b37-11e8-98d0-529269fb1459',1), + ( '2', + 'dadc2c8c-2bab-11e9-b210-d663bd873d95', + 'testModelInstanceName', + 'b25735fe-9b37-11e8-98d0-529269fb1459', + 'ba7e6ef0-9b37-11e8-98d0-529269fb1459', + 'testModelVersion', + 'testModelName', + 'testToscaNodeType', + 'testCvnfcCustomzationDescription', + 'testNfcFunction', + 'testNfcNamingCode', + '2018-07-17 14:05:08', '9bcce658-9b37-11e8-98d0-529269fb1459',1); + + +INSERT IGNORE INTO `configuration` (`MODEL_UUID`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `MODEL_NAME`, `TOSCA_NODE_TYPE`, `DESCRIPTION`, `CREATION_TIMESTAMP`) VALUES + ('d2195b0e-307a-4d30-b82f-9c82001d965e', '2f0a4b7a-dfdb-4f82-a2ab-b65d1ddd5e8e', '13.0', 'Fabric Configuration', 'org.openecomp.nodes.FabricConfiguration', 'A fabric Configuration object', '2019-06-04 20:12:20'); + +INSERT IGNORE INTO `cvnfc_configuration_customization` (`MODEL_CUSTOMIZATION_UUID`, `MODEL_INSTANCE_NAME`, `CONFIGURATION_TYPE`, `CONFIGURATION_ROLE`, `CONFIGURATION_FUNCTION`, `POLICY_NAME`, `CREATION_TIMESTAMP`, `CONFIGURATION_MODEL_UUID`, `CVNFC_CUSTOMIZATION_ID`) VALUES + ('386c9aa7-9318-48ee-a6d1-1bf0f85de385', 'Fabric Configuration 0', '5G', 'Fabric Config', 'Network Cloud', 'Config_MS_fabric_configuration_FRWL.1.xml', '2019-06-04 20:12:20', 'd2195b0e-307a-4d30-b82f-9c82001d965e', '2'); + + insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values ('5df8b6de-2083-11e7-93ae-92361f002676', 'PNF_routing_service', '9647dfc4-2083-11e7-93ae-92361f002676', '1.0', 'PNF service', '2019-03-08 12:00:29', null, 'NA', 'NA', 'Luna', 'Oxygen'); @@ -231,4 +253,4 @@ insert into workflow(artifact_uuid, artifact_name, name, operation_name, version ('5b0c4322-643d-4c9f-b184-4516049e99b1', 'testingWorkflow.bpmn', 'testingWorkflow', 'create', 1, 'Test Workflow', null, 'vnf', 'sdc'); insert into vnf_resource_to_workflow(vnf_resource_model_uuid, workflow_id) values -('ff2ae348-214a-11e7-93ae-92361f002671', '1'); +('ff2ae348-214a-11e7-93ae-92361f002671', '1');
\ No newline at end of file diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index f524b96fa9..d023df3b79 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -2036,7 +2036,7 @@ public class ToscaResourceInstaller { // ****************************************************************************************************************** List<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations = new ArrayList<>(); - Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<>(); + List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<>(); Set<VnfcCustomization> vnfcCustomizations = new HashSet<>(); // Only set the CVNFC if this vfModule group is a member of it. diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomization.java index 05d43d093c..33994bae8b 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomization.java @@ -78,11 +78,11 @@ public class CvnfcConfigurationCustomization implements Serializable { @Temporal(TemporalType.TIMESTAMP) private Date created; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "CONFIGURATION_MODEL_UUID") private ConfigurationResource configurationResource; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "CVNFC_CUSTOMIZATION_ID") private CvnfcCustomization cvnfcCustomization; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java index 7fb328fdb5..9bf0cdd6a7 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java @@ -92,11 +92,11 @@ public class CvnfcCustomization implements Serializable { @Temporal(TemporalType.TIMESTAMP) private Date created; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "VF_MODULE_CUSTOMIZATION_ID") private VfModuleCustomization vfModuleCustomization; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "VNFC_CUST_MODEL_CUSTOMIZATION_UUID") private VnfcCustomization vnfcCustomization; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java index 3420682900..83de95874c 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java @@ -21,10 +21,9 @@ package org.onap.so.db.catalog.beans; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; -import java.util.HashSet; import java.util.List; -import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -41,7 +40,6 @@ import javax.persistence.TemporalType; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; -import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import com.fasterxml.jackson.annotation.JsonFormat; import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; @@ -98,7 +96,7 @@ public class VfModuleCustomization implements Serializable { private VnfResourceCustomization vnfCustomization; @OneToMany(cascade = CascadeType.ALL, mappedBy = "vfModuleCustomization") - private Set<CvnfcCustomization> cvnfcCustomization; + private List<CvnfcCustomization> cvnfcCustomization; @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION") private Boolean skipPostInstConf; @@ -233,13 +231,13 @@ public class VfModuleCustomization implements Serializable { } @LinkedResource - public Set<CvnfcCustomization> getCvnfcCustomization() { + public List<CvnfcCustomization> getCvnfcCustomization() { if (cvnfcCustomization == null) - cvnfcCustomization = new HashSet<>(); + cvnfcCustomization = new ArrayList<>(); return cvnfcCustomization; } - public void setCvnfcCustomization(Set<CvnfcCustomization> cvnfcCustomization) { + public void setCvnfcCustomization(List<CvnfcCustomization> cvnfcCustomization) { this.cvnfcCustomization = cvnfcCustomization; } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index 26c33941ed..b130835062 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -915,7 +915,7 @@ public class CatalogDbClient { findVnfResourceCustomizationInList(vnfCustomizationUUID, service.getVnfCustomizations()); VfModuleCustomization vfModuleCust = findVfModuleCustomizationInList(vfModuleCustomizationUUID, vnfResourceCust.getVfModuleCustomizations()); - return vfModuleCust.getCvnfcCustomization().stream().collect(Collectors.toList()); + return vfModuleCust.getCvnfcCustomization(); } public VnfResourceCustomization findVnfResourceCustomizationInList(String vnfCustomizationUUID, @@ -971,10 +971,9 @@ public class CatalogDbClient { List<CvnfcCustomization> cvnfcCustomization = getCvnfcCustomization(serviceModelUUID, vnfCustomizationUuid, vfModuleCustomizationUuid); CvnfcCustomization cvnfc = findCvnfcCustomizationInAList(cvnfcCustomizationUuid, cvnfcCustomization); - List<CvnfcConfigurationCustomization> fabricConfigs = cvnfc - .getCvnfcConfigurationCustomization().stream().filter(cvnfcCustom -> cvnfcCustom - .getConfigurationResource().getToscaNodeType().contains("FabricConfiguration")) - .collect(Collectors.toList()); + List<CvnfcConfigurationCustomization> fabricConfigs = cvnfc.getCvnfcConfigurationCustomization(); + fabricConfigs.stream().filter(cvnfcCustom -> cvnfcCustom.getConfigurationResource().getToscaNodeType() + .contains("FabricConfiguration")).collect(Collectors.toList()); if (fabricConfigs != null && !fabricConfigs.isEmpty() && fabricConfigs.size() == 1) { logger.debug("Found Fabric Configuration: {}", fabricConfigs.get(0)); return fabricConfigs.get(0); diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java index e8addc4aa8..a13deae159 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java @@ -23,14 +23,10 @@ package org.onap.so.db.catalog.data.repository; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; import org.junit.Assert; import org.junit.Test; import org.onap.so.db.catalog.BaseTest; -import org.onap.so.db.catalog.beans.ConfigurationResource; -import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.beans.VfModuleCustomization; @@ -45,6 +41,7 @@ public class CvnfcCustomizationRepositoryTest extends BaseTest { @Autowired private CvnfcCustomizationRepository cvnfcCustomizationRepository; + @Test public void findAllTest() throws Exception { List<CvnfcCustomization> cvnfcCustomizationList = cvnfcCustomizationRepository.findAll(); @@ -125,14 +122,12 @@ public class CvnfcCustomizationRepositoryTest extends BaseTest { vnfResourceCustomization.setVnfResources(vnfResource); - VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); vnfcCustomization.setModelCustomizationUUID("d95d704a-9ff2-11e8-98d0-529269fb1459"); - - cvnfcCustomizationRepository.save(cvnfcCustomization); + List<CvnfcCustomization> cvnfcCustomizationList = cvnfcCustomizationRepository.findByModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); boolean matchFound = false; @@ -173,7 +168,7 @@ public class CvnfcCustomizationRepositoryTest extends BaseTest { vnfResourceCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); vnfResourceCustomization.setModelInstanceName("testModelInstanceName"); - List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList(); + List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>(); vnfResourceCustomizations.add(vnfResourceCustomization); vnfResourceCustomization.setVnfResources(vnfResource); |