From 1f7c6cccdd3a9544a7760db9a305403def4e5365 Mon Sep 17 00:00:00 2001 From: vasraz Date: Thu, 17 Aug 2023 11:31:31 +0100 Subject: Fix 'Tosca Function get_input in Properties Assignment error'-bug Signed-off-by: Vasyl Razinkov Change-Id: If404b777b7be312d7f51c3d27905af898eb74eb6 Issue-ID: SDC-4598 --- .../elements/ToscaFunctionJsonDeserializerTest.java | 18 ++++++++++-------- .../elements/ToscaGetFunctionDataDefinitionTest.java | 10 +++++----- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'common-be/src/test/java/org/openecomp') diff --git a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializerTest.java b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializerTest.java index 5128c63668..d0bc953df1 100644 --- a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializerTest.java +++ b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializerTest.java @@ -209,10 +209,12 @@ class ToscaFunctionJsonDeserializerTest { assertEquals(1, yamlMap.size()); final Object customFunctionGetInputValue = yamlMap.get("$" + ((ToscaCustomFunction) toscaFunction).getName()); assertTrue(customFunctionGetInputValue instanceof ArrayList); - ArrayList customFunctionGetInputValueList = (ArrayList) customFunctionGetInputValue; - assertEquals(1, customFunctionGetInputValueList.size()); - assertEquals(1, customFunctionGetInputValueList.size()); - assertEquals("controller_actor", customFunctionGetInputValueList.get(0)); + List customFunctionGetInputValueList = (ArrayList) customFunctionGetInputValue; + assertEquals(4, customFunctionGetInputValueList.size()); + assertEquals("pLMNInfoList", customFunctionGetInputValueList.get(0)); + assertEquals(1, customFunctionGetInputValueList.get(1)); + assertEquals("snssai", customFunctionGetInputValueList.get(2)); + assertEquals("sd", customFunctionGetInputValueList.get(3)); List parameters = toscaCustomFunction.getParameters(); assertEquals(1, parameters.size()); @@ -222,12 +224,12 @@ class ToscaFunctionJsonDeserializerTest { final ToscaGetFunctionDataDefinition toscaGetFunction = (ToscaGetFunctionDataDefinition) paramFunction; assertEquals(ToscaFunctionType.GET_INPUT, toscaGetFunction.getType()); assertEquals(ToscaGetFunctionType.GET_INPUT, toscaGetFunction.getFunctionType()); - assertEquals("dd0ec4d2-7e74-4d92-af2f-89c7436baa63.controller_actor", toscaGetFunction.getPropertyUniqueId()); + assertEquals("dd0ec4d2-7e74-4d92-af2f-89c7436baa63.pLMNInfoList", toscaGetFunction.getPropertyUniqueId()); assertEquals(PropertySource.SELF, toscaGetFunction.getPropertySource()); - assertEquals("controller_actor", toscaGetFunction.getPropertyName()); + assertEquals("pLMNInfoList", toscaGetFunction.getPropertyName()); assertEquals("testService", toscaGetFunction.getSourceName()); assertEquals("dd0ec4d2-7e74-4d92-af2f-89c7436baa63", toscaGetFunction.getSourceUniqueId()); - assertEquals(List.of("controller_actor"), toscaGetFunction.getPropertyPathFromSource()); + assertEquals(List.of("pLMNInfoList"), toscaGetFunction.getPropertyPathFromSource()); } private void setDefaultCustomToscaFunctionOnConfiguration() { @@ -245,4 +247,4 @@ class ToscaFunctionJsonDeserializerTest { private ToscaFunction parseToscaFunction(final String toscaFunctionJson) throws JsonProcessingException { return new ObjectMapper().readValue(toscaFunctionJson, ToscaFunction.class); } -} \ No newline at end of file +} diff --git a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinitionTest.java b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinitionTest.java index 3add149e23..fbbaff56d1 100644 --- a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinitionTest.java +++ b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinitionTest.java @@ -62,8 +62,8 @@ class ToscaGetFunctionDataDefinitionTest { final Map getInputJsonAsMap = convertJsonStringToMap(actualValue); assertTrue(getInputJsonAsMap.containsKey(ToscaGetFunctionType.GET_INPUT.getFunctionName())); final Object value = getInputJsonAsMap.get(ToscaGetFunctionType.GET_INPUT.getFunctionName()); - assertTrue(value instanceof List); - assertEquals(((List)value).get(0), propertyName); + assertTrue(value instanceof String); + assertEquals(value, propertyName); } @Test @@ -86,7 +86,7 @@ class ToscaGetFunctionDataDefinitionTest { } @ParameterizedTest - @EnumSource(value = ToscaGetFunctionType.class, names = {"GET_ATTRIBUTE", "GET_PROPERTY"}) + @EnumSource(value = ToscaGetFunctionType.class, names = {"GET_ATTRIBUTE", "GET_PROPERTY"}) void generateValueForGetFunctionWithSelfAsSourceTest(final ToscaGetFunctionType toscaFunction) { //given final var toscaGetFunction = createGetFunction(toscaFunction, PropertySource.SELF, List.of("property"), null); @@ -118,7 +118,7 @@ class ToscaGetFunctionDataDefinitionTest { } @ParameterizedTest - @EnumSource(value = ToscaGetFunctionType.class, names = {"GET_ATTRIBUTE", "GET_PROPERTY"}) + @EnumSource(value = ToscaGetFunctionType.class, names = {"GET_ATTRIBUTE", "GET_PROPERTY"}) void generateValueForGetFunctionWithInstanceAsSourceTest(final ToscaGetFunctionType toscaFunction) { //given final var toscaGetFunction = createGetFunction(toscaFunction, PropertySource.INSTANCE, List.of("property"), "sourceName"); @@ -215,4 +215,4 @@ class ToscaGetFunctionDataDefinitionTest { final Gson gson = new Gson(); return gson.fromJson(actualValue, Map.class); } -} \ No newline at end of file +} -- cgit 1.2.3-korg