From 7a7b13726c195e2944ccc59e4d5c5ade57318763 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Wed, 15 Jun 2022 15:30:40 +0100 Subject: Support TOSCA get_attribute function Adds support to TOSCA get_attribute function in the Property Assignment TOSCA Function modal. Change-Id: I73dda215a7c9d7fecf0803cc259634279c3bdfb6 Issue-ID: SDC-4053 Signed-off-by: andre.schmid --- .../datatypes/elements/ToscaGetFunctionDataDefinition.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'common-be/src/main') diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java index adc2ad6b44..0741d6849e 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java @@ -63,8 +63,8 @@ public class ToscaGetFunctionDataDefinition { } final var gson = new Gson(); - if (functionType == ToscaGetFunctionType.GET_PROPERTY) { - return gson.toJson(buildGetPropertyFunctionValue()); + if (functionType == ToscaGetFunctionType.GET_PROPERTY || functionType == ToscaGetFunctionType.GET_ATTRIBUTE) { + return gson.toJson(buildFunctionValueWithPropertySource()); } if (functionType == ToscaGetFunctionType.GET_INPUT) { return gson.toJson(buildGetInputFunctionValue()); @@ -73,9 +73,11 @@ public class ToscaGetFunctionDataDefinition { throw new UnsupportedOperationException(String.format("ToscaGetFunctionType '%s' is not supported yet", functionType)); } - private Map buildGetPropertyFunctionValue() { + private Map buildFunctionValueWithPropertySource() { if (propertySource == null) { - throw new IllegalStateException("propertySource is required in order to generate the get_property value"); + throw new IllegalStateException( + String.format("propertySource is required in order to generate the %s value", functionType.getFunctionName()) + ); } if (propertySource == PropertySource.SELF) { return Map.of(functionType.getFunctionName(), @@ -84,7 +86,9 @@ public class ToscaGetFunctionDataDefinition { } if (propertySource == PropertySource.INSTANCE) { if (sourceName == null) { - throw new IllegalStateException("sourceName is required in order to generate the get_property from INSTANCE value"); + throw new IllegalStateException( + String.format("sourceName is required in order to generate the %s from INSTANCE value", functionType.getFunctionName()) + ); } return Map.of(functionType.getFunctionName(), Stream.concat(Stream.of(sourceName), propertyPathFromSource.stream()).collect(Collectors.toList()) -- cgit 1.2.3-korg