aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfranciscovila <javier.paradela.vila@est.tech>2022-01-24 10:15:42 +0000
committerFrancisco Javier Paradela Vila <javier.paradela.vila@est.tech>2022-01-24 10:20:27 +0000
commit03df024d4f9ace16307f380bdb5c131dd896f3db (patch)
tree0d0dc44fe3a0a76688a50710b6da0e795573dcde
parent3c33df0dc2d58d8e8bdbb52c0ca1ce8f93bce415 (diff)
Fix use of Optional in TranslatorHeatToToscaParameterConverter
Checking the Optionals are present before getting their values in the TranslatorHeatToToscaParameterConverter class Issue-ID: SDC-3833 Signed-off-by: franciscovila <javier.paradela.vila@est.tech> Change-Id: I133b47aadfa11b42736fe2b68bee4fba78847f00
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaParameterConverter.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaParameterConverter.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaParameterConverter.java
index 9361b33e65..78f3846c76 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaParameterConverter.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaParameterConverter.java
@@ -45,6 +45,7 @@ import org.openecomp.sdc.heat.datatypes.model.Parameter;
import org.openecomp.sdc.tosca.datatypes.extend.ToscaAnnotationType;
import org.openecomp.sdc.tosca.services.ToscaConstants;
import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
+import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslation;
import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslationFactory;
import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
import org.openecomp.sdc.translator.services.heattotosca.impl.functiontranslation.FunctionTranslator;
@@ -229,11 +230,12 @@ public class TranslatorHeatToToscaParameterConverter {
return new HashMap<>();
}
Map.Entry<String, Object> functionMapEntry = (Map.Entry<String, Object>) ((Map) paramValue).entrySet().iterator().next();
- if (FunctionTranslationFactory.getInstance(functionMapEntry.getKey()).isPresent()) {
+ Optional<FunctionTranslation> optFunctionTranslation = FunctionTranslationFactory.getInstance(functionMapEntry.getKey());
+ if (optFunctionTranslation.isPresent()) {
FunctionTranslator functionTranslator = new FunctionTranslator(
getFunctionTranslateTo(serviceTemplate, null, heatFileName, heatOrchestrationTemplate, context), parameterName,
functionMapEntry.getValue(), null);
- return FunctionTranslationFactory.getInstance(functionMapEntry.getKey()).isPresent() ? FunctionTranslationFactory.getInstance(functionMapEntry.getKey()).get().translateFunction(functionTranslator) : paramValue;
+ return optFunctionTranslation.get().translateFunction(functionTranslator);
}
}
return paramValue;