diff options
author | JvD_Ericsson <jeff.van.dam@est.tech> | 2023-05-29 09:48:42 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-05-29 15:37:53 +0000 |
commit | 32d8a1dba11780a622b337e77830f9095f0767ee (patch) | |
tree | 4952eafb1390b90d68eb8c9bbb98ef13856d36ec /common-be/src | |
parent | 2a473f639dd543d78d1f2c6ca439722dccebefd1 (diff) |
Fix various bugs related to tosca custom functions
Issue-ID: SDC-4512
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Change-Id: Ia501b124ddf0c77c97ca0c14bbaa18be39b8f631
Diffstat (limited to 'common-be/src')
-rw-r--r-- | common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java index f77c6f949b..e234a4666f 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java @@ -37,6 +37,7 @@ import org.openecomp.sdc.be.datatypes.enums.PropertySource; import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.util.CollectionUtils; import org.yaml.snakeyaml.Yaml; public class ToscaFunctionJsonDeserializer extends StdDeserializer<ToscaFunction> { @@ -150,23 +151,25 @@ public class ToscaFunctionJsonDeserializer extends StdDeserializer<ToscaFunction return jsonNode.asText(); } - private List<Object> getNumberAsTextOrElseNull(final JsonNode node, final String fieldName, final DeserializationContext context) throws JsonMappingException{ + private List<Object> getNumberAsTextOrElseNull(final JsonNode node, final String fieldName, final DeserializationContext context) + throws JsonMappingException { List<Object> toscaIndexList = new ArrayList<Object>(); final JsonNode jsonNode = node.get(fieldName); if (jsonNode != null) { if (!jsonNode.isArray()) { throw context.instantiationException(ToscaGetFunctionDataDefinition.class, "Expecting an array for toscaIndexList attribute"); } - for (int index=0;index<jsonNode.size();index++) { + for (int index = 0; index < jsonNode.size(); index++) { String textValue = jsonNode.get(index).asText(); - if (index%2 == 0) { + if (index % 2 == 0) { if (textValue.equalsIgnoreCase("INDEX")) { toscaIndexList.add(textValue); } else { try { toscaIndexList.add(Integer.parseInt(textValue)); - } catch(Exception e) { - throw context.instantiationException(ToscaGetFunctionDataDefinition.class, "Expecting a valid value for toscaIndex attribute"); + } catch (Exception e) { + throw context.instantiationException(ToscaGetFunctionDataDefinition.class, + "Expecting a valid value for toscaIndex attribute"); } } } else { @@ -205,7 +208,7 @@ public class ToscaFunctionJsonDeserializer extends StdDeserializer<ToscaFunction private ToscaFunctionType getCustomFunctionType(String name) { List<Configuration.CustomToscaFunction> customFunctions = ConfigurationManager.getConfigurationManager().getConfiguration().getDefaultCustomToscaFunctions(); - if (customFunctions.isEmpty()) { + if (CollectionUtils.isEmpty(customFunctions)) { return ToscaFunctionType.CUSTOM; } Optional<Configuration.CustomToscaFunction> optionalFunc = customFunctions.stream().filter(func -> func.getName().equals(name)).findFirst(); |