From 84db6f1d6b4c975eba30dc45556ada876c262a87 Mon Sep 17 00:00:00 2001 From: "lalena.aria" Date: Fri, 1 Nov 2019 18:19:55 +0000 Subject: UEB Listener Final cleanup of deprecated sdc-tosca parser APIs 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 --- .../onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java | 6 ++++-- .../ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java | 6 ++++++ .../ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java | 2 +- .../onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java | 2 +- .../ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java | 9 +++------ .../onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java | 10 +--------- .../onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java | 4 ++-- .../ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java | 11 ++++++++--- .../ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java | 2 +- 9 files changed, 27 insertions(+), 25 deletions(-) (limited to 'ueb-listener/src/test') 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> cpPropertiesMap = new HashMap>(); Map propertiesMap = new HashMap(); @@ -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); -- cgit 1.2.3-korg