UEB Listener Final cleanup of deprecated sdc-tosca parser APIs 65/97865/2
authorlalena.aria <lalena.aria@att.com>
Fri, 1 Nov 2019 18:19:55 +0000 (18:19 +0000)
committerTimoney, Dan (dt5972) <dtimoney@att.com>
Thu, 7 Nov 2019 16:36:17 +0000 (11:36 -0500)
Changes made:
Replace references to all deprecated sdc-tosca parser APIs
and replace with Entity-based equivalent.
Changes are primarily in SdncBaseModel and junit test files.

Issue-ID: CCSDK-1880
Change-Id: I5d7f12cdbebcfcb7d2487b6474cd7eb92eb32b9b
Signed-off-by: lalena.aria <lalena.aria@att.com>
14 files changed:
lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java
ueb-listener/pom.xml
ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java
ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java
ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java
ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java
ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java
ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java
ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java
ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java
ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java
ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java
ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java

index 002e05e..0e4413a 100644 (file)
@@ -22,6 +22,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicLoader;
 import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
 import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
 import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicClassResolver;
 import org.onap.ccsdk.sli.core.sli.provider.base.BlockNodeExecutor;
 import org.onap.ccsdk.sli.core.sli.provider.base.CallNodeExecutor;
 import org.onap.ccsdk.sli.core.sli.provider.base.ConfigureNodeExecutor;
@@ -171,7 +172,7 @@ public class TestLcmProvider {
         loader.loadAndActivate();
 
         // Create a ServiceLogicService
-        SvcLogicServiceImpl svc = new SvcLogicServiceImpl(new SvcLogicPropertiesProviderImpl());
+        SvcLogicServiceImpl svc = new SvcLogicServiceImpl(new SvcLogicPropertiesProviderImpl(), new SvcLogicClassResolver());
 
         // Finally ready to create sliapiProvider
         LcmSliClient client = new LcmSliClient(svc);
index 9e7e416..8bd81fe 100755 (executable)
@@ -44,6 +44,7 @@
         <dependency>
             <groupId>org.onap.sdc.sdc-distribution-client</groupId>
             <artifactId>sdc-distribution-client</artifactId>
+            <version>1.4.1-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.onap.ccsdk.sli.core</groupId>
             <artifactId>dblib-provider</artifactId>
         </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.13</version>
+        </dependency>
     </dependencies>
 
     <build>
index 7ab431d..bced6a8 100644 (file)
@@ -39,9 +39,6 @@ import org.onap.sdc.tosca.parser.enums.SdcTypes;
 import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
 import org.onap.sdc.toscaparser.api.CapabilityAssignment;
 import org.onap.sdc.toscaparser.api.CapabilityAssignments;
-import org.onap.sdc.toscaparser.api.Group;
-import org.onap.sdc.toscaparser.api.NodeTemplate;
-import org.onap.sdc.toscaparser.api.Policy;
 import org.onap.sdc.toscaparser.api.Property;
 import org.onap.sdc.toscaparser.api.elements.Metadata;
 import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
@@ -74,37 +71,22 @@ public class SdncBaseModel {
        protected ISdcCsarHelper sdcCsarHelper = null;
        protected static DBResourceManager jdbcDataSource = null;
        protected static SdncUebConfiguration config = null;
-       protected NodeTemplate nodeTemplate = null;
        protected IEntityDetails entityDetails = null;
-       
-       public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate, DBResourceManager jdbcDataSource) {
-               this (sdcCsarHelper, nodeTemplate);
-               this.sdcCsarHelper = sdcCsarHelper;
-               this.nodeTemplate = nodeTemplate;
-               this.jdbcDataSource = jdbcDataSource;           
-       }
 
-       public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
-               this (sdcCsarHelper, nodeTemplate);
-               this.sdcCsarHelper = sdcCsarHelper;
-               this.nodeTemplate = nodeTemplate;
-               this.jdbcDataSource = jdbcDataSource;           
-               this.config = config;
-       }
        
        public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails entityDetails, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
                this (sdcCsarHelper, entityDetails);
                this.sdcCsarHelper = sdcCsarHelper;
                this.entityDetails = entityDetails;
-               this.jdbcDataSource = jdbcDataSource;           
-               this.config = config;
+               SdncBaseModel.jdbcDataSource = jdbcDataSource;          
+               SdncBaseModel.config = config;
        }
 
        public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, Metadata metadata, DBResourceManager jdbcDataSource) {
 
                params = new HashMap<String, String>();
                this.sdcCsarHelper = sdcCsarHelper;
-               this.jdbcDataSource = jdbcDataSource;
+               SdncBaseModel.jdbcDataSource = jdbcDataSource;
 
                // extract service metadata
                invariantUUID = extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
@@ -116,28 +98,6 @@ public class SdncBaseModel {
                addParameter(PARAM_TYPE_KEY,extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_TYPE));
                addParameter(PARAM_CATEGORY_KEY,extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY));
        }
-
-       public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate) {
-
-               params = new HashMap<String, String>();
-               attributeValueParams = new HashMap<String, String>();
-               this.sdcCsarHelper = sdcCsarHelper;
-               this.nodeTemplate = nodeTemplate;
-
-               // extract common nodeTemplate metadata
-               Metadata metadata = nodeTemplate.getMetaData();
-               customizationUUID = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
-               invariantUUID = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
-               addParameter(PARAM_INVARIANT_UUID_KEY, invariantUUID);
-               UUID = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_UUID);
-               addParameter(PARAM_UUID_KEY, UUID);
-               addParameter(PARAM_VERSION_KEY, extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VERSION));
-               
-               // extract common nodeTemplate properties
-               //addParameter("ecomp_generated_naming", extractValue (nodeTemplate, "naming#ecompnaming")); // should be extractBooleanValue?
-               //addParameter("naming_policy", extractValue (nodeTemplate, "naming#namingpolicy"));
-               
-       }
        
        public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails entityDetails) {
 
@@ -192,8 +152,8 @@ public class SdncBaseModel {
                String metadataType = "";
                if (!type.isEmpty()) metadataType = type;
                else {
-                       Metadata metadata = nodeTemplate.getMetaData();
-                       metadataType = sdcCsarHelper.getMetadataPropertyValue(metadata, PARAM_TYPE_KEY);
+                       Metadata metadata = entityDetails.getMetadata();
+                       metadataType = extractValue (metadata, PARAM_TYPE_KEY);
                }
                
                // Clean up all attributes for this resource
@@ -466,7 +426,7 @@ public class SdncBaseModel {
                                CachedRowSet rowData = getToscaData("NODE_CAPABILITY", nodeCapabilityParams);
                                rowData.first();
                                int capabilityIdint = rowData.getInt("capability_id");
-                               capabilityId = capabilityId.valueOf(capabilityIdint);
+                               capabilityId = String.valueOf(capabilityIdint);
                                
                        } catch (IOException | SQLException e) {
                                LOG.error("Could not insert Tosca CSAR data into the NODE_CAPABILITY table");
@@ -477,12 +437,11 @@ public class SdncBaseModel {
                }
        }
        
-       protected void insertNodeCapabilitiesEntityData (Map<String, CapabilityAssignment> capabilities) throws IOException {           
+       protected void insertNodeCapabilitiesEntityData (List<CapabilityAssignment> capabilities) throws IOException {          
                
                // Process the capabilities             
-               for (Map.Entry<String, CapabilityAssignment> entry : capabilities.entrySet()) {
-                   CapabilityAssignment capability = entry.getValue();         
-                                                       
+               for (CapabilityAssignment capability :  capabilities) {
+                       
                        // Insert into NODE_CAPABILITY: 
                        // capability_id (generated) 
                        // capability_provider_uuid - UUID of this node 
@@ -528,7 +487,7 @@ public class SdncBaseModel {
                                CachedRowSet rowData = getToscaData("NODE_CAPABILITY", nodeCapabilityParams);
                                rowData.first();
                                int capabilityIdint = rowData.getInt("capability_id");
-                               capabilityId = capabilityId.valueOf(capabilityIdint);
+                               capabilityId = String.valueOf(capabilityIdint);
                                
                        } catch (IOException | SQLException e) {
                                LOG.error("Could not insert Tosca CSAR data into the NODE_CAPABILITY table");
@@ -596,7 +555,7 @@ public class SdncBaseModel {
        }
 
        protected String extractValue (Metadata metadata, String name) {
-               String value = sdcCsarHelper.getMetadataPropertyValue(metadata, name);
+               String value = metadata.getValue(name);
                if (value != null) {
                        return value;
                } else {
@@ -605,7 +564,7 @@ public class SdncBaseModel {
        }
 
        protected String extractBooleanValue (Metadata metadata, String name) {
-               String value = sdcCsarHelper.getMetadataPropertyValue(metadata, name);
+               String value = metadata.getValue(name);
                if (value != null && !value.isEmpty()) {
                        return value.contains("true") ? "Y" : "N";
                } else {
@@ -614,16 +573,7 @@ public class SdncBaseModel {
        }
 
        public static String extractValue (ISdcCsarHelper sdcCsarHelper, Metadata metadata, String name) {
-               String value = sdcCsarHelper.getMetadataPropertyValue(metadata, name);
-               if (value != null) {
-                       return value;
-               } else {
-                       return "";
-               }
-       }
-
-       protected String extractValue (NodeTemplate nodeTemplate, String name) {
-               String value = sdcCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, name);
+               String value = metadata.getValue(name);
                if (value != null) {
                        return value;
                } else {
@@ -676,6 +626,18 @@ public class SdncBaseModel {
                }
        }
        
+       protected String extractValue (IEntityDetails  entityDetails, String path1, String path2, String path3, String name) {
+               String value = ""; 
+               
+               value = extractNestedValue (entityDetails, path1, path2, path3, name);          
+
+               if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
+                       return value;
+               } else {
+                       return "";
+               }
+       }
+       
        protected String extractBooleanValue (IEntityDetails  entityDetails, String path1, String path2, String name) {
                String value = ""; 
                
@@ -707,6 +669,28 @@ public class SdncBaseModel {
                return value;
        }
 
+       protected String extractNestedValue (IEntityDetails  entityDetails, String path1, String path2, String path3, String name) {
+               String value = ""; 
+               
+               if (entityDetails.getProperties().containsKey(path1)) {
+                       Property path1Property = entityDetails.getProperties().get(path1);
+                       if (path1Property != null) {
+                               Map<String, Object> path1PropertyValue = (Map<String, Object>) path1Property.getValue();
+                               if (path1PropertyValue.containsKey(path2)) {
+                                       Map<String, Object> path2PropertyValue = (Map<String, Object>) path1PropertyValue.get(path2);
+                                       if (path2PropertyValue != null && path2PropertyValue.containsKey(path3)) {
+                                               Map<String, Object> path3PropertyValue = (Map<String, Object>) path2PropertyValue.get(path3);
+                                               if (path3PropertyValue != null && path3PropertyValue.containsKey(name)) {
+                                                       value = path3PropertyValue.get(name).toString();
+                                               }
+                                       }
+                               }
+                       }
+               }                       
+
+               return value;
+       }
+
        protected String extractIntegerValue (Property property, String name) {
                String value = ""; 
                
@@ -758,36 +742,15 @@ public class SdncBaseModel {
 
        }
 
-       // Remove this after migrate SdncVFModel to getEntity
-       protected String extractGetInputValue (Group group, NodeTemplate nodeTemplate, String name) {
-
-               String value = sdcCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, extractGetInputName (group, name));
-               if (value != null) {
-                       return value;
-               } else {
-                       return "";
-               }
-       }
-
-       // Remove this after migrate SdncVFModel to getEntity
-       protected String extractGetInputName (Group group, String name) {
+       protected String extractValue (CapabilityAssignment capability, String name) {
+               String value = "";
                
-               String getInputName = name;
-               String groupProperty = sdcCsarHelper.getGroupPropertyLeafValue(group, name);
-               if (groupProperty != null) {
-               int getInputIndex = groupProperty.indexOf("{get_input=");
-                       if (getInputIndex > -1) {
-                               getInputName = groupProperty.substring(getInputIndex+11, groupProperty.length()-1);
-                       }
-               }
+               if (capability.getProperties().containsKey(name)) {
+                       Property property = capability.getProperties().get(name);
+                       value = property.getLeafPropertyValue(name).get(0);
+               }                       
                
-               return getInputName;
-
-       }
-       
-       protected String extractValue (CapabilityAssignment capability, String name) {
-               String value = sdcCsarHelper.getCapabilityPropertyLeafValue(capability, name);
-               if (value != null) {
+               if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
                        return value;
                } else {
                        return "";
@@ -810,15 +773,6 @@ public class SdncBaseModel {
                        return "";
                }
        }
-       
-       protected String extractBooleanValue (NodeTemplate nodeTemplate, String name) {
-               String value = sdcCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, name);
-               if (value != null && !value.isEmpty()) {
-                       return value.contains("true") ? "Y" : "N";
-               } else {
-                       return "";
-               }
-       }
 
        protected String extractBooleanValue (IEntityDetails entityDetails, String name) {
                String value = null; 
@@ -854,8 +808,15 @@ public class SdncBaseModel {
                }
        }
 
-       protected Object extractObjectValue (NodeTemplate nodeTemplate, String name) {
-               Object value = sdcCsarHelper.getNodeTemplatePropertyValueAsObject(nodeTemplate, name);
+       protected Object extractObjectValue (IEntityDetails entityDetails, String name) {
+               Object value = ""; 
+               if (entityDetails.getProperties().containsKey(name)) {
+                       Property property = entityDetails.getProperties().get(name);
+                       if (property != null && property.getValue() != null) {
+                               value = property.getValue();
+                       }
+               }
+               
                if (value != null) {
                        return value;
                } else {
@@ -1030,7 +991,7 @@ public class SdncBaseModel {
        
        protected boolean cleanupExistingToscaData(String tableName, Map<String, String> keyParams) throws IOException
     {
-                       return SdncBaseModel.cleanupExistingToscaData(this.jdbcDataSource, tableName, keyParams);
+                       return SdncBaseModel.cleanupExistingToscaData(SdncBaseModel.jdbcDataSource, tableName, keyParams);
     }
        
        public static boolean cleanupExistingToscaData(DBResourceManager jdbcDataSource, String tableName, Map<String, String> keyParams) throws IOException
index 65b20e6..8e790d9 100644 (file)
@@ -137,44 +137,47 @@ public class SdncNodeModel extends SdncBaseModel {
        
        public void insertRelatedNetworkRoleData () throws IOException {
                
-               if (entityDetails.getProperties().containsKey("related_networks")) {
+               if (entityDetails.getProperties().containsKey("network_assignments")) {
                        
-                       Property relatedNetworksProperty = entityDetails.getProperties().get("related_networks");
-                       List<String> relatedNetworkRoles = relatedNetworksProperty.getLeafPropertyValue("related_network_role");
+                       Map<String, Object> networkAssignmentsPropertyValue = (Map<String, Object>) entityDetails.getProperties().get("network_assignments").getValue();
                        
-                       String networkModelCustomizationUUID = getCustomizationUUID();
-               
-               try {
-                       cleanUpExistingToscaData("RELATED_NETWORK_ROLE", "network_model_customization_uuid", networkModelCustomizationUUID);
-               } catch (IOException e) {
-                       LOG.error("Could not clean up Tosca CSAR data in the RELATED_NETWORK_ROLE table");
-                       throw new IOException (e);
-               }
-
-                       for (String relatedNetworkRole : relatedNetworkRoles) {
-
-               LOG.debug("Node Template [" + entityDetails.getName() + "], property [" + "related_network_role" + "] property value: " + relatedNetworkRole);
-                
-                               try {
-                                       // Table cleanup RELATED_NETWORK_ROLE occurs per network
-                                       // If related_network_role for this service already exist in RELATED_NETWORK_ROLE, don't attempt insertion
-                                       Map<String, String> relatedNetworkRoleParamsCheck = new HashMap<String, String>();
-                                       addParameter("related_network_role", relatedNetworkRole, relatedNetworkRoleParamsCheck);
-                                       addParameter("network_model_customization_uuid", networkModelCustomizationUUID, relatedNetworkRoleParamsCheck);
-                                       if (checkForExistingToscaData("RELATED_NETWORK_ROLE", relatedNetworkRoleParamsCheck) == false) { 
-                                               relatedNetworkRoleParamsCheck.remove("related_network_role");
-                                       LOG.info("Call insertToscaData for RELATED_NETWORK_ROLE where network_model_customization_uuid = " + networkModelCustomizationUUID);
-                                       insertToscaData(buildSql("RELATED_NETWORK_ROLE", "related_network_role", "\"" + relatedNetworkRole + "\"", model_yaml, relatedNetworkRoleParamsCheck), null);
+                       if (networkAssignmentsPropertyValue != null && networkAssignmentsPropertyValue.containsKey("related_networks")) {
+                               
+                               ArrayList<Map<String, String>> relatedNetworkList = (ArrayList) networkAssignmentsPropertyValue.get("related_networks");
+                               String networkModelCustomizationUUID = getCustomizationUUID();
+                       
+                       try {
+                               cleanUpExistingToscaData("RELATED_NETWORK_ROLE", "network_model_customization_uuid", networkModelCustomizationUUID);
+                       } catch (IOException e) {
+                               LOG.error("Could not clean up Tosca CSAR data in the RELATED_NETWORK_ROLE table");
+                               throw new IOException (e);
+                       }
+                       
+                       for (Map<String, String> relatedNetworkValue : relatedNetworkList) {
+                               String relatedNetworkRoleValue = relatedNetworkValue.get("related_network_role");
+                       LOG.debug("Node Template [" + entityDetails.getName() + "], property [" + "related_network_role" + "] property value: " + relatedNetworkRoleValue);
+                       
+                                       try {
+                                               // Table cleanup RELATED_NETWORK_ROLE occurs per network
+                                               // If related_network_role for this service already exist in RELATED_NETWORK_ROLE, don't attempt insertion
+                                               Map<String, String> relatedNetworkRoleParamsCheck = new HashMap<String, String>();
+                                               addParameter("related_network_role", relatedNetworkRoleValue, relatedNetworkRoleParamsCheck);
+                                               addParameter("network_model_customization_uuid", networkModelCustomizationUUID, relatedNetworkRoleParamsCheck);
+                                               if (checkForExistingToscaData("RELATED_NETWORK_ROLE", relatedNetworkRoleParamsCheck) == false) { 
+                                                       relatedNetworkRoleParamsCheck.remove("related_network_role");
+                                               LOG.info("Call insertToscaData for RELATED_NETWORK_ROLE where network_model_customization_uuid = " + networkModelCustomizationUUID);
+                                               insertToscaData(buildSql("RELATED_NETWORK_ROLE", "related_network_role", "\"" + relatedNetworkRoleValue + "\"", model_yaml, relatedNetworkRoleParamsCheck), null);
+                                               }
+                                       } catch (IOException e) {
+                                               LOG.debug("Could not insert Tosca CSAR data into the RELATED_NETWORK_ROLE table");
+                                               throw new IOException (e);
                                        }
-                               } catch (IOException e) {
-                                       LOG.debug("Could not insert Tosca CSAR data into the RELATED_NETWORK_ROLE table");
-                                       throw new IOException (e);
-                               }
-            }
-        }
-        else {
-               LOG.debug("Node Template [" + entityDetails.getName() + "], property [" + "related_networks" + "] property value: " + null);
-        }
+                   }
+               }
+               else {
+                       LOG.debug("Node Template [" + entityDetails.getName() + "], property [" + "related_networks" + "] property value: " + null);
+               }
+               }
                
        }
        
index a366260..8c3a290 100644 (file)
@@ -195,7 +195,7 @@ public class SdncUebCallback implements INotificationCallback {
     }
 
     private final IDistributionClient client;
-    private final SdncUebConfiguration config;
+    protected final SdncUebConfiguration config;
 
     private LinkedList<DeployableArtifact> deployList[];
 
index 734dee2..11556df 100644 (file)
@@ -9,7 +9,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
 import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
  
  public class SdncARModelTest {
@@ -19,10 +19,12 @@ import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
         @Before
         public void setUp() throws Exception {
                ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
-               NodeTemplate nodeTemplate = mock(NodeTemplate.class);
+               Metadata mockMetadata = mock(Metadata.class);
                IEntityDetails mockEntityDetails = mock(IEntityDetails.class); 
                DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
                SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
+               
+               when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
 
                testSdncARModel = new SdncARModel(mockCsarHelper,mockEntityDetails,mockDBResourceManager,mockSdncUebConfiguration);
                assertNotNull(testSdncARModel);
index 3b2cd96..0dfbf08 100644 (file)
@@ -8,6 +8,7 @@ import java.io.IOException;
 import org.junit.Test;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
 import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
  
  public class SdncGroupModelTest {
@@ -17,8 +18,13 @@ import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
                ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
                IEntityDetails group = mock(IEntityDetails.class);
                IEntityDetails entityDetails = mock(IEntityDetails.class);
+               Metadata mockMetadata = mock(Metadata.class);
                DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
                SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
+               
+               when(entityDetails.getMetadata()).thenReturn(mockMetadata);
+               when(group.getMetadata()).thenReturn(mockMetadata);
+               
                SdncGroupModel testSdncGroupModel = null;
                try {
                        testSdncGroupModel = new SdncGroupModel(mockCsarHelper,group,entityDetails,mockSdncUebConfiguration,mockDBResourceManager);
index 9f859e7..3f4728f 100644 (file)
@@ -26,7 +26,7 @@ public class SdncNodeModelTest {
                DBResourceManager mockDBResourceManager = mock(DBResourceManager.class); 
                
                when(entityDetails.getMetadata()).thenReturn(mockMetadata);
-               when(isdcCsarHelper.getMetadataPropertyValue(mockMetadata, "customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
+               when(mockMetadata.getValue("customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
                
                sdncNodeModel = new SdncNodeModel(isdcCsarHelper, entityDetails, mockDBResourceManager, config); 
                sdncNodeModel.setServiceUUID("0e8d757f-1c80-40af-85de-31d64f1f5af8"); 
index d4c06b0..97c3942 100644 (file)
@@ -31,7 +31,7 @@ import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
                SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
                
                when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
-               when(mockCsarHelper.getMetadataPropertyValue(mockMetadata, "customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
+               when(mockMetadata.getValue("customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
                mockProperty.setValue("test-nf-naming-code");
                when(mockProperties.get("nf_naming_code")).thenReturn(mockProperty);
                
index af17e22..b86a8e1 100644 (file)
@@ -3,8 +3,6 @@ package org.onap.ccsdk.sli.northbound.uebclient;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
-import java.io.IOException;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
@@ -21,10 +19,9 @@ import org.onap.sdc.toscaparser.api.elements.Metadata;
                DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
                Metadata mockMetadata = mock(Metadata.class);
                
-               when(mockCsarHelper.getMetadataPropertyValue(mockMetadata, "UUID")).thenReturn("aaaa-bbbb-cccc-dddd");
-               when(mockCsarHelper.getMetadataPropertyValue(mockMetadata, "invariantUUID")).thenReturn("bbbb-cccc-dddd-eeee");
-               when(mockCsarHelper.getMetadataPropertyValue(mockMetadata, "namingPolicy")).thenReturn("test-naming-policy");
-               
+               when(mockMetadata.getValue("UUID")).thenReturn("aaaa-bbbb-cccc-dddd");
+               when(mockMetadata.getValue("invariantUUID")).thenReturn("bbbb-cccc-dddd-eeee");
+               when(mockMetadata.getValue("namingPolicy")).thenReturn("test-naming-policy");
                testSdncServiceModel = new SdncServiceModel(mockCsarHelper,mockMetadata,mockDBResourceManager);
 
                assertNotNull(testSdncServiceModel);
index 768eed8..f868052 100644 (file)
@@ -7,36 +7,29 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
-import java.util.ArrayList;
 
 import org.junit.Before; 
 import org.junit.Test;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; 
-import org.onap.sdc.toscaparser.api.NodeTemplate;
 import org.onap.sdc.toscaparser.api.elements.Metadata;
 import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
  
 public class SdncVFCModelTest { 
  
        SdncVFCModel testSdncVFCModel; 
-       NodeTemplate mockVFCNodeTemplate = null;
        IEntityDetails mockEntityDetails = null;
  
        @Before 
        public void setup() { 
                ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class); 
-               NodeTemplate mockNodeTemplate = mock(NodeTemplate.class); 
                mockEntityDetails = mock(IEntityDetails.class); 
-               mockVFCNodeTemplate = mock(NodeTemplate.class); 
                Metadata mockMetadata = mock(Metadata.class);
                DBResourceManager mockDBResourceManager = mock(DBResourceManager.class); 
                SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
                
-               when(mockNodeTemplate.getMetaData()).thenReturn(mockMetadata);
                when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
-               when(mockCsarHelper.getMetadataPropertyValue(mockMetadata, "customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
-               when(mockCsarHelper.getNodeTemplatePropertyLeafValue(mockNodeTemplate, "nfc_naming_code")).thenReturn("test-nfc-naming-code");
+               when(mockMetadata.getValue("customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
                
                Map<String,Map<String,Object>> cpPropertiesMap = new HashMap<String,Map<String,Object>>();
                Map<String,Object> propertiesMap = new HashMap<String,Object>();
@@ -53,7 +46,6 @@ public class SdncVFCModelTest {
 
                propertiesMap.put("ip_requirements", ipRequirementsList);
                cpPropertiesMap.put("cp-node-1", propertiesMap);
-               when(mockCsarHelper.getCpPropertiesFromVfcAsObject(mockVFCNodeTemplate)).thenReturn(cpPropertiesMap);
                
                try {
                        testSdncVFCModel = new SdncVFCModel(mockCsarHelper, mockEntityDetails, mockDBResourceManager, mockSdncUebConfiguration);
index f20c1ed..93f7d34 100644 (file)
@@ -33,8 +33,8 @@ import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
                
                when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
                when(mockEntityDetails.getProperties()).thenReturn(mockProperties);
-               when(mockCsarHelper.getMetadataPropertyValue(mockMetadata, "customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
-               when(mockCsarHelper.getMetadataPropertyValue(mockMetadata, SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn("VF");
+               when(mockMetadata.getValue("customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
+               when(mockMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn("VF");
                mockProperty.setValue("test-nf-naming-code");
                when(mockProperties.get("nf_naming_code")).thenReturn(mockProperty);            
                try {
index 846b79b..e19e8df 100644 (file)
@@ -1,12 +1,13 @@
 package org.onap.ccsdk.sli.northbound.uebclient; 
  
 import static org.junit.Assert.*; 
-import static org.mockito.Mockito.mock; 
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import org.junit.Test;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; 
-import org.onap.sdc.toscaparser.api.Group; 
+import org.onap.sdc.toscaparser.api.elements.Metadata;
 import org.onap.ccsdk.sli.northbound.uebclient.SdncVFModel;
  
 public class SdncVFModuleModelTest { 
@@ -14,8 +15,12 @@ public class SdncVFModuleModelTest {
        @Test 
        public void testSdncVFModuleModelConstructor() { 
                IEntityDetails mockEntity = mock(IEntityDetails.class); 
+               Metadata mockMetadata = mock(Metadata.class);
                ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class); 
                SdncVFModel mockSdncVFModel = mock(SdncVFModel.class); 
+               
+               when(mockEntity.getMetadata()).thenReturn(mockMetadata);
+               
                SdncVFModuleModel testSdncVFModel = new SdncVFModuleModel(mockCsarHelper, mockEntity, mockSdncVFModel); 
                assertNotNull(testSdncVFModel); 
        } 
index 2c44ba7..24dfd36 100644 (file)
@@ -416,7 +416,7 @@ public class TestSdncUebCallback {
 
                IDistributionClient iDistClient = mock(IDistributionClient.class);
                SdncUebCallback cb = new SdncUebCallback(iDistClient, config);
-               cb.setJdbcDataSource(dblibSvc);
+               SdncUebCallback.setJdbcDataSource(dblibSvc);
 
                INotificationData iData = mock(INotificationData.class);
                /*IArtifactInfo iArtifactInfo = mock(IArtifactInfo.class);