From 8ac648a7e1148caca6d8a3bab799893393246d8a Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Tue, 22 Jan 2019 14:27:55 +0530 Subject: Fix Integer cast exception in getResourceInput Fix Integer cast exception in getResourceInput. Change-Id: I2022ec07fe12bfe1764f734f1776f6bd32143b84 Issue-ID: SO-1408 Signed-off-by: subhash kumar singh --- .../installer/heat/ToscaResourceInputTest.java | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'asdc-controller/src/test/java/org') 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); + } } -- cgit 1.2.3-korg