diff options
author | franciscovila <javier.paradela.vila@est.tech> | 2022-01-11 12:29:08 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-01-13 09:29:35 +0000 |
commit | 566ae1c6de94d1bceb3f8b93db883cfa620560be (patch) | |
tree | db729b692c40503b11a1b60b915e8b8a88eda2a7 /catalog-be/src/main | |
parent | d52bc4fff5b2f66e1616bf4c320d7dc9a9bf5702 (diff) |
Fix use of Optional in ComponentInstanceInputsMergeBL
Issue-ID: SDC-3830
Signed-off-by: franciscovila <javier.paradela.vila@est.tech>
Change-Id: I3504f3fdb449e2b236501eaa31dbe4e2cbda1247
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java index d8b5020046..020c8a9aa1 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java @@ -25,6 +25,7 @@ import fj.data.Either; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; import org.openecomp.sdc.be.components.merge.VspComponentsMergeCommand; import org.openecomp.sdc.be.components.merge.property.DataDefinitionsValuesMergingBusinessLogic; @@ -111,10 +112,13 @@ public class ComponentInstanceInputsMergeBL implements VspComponentsMergeCommand private void mergeOldInstanceInputsValues(Component oldComponent, Component newComponent, String instanceId, List<ComponentInstanceInput> instInputs) { - ComponentInstance currentCompInstance = newComponent.getComponentInstanceById(instanceId).get(); - List<ComponentInstanceInput> oldInstInputs = - oldComponent == null ? Collections.emptyList() : oldComponent.safeGetComponentInstanceInputsByName(currentCompInstance.getName()); - List<InputDefinition> oldInputs = oldComponent == null ? Collections.emptyList() : oldComponent.getInputs(); - propertyValuesMergingBusinessLogic.mergeInstanceDataDefinitions(oldInstInputs, oldInputs, instInputs, newComponent.getInputs()); + Optional<ComponentInstance> oCurrentCompInstance = newComponent.getComponentInstanceById(instanceId); + if (oCurrentCompInstance.isPresent()) { + ComponentInstance currentCompInstance = oCurrentCompInstance.get(); + List<ComponentInstanceInput> oldInstInputs = + oldComponent == null ? Collections.emptyList() : oldComponent.safeGetComponentInstanceInputsByName(currentCompInstance.getName()); + List<InputDefinition> oldInputs = oldComponent == null ? Collections.emptyList() : oldComponent.getInputs(); + propertyValuesMergingBusinessLogic.mergeInstanceDataDefinitions(oldInstInputs, oldInputs, instInputs, newComponent.getInputs()); + } } } |