From 4be9e10f23a3d64607c9d986ce98146c828b94f8 Mon Sep 17 00:00:00 2001 From: zm330 Date: Tue, 30 Apr 2019 20:11:22 +0800 Subject: add resource input Save format when resource is list type e.g. {key2:vf_prop_list,INDEX,key|default} Change-Id: I1cde294eb790df0be6df13cfae9959310b93f366 Issue-ID: SO-1393 Signed-off-by: zm330 --- .../installer/heat/ToscaResourceInputTest.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'asdc-controller/src/test/java/org/onap') 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 844adeede2..f6a369e405 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 @@ -33,10 +33,7 @@ import org.onap.sdc.toscaparser.api.parameters.Input; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; import org.onap.so.asdc.installer.ToscaResourceStructure; import org.onap.so.db.catalog.beans.Service; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedHashMap; +import java.util.*; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Mockito.when; @@ -60,6 +57,23 @@ public class ToscaResourceInputTest { @Mock Input input; + @Test + public void getListResourceInput() { + ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller(); + LinkedHashMap hashMap = new LinkedHashMap<>(); + hashMap.put("key1", property); + when(nodeTemplate.getProperties()).thenReturn(hashMap); + when(property.getValue()).thenReturn(getInput); + when(getInput.getInputName()).thenReturn("nameKey"); + when(input.getName()).thenReturn("nameKey"); + when(input.getDefault()).thenReturn("defaultValue"); + when(getInput.toString()).thenReturn("getinput:[sites,INDEX,role]"); + List inputs = new ArrayList<>(); + inputs.add(input); + String resourceInput = toscaResourceInstaller.getVnfcResourceInput(nodeTemplate, inputs); + assertEquals("{\\\"key1\\\":\\\"sites,INDEX,role|defaultValue\\\"}", resourceInput); + } + @Test public void processResourceSequenceTest() { ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller(); -- cgit 1.2.3-korg