Test TOSCA table insertion

Add code to create TOSCA tables in test driver to test TOSCA table
insertion in ueb-listener TOSCA parser test.

Change-Id: Ib8c3fcdb25fbdba39b4700553d8c01b684efa384
Issue-ID: CCSDK-102
Signed-off-by: Dan Timoney <dtimoney@att.com>
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncArtifactMap.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncArtifactMap.java
index 3605465..671d47a 100644
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncArtifactMap.java
+++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncArtifactMap.java
@@ -8,9 +8,9 @@
  * 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.
@@ -104,6 +104,8 @@
 				LOG.error("Caught exception reading artifact map", e);
 				return;
 			}
+		} else {
+			LOG.info("Artifact map {} does not exist or is not readable", fileName);
 		}
 	}
 
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 2cc08e1..67e042b 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
@@ -561,7 +561,7 @@
 			insertToscaData(serviceModel.getSql(model_yaml));
 		} catch (IOException e) {
 			LOG.error("Could not insert Tosca YAML data into the SERVICE_MODEL table ", e);
-			return;
+			// return;
 		}
 
 		// Ingest Network (VL) Data - 1707
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java
index b49a660..75cb9c9 100644
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java
+++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java
@@ -177,7 +177,10 @@
 
 		String artifactMapFile = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.artifact-map");
 		if (artifactMapFile != null) {
+			LOG.info("Loading artifactMapFile {}", artifactMapFile);
 			artifactMap.load(artifactMapFile);
+		} else {
+			LOG.warn("artifact-map is unset");
 		}
 
 	}
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 d62618c..79a598c 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
@@ -25,6 +25,125 @@
 
 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_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_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_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" +
+			"  PRIMARY KEY (`customization_uuid`)\n" +
+			")";
+
 	 private static final Logger LOG = LoggerFactory
 	            .getLogger(TestSdncUebCallback.class);
 	SdncUebConfiguration config;
@@ -35,6 +154,7 @@
 	public void setUp() throws Exception {
 		config = new SdncUebConfiguration("src/test/resources");
 
+
 		URL propUrl = getClass().getResource("/dblib.properties");
 
 		InputStream propStr = getClass().getResourceAsStream("/dblib.properties");
@@ -56,7 +176,16 @@
 		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_NETWORK_MODEL, null, null);
+		dblibSvc.writeData(CRTBL_VFC_MODEL, null, null);
+		dblibSvc.writeData(CRTBL_VF_MODEL, null, null);
+		dblibSvc.writeData(CRTBL_VF_MODULE_MODEL, null, null);
+		dblibSvc.writeData(CRTBL_ALLOTTED_RESOURCE_MODEL, null, null);
 	}
 
 	@After
diff --git a/ueb-listener/src/test/resources/artifact.map b/ueb-listener/src/test/resources/artifact.map
new file mode 100644
index 0000000..0256515
--- /dev/null
+++ b/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/ueb-listener/src/test/resources/ueb-listener.properties b/ueb-listener/src/test/resources/ueb-listener.properties
index 548cc4c..4b9886e 100755
--- a/ueb-listener/src/test/resources/ueb-listener.properties
+++ b/ueb-listener/src/test/resources/ueb-listener.properties
@@ -16,4 +16,5 @@
 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=
\ No newline at end of file
+org.onap.ccsdk.sli.northbound.uebclient.xslt-path-list=
+org.onap.ccsdk.sli.northbound.uebclient.artifact-map=src/test/resources/artifact.map
\ No newline at end of file
diff --git a/version.properties b/version.properties
index 7092503..3d3e5b5 100644
--- a/version.properties
+++ b/version.properties
@@ -4,8 +4,8 @@
 # because they are used in Jenkins, whose plug-in doesn't support
 
 release_name=0
-sprint_number=0
-feature_revision=1
+sprint_number=1
+feature_revision=0
 
 base_version=${release_name}.${sprint_number}.${feature_revision}