From 8a87bb89e02906a97298af344de37049276fbfdc Mon Sep 17 00:00:00 2001 From: "Kalkere Ramesh, Sharan" Date: Fri, 27 Mar 2020 10:25:31 -0400 Subject: 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) Change-Id: I9c6e7b6cbb96d9f395903a5a54b5af567eba62f8 --- .../so/db/catalog/beans/CvnfcConfigurationCustomization.java | 4 ++-- .../org/onap/so/db/catalog/beans/CvnfcCustomization.java | 4 ++-- .../org/onap/so/db/catalog/beans/VfModuleCustomization.java | 12 +++++------- .../java/org/onap/so/db/catalog/client/CatalogDbClient.java | 9 ++++----- .../data/repository/CvnfcCustomizationRepositoryTest.java | 11 +++-------- 5 files changed, 16 insertions(+), 24 deletions(-) (limited to 'mso-catalog-db') 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; + private List cvnfcCustomization; @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION") private Boolean skipPostInstConf; @@ -233,13 +231,13 @@ public class VfModuleCustomization implements Serializable { } @LinkedResource - public Set getCvnfcCustomization() { + public List getCvnfcCustomization() { if (cvnfcCustomization == null) - cvnfcCustomization = new HashSet<>(); + cvnfcCustomization = new ArrayList<>(); return cvnfcCustomization; } - public void setCvnfcCustomization(Set cvnfcCustomization) { + public void setCvnfcCustomization(List 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 = getCvnfcCustomization(serviceModelUUID, vnfCustomizationUuid, vfModuleCustomizationUuid); CvnfcCustomization cvnfc = findCvnfcCustomizationInAList(cvnfcCustomizationUuid, cvnfcCustomization); - List fabricConfigs = cvnfc - .getCvnfcConfigurationCustomization().stream().filter(cvnfcCustom -> cvnfcCustom - .getConfigurationResource().getToscaNodeType().contains("FabricConfiguration")) - .collect(Collectors.toList()); + List 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 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 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 vnfResourceCustomizations = new ArrayList(); + List vnfResourceCustomizations = new ArrayList<>(); vnfResourceCustomizations.add(vnfResourceCustomization); vnfResourceCustomization.setVnfResources(vnfResource); -- cgit 1.2.3-korg