summaryrefslogtreecommitdiffstats
path: root/asdc-controller
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java2
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java49
2 files changed, 50 insertions, 1 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index b3fda73045..aa1e1a8bd9 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -425,7 +425,7 @@ public class ToscaResourceInstaller {
if(input.getName().equals(inputName)) {
// keep both input name and default value
// if service input does not supplies value the use default value
- String defaultValue = input.getDefault() != null ? (String) input.getDefault() : "";
+ String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
output = inputName + "|" + defaultValue;// return default value
}
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
index e738235a0a..bc9275bb51 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
@@ -133,4 +133,53 @@ public class ToscaResourceInputTest {
String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1");
assertEquals("{\\\"prop1\\\":\\\"res_key|default_value\\\"}", resourceInput);
}
+
+ @Test
+ public void resouceInputGetInputDefaultIntegerTest() throws ArtifactInstallerException {
+ ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
+ ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
+
+ toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
+
+ HashMap hashMap = new HashMap();
+ hashMap.put("customizationUUID", "id1");
+ Metadata metadata = new Metadata(hashMap);
+
+ LinkedHashMap propertyMap = new LinkedHashMap();
+ propertyMap.put("prop1", property);
+
+ when(sdcCsarHelper.getServiceNodeTemplates()).thenReturn(Arrays.asList(nodeTemplate));
+ when(sdcCsarHelper.getServiceInputs()).thenReturn(Arrays.asList(input));
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(nodeTemplate.getProperties()).thenReturn(propertyMap);
+ when(property.getValue()).thenReturn(getInput);
+ when(getInput.getInputName()).thenReturn("res_key");
+ when(input.getName()).thenReturn("res_key");
+ when(input.getDefault()).thenReturn(new Integer(10));
+
+ String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1");
+ assertEquals("{\\\"prop1\\\":\\\"res_key|10\\\"}", resourceInput);
+ }
+
+ @Test
+ public void resouceInputGetInputNoPropertyTest() throws ArtifactInstallerException {
+ ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
+ ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
+
+ toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
+
+ HashMap hashMap = new HashMap();
+ hashMap.put("customizationUUID", "id1");
+ Metadata metadata = new Metadata(hashMap);
+
+ LinkedHashMap propertyMap = new LinkedHashMap();
+
+ when(sdcCsarHelper.getServiceNodeTemplates()).thenReturn(Arrays.asList(nodeTemplate));
+ when(sdcCsarHelper.getServiceInputs()).thenReturn(Arrays.asList(input));
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(nodeTemplate.getProperties()).thenReturn(propertyMap);
+
+ String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1");
+ assertEquals("{}", resourceInput);
+ }
}