diff options
author | subhash kumar singh <subhash.kumar.singh@huawei.com> | 2019-01-22 14:27:55 +0530 |
---|---|---|
committer | subhash kumar singh <subhash.kumar.singh@huawei.com> | 2019-01-22 14:27:55 +0530 |
commit | 8ac648a7e1148caca6d8a3bab799893393246d8a (patch) | |
tree | a36810dbeb64ea7c0766a416b7696e121b6936f5 | |
parent | b26de276956c687b8ff2dd1ec04861ad23c4c31e (diff) |
Fix Integer cast exception in getResourceInputso-1408
Fix Integer cast exception in getResourceInput.
Change-Id: I2022ec07fe12bfe1764f734f1776f6bd32143b84
Issue-ID: SO-1408
Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
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); + } } |