summaryrefslogtreecommitdiffstats
path: root/northbound/ueb-listener/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'northbound/ueb-listener/src/test')
-rw-r--r--northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java50
-rw-r--r--northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java39
-rw-r--r--northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java71
-rw-r--r--northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java102
-rw-r--r--northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java76
-rw-r--r--northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java101
-rw-r--r--northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java104
-rw-r--r--northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java28
-rw-r--r--northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java45
-rw-r--r--northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java475
-rw-r--r--northbound/ueb-listener/src/test/resources/artifact.map2
-rw-r--r--northbound/ueb-listener/src/test/resources/dblib.properties38
-rw-r--r--northbound/ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csarbin0 -> 43966 bytes
-rw-r--r--northbound/ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csarbin0 -> 38938 bytes
-rw-r--r--northbound/ueb-listener/src/test/resources/incoming/vf-license-model.xml1
-rw-r--r--northbound/ueb-listener/src/test/resources/log4j.properties30
-rwxr-xr-xnorthbound/ueb-listener/src/test/resources/ueb-listener.properties22
17 files changed, 1184 insertions, 0 deletions
diff --git a/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java
new file mode 100644
index 000000000..11556df1b
--- /dev/null
+++ b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java
@@ -0,0 +1,50 @@
+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.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 SdncARModelTest {
+
+ SdncARModel testSdncARModel = null;
+
+ @Before
+ public void setUp() throws Exception {
+ ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.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);
+ }
+
+ @Test
+ public void testSetGetSubcategory() {
+ String subcategory = "test-subcategory";
+ testSdncARModel.setSubcategory(subcategory);
+ String result = testSdncARModel.getSubcategory();
+ assertEquals(subcategory, result);
+ }
+
+ @Test
+ public void testInsertAllottedResourceModelData() {
+ try {
+ testSdncARModel.insertAllottedResourceModelData();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
diff --git a/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java
new file mode 100644
index 000000000..0dfbf087f
--- /dev/null
+++ b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java
@@ -0,0 +1,39 @@
+package org.onap.ccsdk.sli.northbound.uebclient;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+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 {
+
+ @Test
+ public void testSdncGroupModelConstructor() {
+ 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);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertNotNull(testSdncGroupModel);
+ }
+
+ }
+
diff --git a/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java
new file mode 100644
index 000000000..3f4728f07
--- /dev/null
+++ b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java
@@ -0,0 +1,71 @@
+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.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 SdncNodeModelTest {
+
+ SdncNodeModel sdncNodeModel;
+
+ @Before
+ public void setUp() throws Exception {
+ SdncUebConfiguration config = mock(SdncUebConfiguration.class);
+ ISdcCsarHelper isdcCsarHelper = mock(ISdcCsarHelper.class);
+ IEntityDetails entityDetails = mock(IEntityDetails.class);
+ Metadata mockMetadata = mock(Metadata.class);
+ DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
+
+ when(entityDetails.getMetadata()).thenReturn(mockMetadata);
+ when(mockMetadata.getValue("customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
+
+ sdncNodeModel = new SdncNodeModel(isdcCsarHelper, entityDetails, mockDBResourceManager, config);
+ sdncNodeModel.setServiceUUID("0e8d757f-1c80-40af-85de-31d64f1f5af8");
+ sdncNodeModel.setEcompGeneratedNaming("hello-world");
+ }
+
+ @Test
+ public void testGetServiceUUID() {
+ String result = sdncNodeModel.getServiceUUID();
+ assertNotNull(result != null);
+ }
+
+ @Test
+ public void testGetEcompGeneratedNaming() {
+ String result = sdncNodeModel.getEcompGeneratedNaming();
+ assertEquals("hello-world", result);
+ }
+
+ @Test
+ public void testGetSqlString() {
+ String result = sdncNodeModel.getSql("TEST-HELLO");
+ String test = "INSERT into NETWORK_MODEL (service_uuid, customization_uuid, model_yaml, ecomp_generated_naming) values (0e8d757f-1c80-40af-85de-31d64f1f5af8, \"aaaa-bbbb-cccc-dddd\", \"TEST-HELLO\", \"hello-world\");";
+ assertEquals(test, result);
+ }
+
+ @Test
+ public void testGetVpnBindingsSql() {
+ String result = sdncNodeModel.getVpnBindingsSql();
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testInsertNetworkModelData() {
+ try {
+ sdncNodeModel.insertNetworkModelData();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java
new file mode 100644
index 000000000..97c3942dc
--- /dev/null
+++ b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java
@@ -0,0 +1,102 @@
+package org.onap.ccsdk.sli.northbound.uebclient;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+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.elements.Metadata;
+import org.onap.sdc.toscaparser.api.Property;
+
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
+
+ public class SdncPNFModelTest {
+
+ SdncPNFModel testSdncPNFModel = null;
+
+ @Before
+ public void setUp() throws Exception {
+ ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
+ IEntityDetails mockEntityDetails = mock(IEntityDetails.class);
+ Metadata mockMetadata = mock(Metadata.class);
+ Property mockProperty = mock(Property.class);
+ Map<String, Property> mockProperties = new HashMap<String, Property>();
+ DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
+ SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
+
+ when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
+ when(mockMetadata.getValue("customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
+ mockProperty.setValue("test-nf-naming-code");
+ when(mockProperties.get("nf_naming_code")).thenReturn(mockProperty);
+
+ try {
+ testSdncPNFModel = new SdncPNFModel(mockCsarHelper,mockEntityDetails,mockDBResourceManager,mockSdncUebConfiguration);
+ testSdncPNFModel.setServiceUUID("bbbb-cccc-dddd-eeee");
+ testSdncPNFModel.setServiceInvariantUUID("cccc-dddd-eeee-ffff");
+ testSdncPNFModel.setVendor("Cisco");
+ testSdncPNFModel.setVendorModelDescription("Cisco Equipment Model");
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertNotNull(testSdncPNFModel);
+ }
+
+ @Test
+ public void testSetGetVendor() {
+ String newVendorModel = "new-vendor-model";
+ testSdncPNFModel.setVendor(newVendorModel);
+ String result = testSdncPNFModel.getVendor();
+ assertEquals(result, newVendorModel);
+ }
+
+ @Test
+ public void testSetGetVendorModelDescription() {
+ String newVendorModelDescription = "new-vendor-model-description";
+ testSdncPNFModel.setVendorModelDescription(newVendorModelDescription);
+ String result = testSdncPNFModel.getVendorModelDescription();
+ assertEquals(result, newVendorModelDescription);
+ }
+
+ @Test
+ public void testSetGetNfNamingCode() {
+ String newNfNamingCode = "new-nf-naming-code";
+ testSdncPNFModel.setNfNamingCode(newNfNamingCode);
+ String result = testSdncPNFModel.getNfNamingCode();
+ assertEquals(result, newNfNamingCode);
+ }
+
+ @Test
+ public void testSetGetServiceUUID() {
+ String newServiceUuid = "cccc-dddd-eeee-ffff";
+ testSdncPNFModel.setServiceUUID(newServiceUuid);
+ String result = testSdncPNFModel.getServiceUUID();
+ assertEquals(newServiceUuid, result);
+ }
+
+ @Test
+ public void testSetGetServiceInvariantUUID() {
+ String newServiceInvariantUuid = "dddd-eeee-ffff-eeee";
+ testSdncPNFModel.setServiceInvariantUUID(newServiceInvariantUuid);
+ String result = testSdncPNFModel.getServiceInvariantUUID();
+ assertEquals(result, newServiceInvariantUuid);
+ }
+
+ @Test
+ public void testInsertData() {
+ try {
+ testSdncPNFModel.insertData();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
diff --git a/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java
new file mode 100644
index 000000000..b86a8e131
--- /dev/null
+++ b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java
@@ -0,0 +1,76 @@
+package org.onap.ccsdk.sli.northbound.uebclient;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+
+ public class SdncServiceModelTest {
+
+ SdncServiceModel testSdncServiceModel = null;
+
+ @Before
+ public void setUp() throws Exception {
+ ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
+ DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
+ Metadata mockMetadata = mock(Metadata.class);
+
+ 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);
+ }
+
+ @Test
+ public void testSetGetServiceUUID() {
+ String newServiceUuid = "cccc-dddd-eeee-ffff";
+ testSdncServiceModel.setServiceUUID(newServiceUuid);
+ String result = testSdncServiceModel.getServiceUUID();
+ assertEquals("\"" + newServiceUuid + "\"", result);
+ }
+
+ @Test
+ public void testSetGetServiceInvariantUUID() {
+ String result = testSdncServiceModel.getServiceInvariantUUID();
+ assertEquals(result, "\"bbbb-cccc-dddd-eeee\"");
+ }
+
+ @Test
+ public void testSetGeServiceInstanceNamePrefix() {
+ String serviceInstanceNamePrefix = "test-service-instance-name-prefix";
+ testSdncServiceModel.setServiceInstanceNamePrefix(serviceInstanceNamePrefix);
+ String result = testSdncServiceModel.getServiceInstanceNamePrefix();
+ assertEquals(serviceInstanceNamePrefix, result);
+ }
+
+ @Test
+ public void testSetGetResourceVendor() {
+ String resourceVendor = "Fortinet";
+ testSdncServiceModel.setResourceVendor(resourceVendor);
+ String result = testSdncServiceModel.getResourceVendor();
+ assertEquals(resourceVendor, result);
+ }
+
+ @Test
+ public void testSetGetResourceVendorRelease() {
+ String resourceVendorRelease = "1.0.0";
+ testSdncServiceModel.setResourceVendorRelease(resourceVendorRelease);
+ String result = testSdncServiceModel.getResourceVendorRelease();
+ assertEquals(resourceVendorRelease, result);
+ }
+
+ @Test
+ public void testGetSqlString() {
+ String result = testSdncServiceModel.getSql("TEST-HELLO");
+ String test = "INSERT into SERVICE_MODEL (service_uuid, model_yaml, filename, naming_policy, invariant_uuid) values (\"aaaa-bbbb-cccc-dddd\", \"TEST-HELLO\", \"null\", \"test-naming-policy\", \"bbbb-cccc-dddd-eeee\");";
+ assertEquals(test, result);
+ }
+
+
+ }
diff --git a/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java
new file mode 100644
index 000000000..f8680522f
--- /dev/null
+++ b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java
@@ -0,0 +1,101 @@
+package org.onap.ccsdk.sli.northbound.uebclient;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+
+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.elements.Metadata;
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
+
+public class SdncVFCModelTest {
+
+ SdncVFCModel testSdncVFCModel;
+ IEntityDetails mockEntityDetails = null;
+
+ @Before
+ public void setup() {
+ ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
+ mockEntityDetails = mock(IEntityDetails.class);
+ Metadata mockMetadata = mock(Metadata.class);
+ DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
+ SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
+
+ when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
+ 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>();
+ propertiesMap.put("network-role", "test-network-role");
+ propertiesMap.put("network-role-tag", "test-network-role-tag");
+
+ ArrayList<Map<String, Object>> ipRequirementsList = new ArrayList<Map<String, Object>>();
+ Map<String,Object> ip4Prop = new HashMap<String,Object>();
+ ip4Prop.put("ip_version", "4");
+ ipRequirementsList.add(ip4Prop);
+ Map<String,Object> ip6Prop = new HashMap<String,Object>();
+ ip4Prop.put("ip_version", "6");
+ ipRequirementsList.add(ip4Prop);
+
+ propertiesMap.put("ip_requirements", ipRequirementsList);
+ cpPropertiesMap.put("cp-node-1", propertiesMap);
+
+ try {
+ testSdncVFCModel = new SdncVFCModel(mockCsarHelper, mockEntityDetails, mockDBResourceManager, mockSdncUebConfiguration);
+ testSdncVFCModel.setVmType("Test-type");
+ testSdncVFCModel.setVmCount("5");
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testSdncVFCModelSetGetVmType() {
+ String newVMtype = "new-vm-type";
+ testSdncVFCModel.setVmType(newVMtype);
+ assertEquals(testSdncVFCModel.getVmType(), "new-vm-type");
+ }
+
+ @Test
+ public void testSdncVFCModelSetGetVmCount() {
+ String newVMcount = "4";
+ testSdncVFCModel.setVmCount(newVMcount);
+ assertEquals(testSdncVFCModel.getVmCount(), "4");
+ }
+
+ @Test
+ public void testInsertVFCModelData() {
+ try {
+ testSdncVFCModel.insertVFCModelData();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testInsertVFCtoNetworkRoleMappingData() {
+ try {
+ testSdncVFCModel.insertVFCtoNetworkRoleMappingData(mockEntityDetails);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testIpPropParamsMapContainsSubnetRole() {
+ ArrayList<Map<String, String>> testList = new ArrayList<Map<String, String>>();
+ testSdncVFCModel.ipPropParamsMapContainsSubnetRole(testList, "test-subnet-role");
+ }
+
+}
diff --git a/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java
new file mode 100644
index 000000000..93f7d3467
--- /dev/null
+++ b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java
@@ -0,0 +1,104 @@
+package org.onap.ccsdk.sli.northbound.uebclient;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+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.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.toscaparser.api.Property;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
+
+ public class SdncVFModelTest {
+
+ SdncVFModel testSdncVFModel = null;
+
+ @Before
+ public void setUp() throws Exception {
+ ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
+ IEntityDetails mockEntityDetails = mock(IEntityDetails.class);
+ Metadata mockMetadata = mock(Metadata.class);
+ DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
+ SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
+
+ Property mockProperty = mock(Property.class);
+ Map<String, Property> mockProperties = new HashMap<String, Property>();
+
+ when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
+ when(mockEntityDetails.getProperties()).thenReturn(mockProperties);
+ 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 {
+ testSdncVFModel = new SdncVFModel(mockCsarHelper,mockEntityDetails,mockDBResourceManager,mockSdncUebConfiguration);
+ testSdncVFModel.setServiceUUID("bbbb-cccc-dddd-eeee");
+ testSdncVFModel.setServiceInvariantUUID("cccc-dddd-eeee-ffff");
+ testSdncVFModel.setVendor("Cisco");
+ testSdncVFModel.setVendorModelDescription("Cisco Equipment Model");
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertNotNull(testSdncVFModel);
+ }
+
+ @Test
+ public void testSetGetVendor() {
+ String newVendorModel = "new-vendor-model";
+ testSdncVFModel.setVendor(newVendorModel);
+ String result = testSdncVFModel.getVendor();
+ assertEquals(result, newVendorModel);
+ }
+
+ @Test
+ public void testSetGetVendorModelDescription() {
+ String newVendorModelDescription = "new-vendor-model-description";
+ testSdncVFModel.setVendorModelDescription(newVendorModelDescription);
+ String result = testSdncVFModel.getVendorModelDescription();
+ assertEquals(result, newVendorModelDescription);
+ }
+
+ @Test
+ public void testSetGetNfNamingCode() {
+ String newNfNamingCode = "new-nf-naming-code";
+ testSdncVFModel.setNfNamingCode(newNfNamingCode);
+ String result = testSdncVFModel.getNfNamingCode();
+ assertEquals(result, newNfNamingCode);
+ }
+
+ @Test
+ public void testSetGetServiceUUID() {
+ String newServiceUuid = "cccc-dddd-eeee-ffff";
+ testSdncVFModel.setServiceUUID(newServiceUuid);
+ String result = testSdncVFModel.getServiceUUID();
+ assertEquals(newServiceUuid, result);
+ }
+
+ @Test
+ public void testSetGetServiceInvariantUUID() {
+ String newServiceInvariantUuid = "dddd-eeee-ffff-eeee";
+ testSdncVFModel.setServiceInvariantUUID(newServiceInvariantUuid);
+ String result = testSdncVFModel.getServiceInvariantUUID();
+ assertEquals(result, newServiceInvariantUuid);
+ }
+
+ @Test
+ public void testInsertData() {
+ try {
+ testSdncVFModel.insertData();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
diff --git a/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java
new file mode 100644
index 000000000..e19e8dfa9
--- /dev/null
+++ b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java
@@ -0,0 +1,28 @@
+package org.onap.ccsdk.sli.northbound.uebclient;
+
+import static org.junit.Assert.*;
+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.elements.Metadata;
+import org.onap.ccsdk.sli.northbound.uebclient.SdncVFModel;
+
+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/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java
new file mode 100644
index 000000000..1b4b22f42
--- /dev/null
+++ b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java
@@ -0,0 +1,45 @@
+package org.onap.ccsdk.sli.northbound.uebclient;
+
+import ch.vorburger.mariadb4j.DB;
+import ch.vorburger.mariadb4j.DBConfigurationBuilder;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
+import org.onap.sdc.api.IDistributionClient;
+import org.onap.sdc.api.notification.INotificationData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.ConnectException;
+import java.net.URL;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.Properties;
+
+import static org.mockito.Mockito.mock;
+
+public class TestSdncOdlConnection {
+
+ @Test
+ public void test() {
+
+ try {
+ SdncOdlConnection sdncOdlConnection = SdncOdlConnection.newInstance("https://127.0.0.1:8447/aai/v11/network/pnfs/pnf/a8098c1a-f86e-11da-bd1a-00112444be1e", "", "");
+ sdncOdlConnection.send("PUT", "application/json", "{\n" +
+ " \"input\" : { \n" +
+ " }\n" +
+ "}");
+ } catch (ConnectException e) {
+ //Connection exception
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java
new file mode 100644
index 000000000..24dfd36b1
--- /dev/null
+++ b/northbound/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java
@@ -0,0 +1,475 @@
+package org.onap.ccsdk.sli.northbound.uebclient;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.*;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
+import org.onap.sdc.api.IDistributionClient;
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.notification.INotificationData;
+import org.onap.sdc.api.notification.IResourceInstance;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import ch.vorburger.mariadb4j.DB;
+import ch.vorburger.mariadb4j.DBConfigurationBuilder;
+
+public class TestSdncUebCallback {
+
+
+ private static final String CRTBL_SERVICE_MODEL = "CREATE TABLE `SERVICE_MODEL` (\n" +
+ " `service_uuid` varchar(255) NOT NULL,\n" +
+ " `model_yaml` longblob,\n" +
+ " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
+ " `version` varchar(255) DEFAULT NULL,\n" +
+ " `name` varchar(255) DEFAULT NULL,\n" +
+ " `description` varchar(1024) DEFAULT NULL,\n" +
+ " `type` varchar(255) DEFAULT NULL,\n" +
+ " `category` varchar(255) DEFAULT NULL,\n" +
+ " `ecomp_naming` char(1) DEFAULT NULL,\n" +
+ " `service_instance_name_prefix` varchar(255) DEFAULT NULL,\n" +
+ " `filename` varchar(100) DEFAULT NULL,\n" +
+ " `naming_policy` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`service_uuid`)\n" +
+ ") ";
+
+ private static final String CRTBL_SERVICE_MODEL_TO_VF_MODEL_MAPPING = "CREATE TABLE `SERVICE_MODEL_TO_VF_MODEL_MAPPING` (\n" +
+ " `service_uuid` varchar(255) NOT NULL,\n" +
+ " `vf_uuid` varchar(255) DEFAULT NULL,\n" +
+ " `vf_customization_uuid` varchar(255) DEFAULT NULL,\n" +
+ " `service_invariant_uuid` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`service_uuid`)\n" +
+ ") ";
+
+ private static final String CRTBL_ATTRIBUTE_VALUE_PAIR = "CREATE TABLE `ATTRIBUTE_VALUE_PAIR` (\n" +
+ " `resource_uuid` varchar(255) NOT NULL,\n" +
+ " `attribute_name` varchar(255) NOT NULL,\n" +
+ " `resource_type` varchar(255) NOT NULL,\n" +
+ " `attribute_value` varchar(255) DEFAULT NULL,\n" +
+ " `resource_customization_uuid` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`resource_uuid`,`attribute_name`,`resource_type`)\n" +
+ ") ";
+
+ private static final String CRTBL_NETWORK_MODEL = "CREATE TABLE `NETWORK_MODEL` (\n" +
+ " `customization_uuid` varchar(255) NOT NULL,\n" +
+ " `service_uuid` varchar(255) NOT NULL,\n" +
+ " `model_yaml` longblob,\n" +
+ " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
+ " `uuid` varchar(255) DEFAULT NULL,\n" +
+ " `network_type` varchar(255) DEFAULT NULL,\n" +
+ " `network_role` varchar(255) DEFAULT NULL,\n" +
+ " `network_technology` varchar(255) DEFAULT NULL,\n" +
+ " `network_scope` varchar(255) DEFAULT NULL,\n" +
+ " `naming_policy` varchar(255) DEFAULT NULL,\n" +
+ " `ecomp_generated_naming` char(1) DEFAULT NULL,\n" +
+ " `is_shared_network` char(1) DEFAULT NULL,\n" +
+ " `is_external_network` char(1) DEFAULT NULL,\n" +
+ " `is_provider_network` char(1) DEFAULT NULL,\n" +
+ " `physical_network_name` varchar(255) DEFAULT NULL,\n" +
+ " `is_bound_to_vpn` char(1) DEFAULT NULL,\n" +
+ " `vpn_binding` varchar(255) DEFAULT NULL,\n" +
+ " `use_ipv4` char(1) DEFAULT NULL,\n" +
+ " `ipv4_dhcp_enabled` char(1) DEFAULT NULL,\n" +
+ " `ipv4_ip_version` char(1) DEFAULT NULL,\n" +
+ " `ipv4_cidr_mask` varchar(255) DEFAULT NULL,\n" +
+ " `eipam_v4_address_plan` varchar(255) DEFAULT NULL,\n" +
+ " `use_ipv6` char(1) DEFAULT NULL,\n" +
+ " `ipv6_dhcp_enabled` char(1) DEFAULT NULL,\n" +
+ " `ipv6_ip_version` char(1) DEFAULT NULL,\n" +
+ " `ipv6_cidr_mask` varchar(255) DEFAULT NULL,\n" +
+ " `eipam_v6_address_plan` varchar(255) DEFAULT NULL,\n" +
+ " `version` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`customization_uuid`),\n" +
+ " KEY `FK_NETWORK_MODEL` (`service_uuid`),\n" +
+ " CONSTRAINT `FK_NETWORK_MODEL` FOREIGN KEY (`service_uuid`) REFERENCES `SERVICE_MODEL` (`service_uuid`) ON DELETE NO ACTION ON UPDATE NO ACTION\n" +
+ ")";
+
+ private static final String CRTBL_ALLOTTED_RESOURCE_MODEL = "CREATE TABLE `ALLOTTED_RESOURCE_MODEL` (\n" +
+ " `customization_uuid` varchar(255) NOT NULL,\n" +
+ " `model_yaml` longblob,\n" +
+ " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
+ " `uuid` varchar(255) DEFAULT NULL,\n" +
+ " `version` varchar(255) DEFAULT NULL,\n" +
+ " `naming_policy` varchar(255) DEFAULT NULL,\n" +
+ " `ecomp_generated_naming` char(1) DEFAULT NULL,\n" +
+ " `depending_service` varchar(255) DEFAULT NULL,\n" +
+ " `role` varchar(255) DEFAULT NULL,\n" +
+ " `type` varchar(255) DEFAULT NULL,\n" +
+ " `service_dependency` varchar(255) DEFAULT NULL,\n" +
+ " `allotted_resource_type` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`customization_uuid`)\n" +
+ ") ";
+
+ private static final String CRTBL_VFC_MODEL = "CREATE TABLE `VFC_MODEL` (\n" +
+ " `customization_uuid` varchar(255) NOT NULL,\n" +
+ " `model_yaml` longblob,\n" +
+ " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
+ " `uuid` varchar(255) DEFAULT NULL,\n" +
+ " `version` varchar(255) DEFAULT NULL,\n" +
+ " `naming_policy` varchar(255) DEFAULT NULL,\n" +
+ " `ecomp_generated_naming` char(1) DEFAULT NULL,\n" +
+ " `nfc_function` varchar(255) DEFAULT NULL,\n" +
+ " `nfc_naming_code` varchar(255) DEFAULT NULL,\n" +
+ " `vm_type` varchar(255) DEFAULT NULL,\n" +
+ " `vm_type_tag` varchar(255) DEFAULT NULL,\n" +
+ " `vm_image_name` varchar(255) DEFAULT NULL,\n" +
+ " `vm_flavor_name` varchar(255) DEFAULT NULL,\n" +
+ " `high_availability` varchar(255) DEFAULT NULL,\n" +
+ " `nfc_naming` varchar(255) DEFAULT NULL,\n" +
+ " `min_instances` int(11) DEFAULT NULL,\n" +
+ " `max_instances` int(11) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`customization_uuid`)\n" +
+ ") ";
+
+ private static final String CRTBL_VFC_RELATED_NETWORK_ROLE = "CREATE TABLE `VFC_RELATED_NETWORK_ROLE` (\n" +
+ " `vfc_customization_uuid` varchar(255) NOT NULL,\n" +
+ " `vm_type` varchar(255) NOT NULL,\n" +
+ " `network_role` varchar(255) NOT NULL,\n" +
+ " `related_network_role` varchar(255) NOT NULL,\n" +
+ " PRIMARY KEY (`vfc_customization_uuid`,`vm_type`,`network_role`,`related_network_role`)\n" +
+ ") ";
+
+ private static final String CRTBL_VFC_TO_NETWORK_ROLE_MAPPING = "CREATE TABLE `VFC_TO_NETWORK_ROLE_MAPPING` (\n" +
+ " `seq` int(11) NOT NULL AUTO_INCREMENT,\n" +
+ " `vfc_customization_uuid` varchar(255) NOT NULL,\n" +
+ " `network_role` varchar(255) NOT NULL,\n" +
+ " `vm_type` varchar(255) DEFAULT NULL,\n" +
+ " `network_role_tag` varchar(255) DEFAULT NULL,\n" +
+ " `ipv4_count` int(11) NOT NULL,\n" +
+ " `ipv6_count` int(11) NOT NULL,\n" +
+ " `ipv4_use_dhcp` char(1) DEFAULT NULL,\n" +
+ " `ipv6_use_dhcp` char(1) DEFAULT NULL,\n" +
+ " `ipv4_ip_version` char(1) DEFAULT NULL,\n" +
+ " `ipv6_ip_version` char(1) DEFAULT NULL,\n" +
+ " `extcp_subnetpool_id` varchar(512) DEFAULT NULL,\n" +
+ " `ipv4_floating_count` int(11) DEFAULT NULL,\n" +
+ " `ipv6_floating_count` int(11) DEFAULT NULL,\n" +
+ " `ipv4_address_plan_name` varchar(512) DEFAULT NULL,\n" +
+ " `ipv6_address_plan_name` varchar(512) DEFAULT NULL,\n" +
+ " `ipv4_vrf_name` varchar(512) DEFAULT NULL,\n" +
+ " `ipv6_vrf_name` varchar(512) DEFAULT NULL,\n" +
+ " `subnet_role` varchar(255) DEFAULT NULL,\n" +
+ " `subinterface_indicator` char(1) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`seq`),\n" +
+ " KEY `IX1_VFC_TO_NETWORK_ROLE_MAPPING` (`vfc_customization_uuid`)\n" +
+ ") ";
+
+ private static final String CRTBL_VF_MODEL = "CREATE TABLE `VF_MODEL` (\n" +
+ " `customization_uuid` varchar(255) NOT NULL,\n" +
+ " `model_yaml` longblob,\n" +
+ " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
+ " `uuid` varchar(255) DEFAULT NULL,\n" +
+ " `version` varchar(255) DEFAULT NULL,\n" +
+ " `name` varchar(255) DEFAULT NULL,\n" +
+ " `naming_policy` varchar(255) DEFAULT NULL,\n" +
+ " `ecomp_generated_naming` char(1) DEFAULT NULL,\n" +
+ " `avail_zone_max_count` int(11) DEFAULT NULL,\n" +
+ " `nf_function` varchar(255) DEFAULT NULL,\n" +
+ " `nf_code` varchar(255) DEFAULT NULL,\n" +
+ " `nf_type` varchar(255) DEFAULT NULL,\n" +
+ " `nf_role` varchar(255) DEFAULT NULL,\n" +
+ " `vendor` varchar(255) DEFAULT NULL,\n" +
+ " `vendor_version` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`customization_uuid`)\n" +
+ ")";
+
+ private static final String CRTBL_VNF_RELATED_NETWORK_ROLE = "CREATE TABLE `VNF_RELATED_NETWORK_ROLE` (\n" +
+ " `vnf_customization_uuid` varchar(255) NOT NULL,\n" +
+ " `network_role` varchar(255) NOT NULL,\n" +
+ " `related_network_role` varchar(255) NOT NULL,\n" +
+ " PRIMARY KEY (`vnf_customization_uuid`,`network_role`,`related_network_role`)\n" +
+ ")";
+
+ private static final String CRTBL_VF_TO_NETWORK_ROLE_MAPPING = "CREATE TABLE `VF_TO_NETWORK_ROLE_MAPPING` (\n" +
+ " `seq` int(11) NOT NULL AUTO_INCREMENT,\n" +
+ " `vf_customization_uuid` varchar(255) NOT NULL,\n" +
+ " `network_role` varchar(255) NOT NULL,\n" +
+ " PRIMARY KEY (`seq`),\n" +
+ " KEY `IX1_VF_TO_NETWORK_ROLE_MAPPING` (`vf_customization_uuid`)\n" +
+ ")";
+
+ private static final String CRTBL_VF_MODULE_MODEL = "CREATE TABLE `VF_MODULE_MODEL` (\n" +
+ " `customization_uuid` varchar(255) NOT NULL,\n" +
+ " `model_yaml` longblob,\n" +
+ " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
+ " `uuid` varchar(255) DEFAULT NULL,\n" +
+ " `version` varchar(255) DEFAULT NULL,\n" +
+ " `vf_module_type` varchar(255) DEFAULT NULL,\n" +
+ " `availability_zone_count` int(11) DEFAULT NULL,\n" +
+ " `ecomp_generated_vm_assignments` char(1) DEFAULT NULL,\n" +
+ " `vf_customization_uuid` char(255) DEFAULT NULL,\n" +
+ " `vf_module_label` char(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`customization_uuid`)\n" +
+ ")";
+
+ private static final String CRTBL_VF_MODULE_TO_VFC_MAPPING = "CREATE TABLE `VF_MODULE_TO_VFC_MAPPING` (\n" +
+ " `seq` int(11) NOT NULL AUTO_INCREMENT,\n" +
+ " `vf_module_customization_uuid` varchar(255) NOT NULL,\n" +
+ " `vfc_customization_uuid` varchar(255) NOT NULL,\n" +
+ " `vm_type` varchar(255) NOT NULL,\n" +
+ " `vm_count` int(11) NOT NULL,\n" +
+ " PRIMARY KEY (`seq`),\n" +
+ " KEY `IX1_VF_MODULE_TO_VFC_MAPPING` (`vf_module_customization_uuid`)\n" +
+ ")";
+
+ private static final String CRTBL_RESOURCE_GROUP = "CREATE TABLE `RESOURCE_GROUP` (\n" +
+ " `resource_uuid` varchar(255) NOT NULL,\n" +
+ " `group_uuid` varchar(255) NOT NULL,\n" +
+ " `group_customization_uuid` varchar(255) DEFAULT NULL,\n" +
+ " `group_invariant_uuid` varchar(255) DEFAULT NULL,\n" +
+ " `group_name` varchar(255) DEFAULT NULL,\n" +
+ " `version` varchar(255) DEFAULT NULL,\n" +
+ " `group_type` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`resource_uuid`,`group_uuid`)\n" +
+ ")";
+
+ private static final String CRTBL_RESOURCE_GROUP_TO_TARGET_NODE_MAPPING = "CREATE TABLE `RESOURCE_GROUP_TO_TARGET_NODE_MAPPING` (\n" +
+ " `group_uuid` varchar(255) NOT NULL,\n" +
+ " `parent_uuid` varchar(255) NOT NULL,\n" +
+ " `target_node_uuid` varchar(255) NOT NULL,\n" +
+ " `target_type` varchar(255) DEFAULT NULL,\n" +
+ " `table_name` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`group_uuid`,`parent_uuid`,`target_node_uuid`)\n" +
+ ")";
+
+ private static final String CRTBL_RESOURCE_POLICY = "CREATE TABLE `RESOURCE_POLICY` (\n" +
+ " `resource_uuid` varchar(255) NOT NULL,\n" +
+ " `policy_uuid` varchar(255) NOT NULL,\n" +
+ " `policy_invariant_uuid` varchar(255) NOT NULL,\n" +
+ " `policy_name` varchar(255) DEFAULT NULL,\n" +
+ " `version` varchar(255) DEFAULT NULL,\n" +
+ " `policy_type` varchar(255) DEFAULT NULL,\n" +
+ " `property_type` varchar(255) DEFAULT NULL,\n" +
+ " `property_source` varchar(255) DEFAULT NULL,\n" +
+ " `property_name` varchar(255) DEFAULT NULL,\n" +
+ " `policy_customization_uuid` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`resource_uuid`,`policy_uuid`)\n" +
+ ")";
+
+ private static final String CRTBL_RESOURCE_POLICY_TO_TARGET_NODE_MAPPING = "CREATE TABLE `RESOURCE_POLICY_TO_TARGET_NODE_MAPPING` (\n" +
+ " `policy_uuid` varchar(255) NOT NULL,\n" +
+ " `parent_uuid` varchar(255) NOT NULL,\n" +
+ " `target_node_uuid` varchar(255) NOT NULL,\n" +
+ " `target_type` varchar(255) DEFAULT NULL,\n" +
+ " `target_node_customization_uuid` varchar(255) DEFAULT NULL,\n" +
+ " `policy_customization_uuid` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`policy_uuid`,`parent_uuid`,`target_node_uuid`)\n" +
+ ")";
+
+ private static final String CRTBL_NODE_CAPABILITY = "CREATE TABLE `NODE_CAPABILITY` (\n" +
+ " `capability_id` int(11) NOT NULL AUTO_INCREMENT,\n" +
+ " `capability_provider_uuid` varchar(255) NOT NULL,\n" +
+ " `capability_provider_customization_uuid` varchar(255) NOT NULL,\n" +
+ " `capability_name` varchar(255) DEFAULT NULL,\n" +
+ " `capability_type` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`capability_id`)\n" +
+ ")";
+
+ private static final String CRTBL_NODE_CAPABILITY_PROPERTY = "CREATE TABLE `NODE_CAPABILITY_PROPERTY` (\n" +
+ " `capability_id` int(11) NOT NULL AUTO_INCREMENT,\n" +
+ " `capability_property_name` varchar(255) NOT NULL,\n" +
+ " `capability_property_type` varchar(255) DEFAULT NULL,\n" +
+ " PRIMARY KEY (`capability_id`,`capability_property_name`),\n" +
+ " CONSTRAINT `NODE_CAPABILITY_PROPERTY_TO_NODE_CAPABILITY` FOREIGN KEY (`capability_id`) REFERENCES `NODE_CAPABILITY` (`capability_id`) ON DELETE CASCADE\n" +
+ ")";
+
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(TestSdncUebCallback.class);
+ SdncUebConfiguration config;
+ DBResourceManager dblibSvc;
+ DB db;
+ List<IArtifactInfo > processLevelArtifactList;
+ List<IArtifactInfo > serviceLevelArtifactList;
+ ArrayList<IResourceInstance> resourceList;
+ IArtifactInfo mockProcessArtifact1;
+ IArtifactInfo mockProcessArtifact2;
+ IArtifactInfo mockProcessArtifact3;
+ IArtifactInfo mockServiceArtifact1;
+ IResourceInstance resource;
+
+
+ @Before
+ public void setUp() throws Exception {
+ config = new SdncUebConfiguration("src/test/resources");
+
+
+ URL propUrl = getClass().getResource("/dblib.properties");
+
+ InputStream propStr = getClass().getResourceAsStream("/dblib.properties");
+
+ Properties props = new Properties();
+
+ props.load(propStr);
+
+
+ // Start MariaDB4j database
+ DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder();
+ config.setPort(0); // 0 => autom. detect free port
+ db = DB.newEmbeddedDB(config.build());
+ db.start();
+
+
+ // Override jdbc URL and database name
+ props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test");
+ props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test"));
+
+
+ // Create dblib connection
+ dblibSvc = new DBResourceManager(props);
+
+ // Create TOSCA tables
+ dblibSvc.writeData(CRTBL_SERVICE_MODEL, null, null);
+ dblibSvc.writeData(CRTBL_SERVICE_MODEL_TO_VF_MODEL_MAPPING, null, null);
+ dblibSvc.writeData(CRTBL_ATTRIBUTE_VALUE_PAIR, null, null);
+ dblibSvc.writeData(CRTBL_NETWORK_MODEL, null, null);
+ dblibSvc.writeData(CRTBL_VFC_MODEL, null, null);
+ dblibSvc.writeData(CRTBL_VFC_RELATED_NETWORK_ROLE, null, null);
+ dblibSvc.writeData(CRTBL_VFC_TO_NETWORK_ROLE_MAPPING, null, null);
+ dblibSvc.writeData(CRTBL_VF_MODEL, null, null);
+ dblibSvc.writeData(CRTBL_VNF_RELATED_NETWORK_ROLE, null, null);
+ dblibSvc.writeData(CRTBL_VF_TO_NETWORK_ROLE_MAPPING, null, null);
+ dblibSvc.writeData(CRTBL_VF_MODULE_MODEL, null, null);
+ dblibSvc.writeData(CRTBL_VF_MODULE_TO_VFC_MAPPING, null, null);
+ dblibSvc.writeData(CRTBL_ALLOTTED_RESOURCE_MODEL, null, null);
+ dblibSvc.writeData(CRTBL_RESOURCE_GROUP, null, null);
+ dblibSvc.writeData(CRTBL_RESOURCE_GROUP_TO_TARGET_NODE_MAPPING, null, null);
+ dblibSvc.writeData(CRTBL_RESOURCE_POLICY, null, null);
+ dblibSvc.writeData(CRTBL_RESOURCE_POLICY_TO_TARGET_NODE_MAPPING, null, null);
+ dblibSvc.writeData(CRTBL_NODE_CAPABILITY, null, null);
+ dblibSvc.writeData(CRTBL_NODE_CAPABILITY_PROPERTY, null, null);
+
+ processLevelArtifactList = new ArrayList<>();
+ serviceLevelArtifactList = new ArrayList<>();
+ resourceList = new ArrayList<>();
+
+
+ mockProcessArtifact1 = mock(IArtifactInfo.class);
+ when(mockProcessArtifact1.getArtifactName()).thenReturn("mockProcessArtifact1");
+ when(mockProcessArtifact1.getArtifactType()).thenReturn("HEAT");
+ when(mockProcessArtifact1.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
+ when(mockProcessArtifact1.getArtifactChecksum()).thenReturn("123tfg123 1234ftg");
+ when(mockProcessArtifact1.getArtifactTimeout()).thenReturn(110);
+
+ mockProcessArtifact2 = mock(IArtifactInfo.class);
+ when(mockProcessArtifact2.getArtifactName()).thenReturn("mockProcessArtifact2");
+ when(mockProcessArtifact2.getArtifactType()).thenReturn("DG_XML");
+ when(mockProcessArtifact2.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
+ when(mockProcessArtifact2.getArtifactChecksum()).thenReturn("456jhgt 1234ftg");
+ when(mockProcessArtifact2.getArtifactTimeout()).thenReturn(110);
+
+ mockProcessArtifact3 = mock(IArtifactInfo.class);
+ when(mockProcessArtifact3.getArtifactName()).thenReturn("mockProcessArtifact3");
+ when(mockProcessArtifact3.getArtifactType()).thenReturn("HEAT");
+ when(mockProcessArtifact3.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
+ when(mockProcessArtifact3.getArtifactChecksum()).thenReturn("123tfg123 543gtd");
+ when(mockProcessArtifact3.getArtifactTimeout()).thenReturn(110);
+
+
+ mockServiceArtifact1 = mock(IArtifactInfo.class);
+ when(mockServiceArtifact1.getArtifactName()).thenReturn("mockProcessArtifact4");
+ when(mockServiceArtifact1.getArtifactType()).thenReturn("HEAT");
+ when(mockServiceArtifact1.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
+ when(mockServiceArtifact1.getArtifactChecksum()).thenReturn("123t3455 543gtd");
+ when(mockServiceArtifact1.getArtifactTimeout()).thenReturn(110);
+
+ resource = mock(IResourceInstance.class);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Move anything in archive back to incoming
+ String curFileName = "";
+
+ Path incomingPath = new File(config.getIncomingDir()).toPath();
+ File archiveDir = new File(config.getArchiveDir());
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(archiveDir.toPath())) {
+ for (Path file: stream) {
+ Files.move(file, incomingPath.resolve(file.getFileName()), StandardCopyOption.REPLACE_EXISTING);
+ }
+ } catch (Exception x) {
+ // IOException can never be thrown by the iteration.
+ // In this snippet, it can only be thrown by newDirectoryStream.
+ LOG.warn("Cannot replace spool file {}", curFileName, x);
+ }
+
+ db.stop();
+
+ }
+
+ @Test
+ public void test() {
+
+ IDistributionClient iDistClient = mock(IDistributionClient.class);
+ SdncUebCallback cb = new SdncUebCallback(iDistClient, config);
+ SdncUebCallback.setJdbcDataSource(dblibSvc);
+
+ INotificationData iData = mock(INotificationData.class);
+ /*IArtifactInfo iArtifactInfo = mock(IArtifactInfo.class);
+ when(iArtifactInfo.getArtifactName()).thenReturn("testArtifact1");
+ when(iArtifactInfo.getArtifactType()).thenReturn("TOSCA_CSAR");
+ List artifactInfoList = new ArrayList();
+ artifactInfoList.add(iArtifactInfo);*/
+
+ when(iData.getServiceName()).thenReturn("testServiceName");
+ //when(iData.getServiceArtifacts()).thenReturn(artifactInfoList);
+ cb.deployDownloadedFiles(null, null, null);
+ cb.activateCallback(iData);
+
+ }
+
+
+
+ @Test
+ public void testServiceAndProcessArtifactsactivateCallback() {
+
+ try {
+ processLevelArtifactList.add(mockProcessArtifact1);
+ processLevelArtifactList.add(mockProcessArtifact2);
+ processLevelArtifactList.add(mockProcessArtifact3);
+
+ resourceList.add(resource);
+ serviceLevelArtifactList.add(mockServiceArtifact1);
+ when(resource.getArtifacts()).thenReturn(serviceLevelArtifactList);
+ when(resource.getResourceName()).thenReturn("Resource_service_name");
+
+
+ IDistributionClient iDistClient1 = mock(IDistributionClient.class);
+ INotificationData mockData = mock(INotificationData.class);
+ when(mockData.getResources()).thenReturn(resourceList);
+ when(mockData.getServiceName()).thenReturn("Test_service_name");
+ when(mockData.getServiceArtifacts()).thenReturn(processLevelArtifactList);
+
+ /*IArtifactInfo iArtifactInfo = mock(IArtifactInfo.class);
+ when(iArtifactInfo.getArtifactName()).thenReturn("testArtifact1");
+ when(iArtifactInfo.getArtifactType()).thenReturn("TOSCA_CSAR");
+ List artifactInfoList = new ArrayList();
+ artifactInfoList.add(iArtifactInfo);
+
+ //when(mockData.getServiceName()).thenReturn("testServiceName");
+ when(mockData.getServiceArtifacts()).thenReturn(artifactInfoList);*/
+
+
+ SdncUebCallback cb1 = new SdncUebCallback(iDistClient1, config);
+ cb1.activateCallback(mockData);
+ assertTrue(true);
+ } catch (Exception e) {
+ assertTrue(false);
+ }
+ }
+
+}
diff --git a/northbound/ueb-listener/src/test/resources/artifact.map b/northbound/ueb-listener/src/test/resources/artifact.map
new file mode 100644
index 000000000..0256515f0
--- /dev/null
+++ b/northbound/ueb-listener/src/test/resources/artifact.map
@@ -0,0 +1,2 @@
+vf-license-model,ASDC-API:vf-license-model-update,0
+bad-entry,0
diff --git a/northbound/ueb-listener/src/test/resources/dblib.properties b/northbound/ueb-listener/src/test/resources/dblib.properties
new file mode 100644
index 000000000..9506ac8d1
--- /dev/null
+++ b/northbound/ueb-listener/src/test/resources/dblib.properties
@@ -0,0 +1,38 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+# dblib.properrties
+org.onap.ccsdk.sli.dbtype=jdbc
+
+org.onap.ccsdk.sli.jdbc.hosts=sdnctldb01
+org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/sdnctl
+org.onap.ccsdk.sli.jdbc.driver=org.mariadb.jdbc.Driver
+org.onap.ccsdk.sli.jdbc.database=sdnctl
+org.onap.ccsdk.sli.jdbc.user=sdnctl
+org.onap.ccsdk.sli.jdbc.password=gamma
+org.onap.ccsdk.sli.jdbc.connection.name=sdnctldb01
+org.onap.ccsdk.sli.jdbc.connection.timeout=50
+org.onap.ccsdk.sli.jdbc.request.timeout=100
+org.onap.ccsdk.sli.jdbc.limit.init=10
+org.onap.ccsdk.sli.jdbc.limit.min=10
+org.onap.ccsdk.sli.jdbc.limit.max=20
+org.onap.dblib.connection.recovery=false
+
diff --git a/northbound/ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csar b/northbound/ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csar
new file mode 100644
index 000000000..bb09f1c2f
--- /dev/null
+++ b/northbound/ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csar
Binary files differ
diff --git a/northbound/ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csar b/northbound/ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csar
new file mode 100644
index 000000000..329076a15
--- /dev/null
+++ b/northbound/ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csar
Binary files differ
diff --git a/northbound/ueb-listener/src/test/resources/incoming/vf-license-model.xml b/northbound/ueb-listener/src/test/resources/incoming/vf-license-model.xml
new file mode 100644
index 000000000..c5e33eeb5
--- /dev/null
+++ b/northbound/ueb-listener/src/test/resources/incoming/vf-license-model.xml
@@ -0,0 +1 @@
+<vf-license-model xmlns="http://xmlns.openecomp.org/asdc/license-model/1.0"><vendor-name>Broadsoft</vendor-name><vf-id>E5A18BC3D2454091B02EA3F69EB1DB46</vf-id><feature-group-list><feature-group><entitlement-pool-list><entitlement-pool><name>Broadsoft EP</name><description>tbp</description><increments>200</increments><entitlement-pool-uuid>728ad6b0-912e-432b-853e-373845d410ad</entitlement-pool-uuid><manufacturer-reference-number>tbp</manufacturer-reference-number><sp-limits/><vendor-limits/><operational-scope><value>VM</value></operational-scope><start-date/><expiry-date/><threshold-value><unit>Absolute</unit><value>100</value></threshold-value></entitlement-pool></entitlement-pool-list><license-key-group-list><license-key-group><name>Placeholder BS LPK</name><description>tbp</description><type>Universal</type><increments/><license-key-group-uuid>3be519b2-abf3-449f-9851-0ac70ccb5632</license-key-group-uuid><manufacturer-reference-number>tbp</manufacturer-reference-number><sp-limits/><vendor-limits/><operational-scope><value>VM</value></operational-scope><start-date/><expiry-date/><threshold-value><unit/><value/></threshold-value></license-key-group></license-key-group-list><description>tbp</description><part-number>asdfasfdsdf</part-number><name>Placeholder LPK</name><feature-group-uuid>4ACF252A84FA4FEC9C98AA0DFCFFFBCE</feature-group-uuid></feature-group></feature-group-list></vf-license-model> \ No newline at end of file
diff --git a/northbound/ueb-listener/src/test/resources/log4j.properties b/northbound/ueb-listener/src/test/resources/log4j.properties
new file mode 100644
index 000000000..71849c3db
--- /dev/null
+++ b/northbound/ueb-listener/src/test/resources/log4j.properties
@@ -0,0 +1,30 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+log4j.rootLogger=DEBUG,CONSOLE
+
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=DEBUG
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
+
+
diff --git a/northbound/ueb-listener/src/test/resources/ueb-listener.properties b/northbound/ueb-listener/src/test/resources/ueb-listener.properties
new file mode 100755
index 000000000..c017cbd7b
--- /dev/null
+++ b/northbound/ueb-listener/src/test/resources/ueb-listener.properties
@@ -0,0 +1,22 @@
+org.onap.ccsdk.sli.northbound.uebclient.asdc-address=localhost:1234
+org.onap.ccsdk.sli.northbound.uebclient.consumer-group=ccsdk1
+org.onap.ccsdk.sli.northbound.uebclient.consumer-id=localhost_ccsdk1
+org.onap.ccsdk.sli.northbound.uebclient.environment-name=UNITTEST
+org.onap.ccsdk.sli.northbound.uebclient.password=123456
+org.onap.ccsdk.sli.northbound.uebclient.user=test
+org.onap.ccsdk.sli.northbound.uebclient.sdnc-user=test
+org.onap.ccsdk.sli.northbound.uebclient.sdnc-passwd=test
+org.onap.ccsdk.sli.northbound.uebclient.asdc-api-base-url=http://localhost:8282/restconf/operations/
+org.onap.ccsdk.sli.northbound.uebclient.asdc-api-namespace=org:onap:ccsdk
+org.onap.ccsdk.sli.northbound.uebclient.spool.incoming=src/test/resources/incoming
+org.onap.ccsdk.sli.northbound.uebclient.spool.archive=src/test/resources/archive
+org.onap.ccsdk.sli.northbound.uebclient.polling-interval=30
+org.onap.ccsdk.sli.northbound.uebclient.polling-timeout=15
+org.onap.ccsdk.sli.northbound.uebclient.client-startup-timeout=60
+org.onap.ccsdk.sli.northbound.uebclient.relevant-artifact-types=YANG_XML,VF_LICENSE,TOSCA_TEMPLATE,TOSCA_CSAR,UCPE_LAYER_2_CONFIGURATION
+org.onap.ccsdk.sli.northbound.uebclient.relevant-capability-names=RoutingConfiguration,routing_configuration,VLANAssignment,vlan_assignment
+org.onap.ccsdk.sli.northbound.uebclient.activate-server-tls-auth=false
+org.onap.ccsdk.sli.northbound.uebclient.keystore-path=
+org.onap.ccsdk.sli.northbound.uebclient.keystore-password=
+org.onap.ccsdk.sli.northbound.uebclient.xslt-path-list=
+org.onap.ccsdk.sli.northbound.uebclient.artifact-map=src/test/resources/artifact.map