diff options
Diffstat (limited to 'ueb-listener')
13 files changed, 136 insertions, 164 deletions
diff --git a/ueb-listener/pom.xml b/ueb-listener/pom.xml index 9e7e41691..8bd81fee5 100755 --- a/ueb-listener/pom.xml +++ b/ueb-listener/pom.xml @@ -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> @@ -91,6 +92,11 @@ <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> diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java index 7ab431dac..bced6a830 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java @@ -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 diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java index 65b20e61f..8e790d9be 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java @@ -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); + } + } } diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java index a3662604e..8c3a290e0 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java @@ -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[]; diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java index 734dee229..11556df1b 100644 --- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java @@ -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); diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java index 3b2cd96a1..0dfbf087f 100644 --- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java @@ -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); diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java index 9f859e793..3f4728f07 100644 --- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java @@ -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"); diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java index d4c06b049..97c3942dc 100644 --- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java @@ -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); diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java index af17e2291..b86a8e131 100644 --- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java @@ -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); diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java index 768eed86c..f8680522f 100644 --- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java @@ -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); diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java index f20c1edbf..93f7d3467 100644 --- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java @@ -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 { diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java index 846b79b49..e19e8dfa9 100644 --- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java @@ -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); } diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java index 2c44ba732..24dfd36b1 100644 --- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java +++ b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java @@ -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); |