aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-translator-lib
diff options
context:
space:
mode:
authorfranciscovila <javier.paradela.vila@est.tech>2022-01-24 10:10:40 +0000
committerAndr� Schmid <andre.schmid@est.tech>2022-01-25 10:02:05 +0000
commit7a98ee137b17a808635b06d72955e01ac84fe55b (patch)
treec13573a7236bc9b1aad50de08ee97f43b6009e21 /openecomp-be/lib/openecomp-sdc-translator-lib
parent3ba359e291789363ce2670c72da8eaa9caa5f956 (diff)
Fix use of Optional in TranslatorHeatToToscaPropertyConverter
Checking the Optionals are present before getting their values in the TranslatorHeatToToscaPropertyConverter class Issue-ID: SDC-3834 Signed-off-by: franciscovila <javier.paradela.vila@est.tech> Change-Id: I92f9153adea8be4225c0a181fd31b9f7090bde96
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaPropertyConverter.java8
1 files changed, 6 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/TranslatorHeatToToscaPropertyConverter.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaPropertyConverter.java
index b9cad2f474..7b2a93c18d 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaPropertyConverter.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/mapping/TranslatorHeatToToscaPropertyConverter.java
@@ -25,12 +25,15 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
+
import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.onap.sdc.tosca.datatypes.model.Template;
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
import org.openecomp.sdc.translator.services.heattotosca.ConfigConstants;
import org.openecomp.sdc.translator.services.heattotosca.Constants;
+import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslation;
import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslationFactory;
import org.openecomp.sdc.translator.services.heattotosca.impl.functiontranslation.FunctionTranslator;
@@ -113,11 +116,12 @@ public class TranslatorHeatToToscaPropertyConverter {
Template template, TranslationContext context) {
if (propertyValue instanceof Map && !((Map) propertyValue).isEmpty()) {
Map.Entry<String, Object> functionMapEntry = (Map.Entry<String, Object>) ((Map) propertyValue).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, resourceId, heatFileName, heatOrchestrationTemplate, context), propertyName,
functionMapEntry.getValue(), template);
- return FunctionTranslationFactory.getInstance(functionMapEntry.getKey()).get().translateFunction(functionTranslator);
+ return optFunctionTranslation.get().translateFunction(functionTranslator);
}
Map<String, Object> propertyValueMap = new HashMap<>();
for (Map.Entry<String, Object> entry : ((Map<String, Object>) propertyValue).entrySet()) {