Remove skipping of the Fabric config code 76/82176/1
authorBenjamin, Max (mb388a) <mb388a@us.att.com>
Wed, 13 Mar 2019 20:10:16 +0000 (16:10 -0400)
committerBenjamin, Max (mb388a) <mb388a@us.att.com>
Wed, 13 Mar 2019 20:10:34 +0000 (16:10 -0400)
Merged the FabricConfig and TestCvnfc tests together.
Remove skipping of the Fabric config code if the Cvnfc already exist.
Instead use the existing cvnfc/vfc object.

Change-Id: Ica648b98a803a54636e0e451590ec94b51f17949
Issue-ID: SO-1653
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java

index a1c660f..cbe16d8 100644 (file)
@@ -30,19 +30,31 @@ import org.onap.sdc.api.notification.INotificationData;
 import org.onap.sdc.api.notification.IResourceInstance;
 import org.springframework.stereotype.Component;
 
-import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
 
 @Component
+@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
 public class NotificationDataImpl implements INotificationData {
 
+       @JsonProperty("distributionID")
        private String distributionID;
+       @JsonProperty("serviceName")
        private String serviceName;
+       @JsonProperty("serviceVersion")
        private String serviceVersion;
+       @JsonProperty("serviceUUID")
        private String serviceUUID;
+       @JsonProperty("serviceDescription")
        private String serviceDescription;
+       @JsonProperty("serviceInvariantUUID")
        private String serviceInvariantUUID;
+       @JsonProperty("resources")
        private List<ResourceInfoImpl> resources;
+       @JsonProperty("serviceArtifacts")
        private List<ArtifactInfoImpl> serviceArtifacts;
+       @JsonProperty("workloadContext")
        private String workloadContext;
 
        @Override
@@ -118,7 +130,6 @@ public class NotificationDataImpl implements INotificationData {
                return ret;
        }
        
-       @JsonIgnore
        public List<ResourceInfoImpl> getResourcesImpl(){
                return resources;
        }
index 892a96e..6d9e2fb 100644 (file)
@@ -1483,7 +1483,6 @@ public class ToscaResourceInstaller {
                        vfModuleMemberName = node.getName();
                }
                
-
                // Extract CVFC lists
                List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC);
                                                
@@ -1491,7 +1490,7 @@ public class ToscaResourceInstaller {
                                                                                                
                        CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet, cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
                        
-                       if(existingCvnfcCustomization == null && (vfModuleMemberName != null && vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName()))){
+                       if(vfModuleMemberName != null && vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())){
                        
                        //Extract associated VFC - Should always be just one
                        List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
@@ -1502,6 +1501,12 @@ public class ToscaResourceInstaller {
                                VnfcCustomization existingVnfcCustomization = null;
                                
                                existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+                               
+                               if(existingVnfcCustomization == null){
+                                       vnfcCustomization = new VnfcCustomization();
+                               } else {
+                                       vnfcCustomization = existingVnfcCustomization;
+                               }
                                        
                                // Only Add Abstract VNFC's to our DB, ignore all others
                                if(existingVnfcCustomization == null && vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")){
@@ -1524,32 +1529,40 @@ public class ToscaResourceInstaller {
                        // This check is needed incase the VFC subcategory is something other than Abstract.  In that case we want to skip adding that record to our DB.
                        if(vnfcCustomization.getModelCustomizationUUID() != null){
                                
-                               CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
-                               cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-                               cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
-                               cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
-                               cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
-                               cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-       
-                               cvnfcCustomization.setModelVersion(
-                                               testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
-                               cvnfcCustomization.setDescription(
-                                               testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
-                               cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
+                               CvnfcCustomization cvnfcCustomization = null;
                                
-                               if(existingVnfcCustomization != null){
-                                       cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
-                               }else{
-                                       cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
+                               if(existingCvnfcCustomization != null){
+                                       cvnfcCustomization = existingCvnfcCustomization;                                        
                                }
+                               else{
                                
-                               cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
-                               cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
-                               cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
-                               cvnfcCustomization.setVnfResourceCustomization(vnfResource);
-
-                               cvnfcCustomizations.add(cvnfcCustomization);
-                               existingCvnfcSet.add(cvnfcCustomization);
+                                       cvnfcCustomization = new CvnfcCustomization();
+                                       cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+                                       cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
+                                       cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+                                       cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+                                       cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+               
+                                       cvnfcCustomization.setModelVersion(
+                                                       testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+                                       cvnfcCustomization.setDescription(
+                                                       testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+                                       cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
+                                       
+                                       if(existingVnfcCustomization != null){
+                                               cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
+                                       }else{
+                                               cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
+                                       }
+                                       
+                                       cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
+                                       cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
+                                       cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
+                                       cvnfcCustomization.setVnfResourceCustomization(vnfResource);
+       
+                                       cvnfcCustomizations.add(cvnfcCustomization);
+                                       existingCvnfcSet.add(cvnfcCustomization);                               
+                        }
                        
                        //*****************************************************************************************************************************************
                        //* Extract Fabric Configuration
@@ -1595,8 +1608,7 @@ public class ToscaResourceInstaller {
             VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
             ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
 
-               Metadata fabricMetadata = fabricTemplate.getMetaData();
-               
+               Metadata fabricMetadata = fabricTemplate.getMetaData(); 
                
                VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();