Merge "Changed VF creation to new MSO scaleout API"
diff --git a/deliveries/src/main/scripts/localize.sh b/deliveries/src/main/scripts/localize.sh
index 3966f70..aca557f 100755
--- a/deliveries/src/main/scripts/localize.sh
+++ b/deliveries/src/main/scripts/localize.sh
@@ -1,18 +1,23 @@
 #!/bin/bash
 
-#Extract the WAR so it can be customized by the localization script
-cd /tmp/vid/stage
-jar -xf vid.war
-
-source /tmp/vid/localize_war.sh || {
-	echo "ERROR: Localization script failed"
-	exit 2
+fillTemplateProperties() {
+  source /tmp/vid/localize_war.sh $1 || {
+  	echo "ERROR: Localization script failed"
+  	exit 2
+  }
 }
 
-#Create the customized WAR and deploy it to Tomcat
-mkdir -p /tmp/vid/deployed
-cd /tmp/vid/stage
-jar -cvf /tmp/vid/deployed/vid.war .
-cd
-mv -f /tmp/vid/deployed/vid.war /usr/local/tomcat/webapps
+deployWarOnTomcatManually() {
+  cd /usr/local/tomcat/webapps/
+  mkdir vid
+  cd vid
+  jar -xf /tmp/vid/stage/vid.war
+}
+
+deployWarOnTomcatManually
+
+TEMPLATES_BASE_DIR=/usr/local/tomcat/webapps/vid/WEB-INF
+
+fillTemplateProperties ${TEMPLATES_BASE_DIR}
+
 catalina.sh run
diff --git a/deliveries/src/main/scripts/localize_asdc.sh b/deliveries/src/main/scripts/localize_asdc.sh
index 549c17a..af48318 100755
--- a/deliveries/src/main/scripts/localize_asdc.sh
+++ b/deliveries/src/main/scripts/localize_asdc.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/asdc.properties
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/asdc_template.properties
+FINAL_CONFIG_FILE=$1/conf/asdc.properties
+TEMPLATE_CONFIG_FILE=$1/conf/asdc_template.properties
 
 echo "Localizing the ASDC client configuration"
 
diff --git a/deliveries/src/main/scripts/localize_cache.sh b/deliveries/src/main/scripts/localize_cache.sh
index d25949c..2d676c3 100755
--- a/deliveries/src/main/scripts/localize_cache.sh
+++ b/deliveries/src/main/scripts/localize_cache.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/cache.ccf
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/cache_template.ccf
+FINAL_CONFIG_FILE=$1/classes/cache.ccf
+TEMPLATE_CONFIG_FILE=$1/classes/cache_template.ccf
 
 echo "Localizing the VID cache configuration"
 
diff --git a/deliveries/src/main/scripts/localize_log4j.sh b/deliveries/src/main/scripts/localize_log4j.sh
index d2ab2bb..121f567 100755
--- a/deliveries/src/main/scripts/localize_log4j.sh
+++ b/deliveries/src/main/scripts/localize_log4j.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/log4j.properties
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/log4j_template.properties
+FINAL_CONFIG_FILE=$1/conf/log4j.properties
+TEMPLATE_CONFIG_FILE=$1/conf/log4j_template.properties
 
 echo "Localizing the VID log4j configuration"
 
diff --git a/deliveries/src/main/scripts/localize_logback.sh b/deliveries/src/main/scripts/localize_logback.sh
index 43798eb..a0f1773 100755
--- a/deliveries/src/main/scripts/localize_logback.sh
+++ b/deliveries/src/main/scripts/localize_logback.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/logback.xml
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/logback_template.xml
+FINAL_CONFIG_FILE=$1/classes/logback.xml
+TEMPLATE_CONFIG_FILE=$1/classes/logback_template.xml
 
 echo "Localizing the VID logback configuration"
 
diff --git a/deliveries/src/main/scripts/localize_portal.sh b/deliveries/src/main/scripts/localize_portal.sh
index f29d485..947e0e1 100755
--- a/deliveries/src/main/scripts/localize_portal.sh
+++ b/deliveries/src/main/scripts/localize_portal.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/portal.properties
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/classes/portal_template.properties
+FINAL_CONFIG_FILE=$1/classes/portal.properties
+TEMPLATE_CONFIG_FILE=$1/classes/portal_template.properties
 
 echo "Localizing the VID portal configuration"
 
diff --git a/deliveries/src/main/scripts/localize_quartz.sh b/deliveries/src/main/scripts/localize_quartz.sh
index c284e6c..c22d879 100755
--- a/deliveries/src/main/scripts/localize_quartz.sh
+++ b/deliveries/src/main/scripts/localize_quartz.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/quartz.properties
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/quartz_template.properties
+FINAL_CONFIG_FILE=$1/conf/quartz.properties
+TEMPLATE_CONFIG_FILE=$1/conf/quartz_template.properties
 
 echo "Localizing the VID quartz configuration"
 
diff --git a/deliveries/src/main/scripts/localize_system.sh b/deliveries/src/main/scripts/localize_system.sh
index a739335..0947d49 100755
--- a/deliveries/src/main/scripts/localize_system.sh
+++ b/deliveries/src/main/scripts/localize_system.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 
-FINAL_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/system.properties
-TEMPLATE_CONFIG_FILE=/tmp/vid/stage/WEB-INF/conf/system_template.properties
+FINAL_CONFIG_FILE=$1/conf/system.properties
+TEMPLATE_CONFIG_FILE=$1/conf/system_template.properties
 
 echo "Localizing the VID system configuration"
 
diff --git a/deliveries/src/main/scripts/localize_war.sh b/deliveries/src/main/scripts/localize_war.sh
index f0669e0..99cb177 100755
--- a/deliveries/src/main/scripts/localize_war.sh
+++ b/deliveries/src/main/scripts/localize_war.sh
@@ -1,31 +1,31 @@
 #!/bin/bash
 
-source /tmp/vid/localize_logback.sh || {
+source /tmp/vid/localize_logback.sh $1 || {
 	echo "ERROR: Localizing logback.xml failed"
 	exit 1
 }
 
-source /tmp/vid/localize_portal.sh || {
+source /tmp/vid/localize_portal.sh $1 || {
 	echo "ERROR: Localizing portal.properties failed"
 	exit 1
 }
 
-source /tmp/vid/localize_quartz.sh || {
+source /tmp/vid/localize_quartz.sh $1 || {
 	echo "ERROR: Localizing quartz.properties failed"
 	exit 1
 }
 
-source /tmp/vid/localize_system.sh || {
+source /tmp/vid/localize_system.sh $1 || {
 	echo "ERROR: Localizing system.properties failed"
 	exit 1
 }
 
-source /tmp/vid/localize_cache.sh || {
+source /tmp/vid/localize_cache.sh $1 || {
 	echo "ERROR: Localizing cache.ccf failed"
 	exit 1
 }
 
-source /tmp/vid/localize_asdc.sh || {
+source /tmp/vid/localize_asdc.sh $1 || {
 	echo "ERROR: Localizing asdc.properties failed"
 	exit 1
 }
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java b/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java
index 03dc808..12cc68e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java
@@ -25,6 +25,7 @@
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.onap.vid.dao.FnAppDoaImpl;
 import org.onap.vid.model.GitRepositoryState;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -46,7 +47,6 @@
 @RequestMapping("/")
 public class HealthCheckController extends UnRestrictedBaseController {
 
-
     /**
      * The logger.
      */
@@ -58,6 +58,7 @@
     final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
 
     private static final String HEALTH_CHECK_PATH = "/healthCheck";
+    private static final String GIT_PROPERTIES_FILENAME = "git.properties";
 
     /**
      * Model for JSON response with health-check results.
@@ -193,10 +194,10 @@
         return healthStatus;
     }
 
-    @RequestMapping(value = "/version", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+    @RequestMapping(value = "/commitInfo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
     public GitRepositoryState getCommitInfo() throws IOException {
         Properties properties = new Properties();
-        properties.load(getClass().getClassLoader().getResourceAsStream("git.properties"));
+        properties.load(getClass().getClassLoader().getResourceAsStream(GIT_PROPERTIES_FILENAME));
         return new GitRepositoryState(properties);
     }
 }
diff --git a/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java
index ca7a163..6055bc3 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java
@@ -1,18 +1,32 @@
 package org.onap.vid.controllers;
 
+import org.apache.log4j.BasicConfigurator;
+import org.junit.Before;
 import org.junit.Test;
-import org.onap.vid.controllers.HealthCheckController;
 import org.onap.vid.controllers.HealthCheckController.HealthStatus;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
 
 public class HealthCheckControllerTest {
 
-	private HealthCheckController createTestSubject() {
-		return new HealthCheckController();
+	private HealthCheckController testSubject;
+	private MockMvc mockMvc;
+
+	@Before
+	public void setUp() {
+		testSubject = new HealthCheckController();
+		BasicConfigurator.configure();
+		mockMvc = MockMvcBuilders.standaloneSetup(testSubject).build();
 	}
 
 	@Test
 	public void testGetProfileCount() throws Exception {
-		HealthCheckController testSubject;
 		String driver = "";
 		String URL = "";
 		String username = "";
@@ -20,29 +34,34 @@
 		int result;
 
 		// default test
-		testSubject = createTestSubject();
 		result = testSubject.getProfileCount(driver, URL, username, password);
 	}
 
 	@Test
 	public void testGethealthCheckStatusforIDNS() throws Exception {
-		HealthCheckController testSubject;
 		HealthStatus result;
 
 		// default test
-		testSubject = createTestSubject();
 		result = testSubject.gethealthCheckStatusforIDNS();
 	}
 
 	@Test
 	public void testGetHealthCheck() throws Exception {
-		HealthCheckController testSubject;
 		String UserAgent = "";
 		String ECOMPRequestID = "";
 		HealthStatus result;
 
 		// default test
-		testSubject = createTestSubject();
 		result = testSubject.getHealthCheck(UserAgent, ECOMPRequestID);
 	}
+
+	@Test
+	public void testCommitInfoEndpoint() throws Exception {
+		mockMvc.perform(get("/commitInfo")
+				.accept(MediaType.APPLICATION_JSON))
+				.andExpect(status().isOk())
+				.andExpect(jsonPath("$.commitId").value("123987"))
+				.andExpect(jsonPath("$.commitMessageShort").value("Test short commit message"))
+				.andExpect(jsonPath("$.commitTime").value("1999-09-12T13:48:55+0200"));
+	}
 }
\ No newline at end of file
diff --git a/vid-app-common/src/test/resources/git.properties b/vid-app-common/src/test/resources/git.properties
new file mode 100644
index 0000000..d504e3e
--- /dev/null
+++ b/vid-app-common/src/test/resources/git.properties
@@ -0,0 +1,3 @@
+git.commit.id=123987
+git.commit.message.short=Test short commit message
+git.commit.time=1999-09-12T13\:48\:55+0200
\ No newline at end of file
diff --git a/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/get_sdc_catalog_services_83d587e1.json b/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/get_sdc_catalog_services_83d587e1.json
new file mode 100644
index 0000000..0bc179c
--- /dev/null
+++ b/vid-ext-services-simulator/src/main/resources/preset_registration/changeManagement/get_sdc_catalog_services_83d587e1.json
@@ -0,0 +1,38 @@
+[
+  {
+    "simulatorRequest": {
+      "method": "GET",
+      "path": "/sdc/v1/catalog/services/83d587e1-742d-4cb0-b087-3963b012dfe3/toscaModel"
+    },
+    "simulatorResponse": {
+      "responseCode": 200,
+      "file": "csar15782222_instantiationTypeMacroWithPnf.zip"
+    }
+  },
+  {
+    "simulatorRequest": {
+      "method": "GET",
+      "path": "/sdc/v1/catalog/services/83d587e1-742d-4cb0-b087-3963b012dfe3/metadata"
+    },
+    "simulatorResponse": {
+      "responseCode": 200,
+      "responseHeaders": {
+        "Content-Type": "application/json"
+      },
+      "body": {
+        "uuid": "83d587e1-742d-4cb0-b087-3963b012dfe3",
+        "invariantUUID": "any-id",
+        "name": "test-pnf",
+        "version": "1.0",
+        "toscaModelURL": "./csar15782222_instantiationTypeMacroWithPnf.zip",
+        "category": "Mobility",
+        "lifecycleState": "CERTIFIED",
+        "lastUpdaterUserId": "rg276b",
+        "lastUpdaterFullName": null,
+        "distributionStatus": "DISTRIBUTED",
+        "artifacts": null,
+        "resources": null
+      }
+    }
+  }
+]
\ No newline at end of file
diff --git a/vid-ext-services-simulator/src/main/resources/preset_registration/general/ecompportal_getSessionSlotCheckInterval.json b/vid-ext-services-simulator/src/main/resources/preset_registration/general/ecompportal_getSessionSlotCheckInterval.json
index a43092e..cc7f76c 100644
--- a/vid-ext-services-simulator/src/main/resources/preset_registration/general/ecompportal_getSessionSlotCheckInterval.json
+++ b/vid-ext-services-simulator/src/main/resources/preset_registration/general/ecompportal_getSessionSlotCheckInterval.json
@@ -2,7 +2,7 @@
   {
     "simulatorRequest": {
       "method": "GET",
-      "path": "/ecompportal_att/auxapi//getSessionSlotCheckInterval"
+      "path": "/ONAPPORTAL/auxapi/v[0-9]+/getSessionSlotCheckInterval"
     },
     "simulatorResponse": {
       "responseCode": 200,
@@ -12,7 +12,7 @@
   {
     "simulatorRequest": {
       "method": "POST",
-      "path": "/ecompportal_att/auxapi//extendSessionTimeOuts"
+      "path": "/ONAPPORTAL/auxapi//extendSessionTimeOuts"
     },
     "simulatorResponse": {
       "responseCode": 200,
@@ -22,7 +22,7 @@
   {
     "simulatorRequest": {
       "method": "GET",
-      "path": "/ecompportal_att/auxapi/context/get_user"
+      "path": "/ONAPPORTAL/auxapi/context/get_user"
     },
     "simulatorResponse": {
       "responseCode": 200,
diff --git a/vid-ext-services-simulator/src/main/resources/preset_registration/service-design-and-creation.json b/vid-ext-services-simulator/src/main/resources/preset_registration/service-design-and-creation.json
index 679c5d7..04b1f99 100644
--- a/vid-ext-services-simulator/src/main/resources/preset_registration/service-design-and-creation.json
+++ b/vid-ext-services-simulator/src/main/resources/preset_registration/service-design-and-creation.json
@@ -428,6 +428,24 @@
               ]
             }
           }
+        },
+        {
+          "model": {
+            "model-invariant-id": "any-id",
+            "model-type": "resource",
+            "resource-version": "10001",
+            "model-vers": {
+              "model-ver": [
+                {
+                  "model-version-id": "83d587e1-742d-4cb0-b087-3963b012dfe3",
+                  "model-name": "pnf-test",
+                  "model-version": "1.0",
+                  "model-description": "Should ask about CorrelationId",
+                  "resource-version": "200021"
+                }
+              ]
+            }
+          }
         }
       ]
     }