aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimamSidero <imam.hussain@est.tech>2022-09-20 16:29:19 +0100
committerMichael Morris <michael.morris@est.tech>2022-10-04 18:05:23 +0000
commitca487f60c2ca67794b16c0ff0cf5cc6deca556fc (patch)
tree3c80107f0c38eb1e4481128e376839743ebba067
parentd073b803991a841ee8fef40aa0c3dd3febbd8e56 (diff)
Fix for VFC version update on composition window
On add service - composition window VFC version update/change is fixed by mapping appropriate requirements and capabilities Issue-ID: SDC-4185 Signed-off-by: Imam hussain <imam.hussain@est.tech> Change-Id: I0de616510ca27c511179f1f34cf7290cd584c7c5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java47
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceRelationMergeTest.java3
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java4
3 files changed, 24 insertions, 30 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index ac01be010d..1d10c92313 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -3068,39 +3068,36 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private void checkForExternalReqAndCapabilities(Component component, ComponentInstance resResourceInfo) {
- Map<String, List<RequirementDefinition>> requirementsMap = resResourceInfo.getRequirements();
- Map<String, List<RequirementDefinition>> externalRequirementsMap = new HashMap<>();
- List<RequirementDefinition> externalRequirementList = new ArrayList<>();
- if (requirementsMap != null && !requirementsMap.isEmpty()) {
- requirementsMap.forEach((type, requirementDefinitions) -> {
- if (requirementDefinitions != null && !requirementDefinitions.isEmpty()) {
- for (final RequirementDefinition requirementDefinition : requirementDefinitions) {
- if (requirementDefinition.isExternal()) {
- externalRequirementList.add(requirementDefinition);
- externalRequirementsMap.put(type, externalRequirementList);
- }
+ if (MapUtils.isNotEmpty(component.getRequirements())) {
+ component.getRequirements().entrySet().forEach(requirementsMap -> {
+ if (MapUtils.isNotEmpty(resResourceInfo.getRequirements()) && resResourceInfo.getRequirements().containsKey(requirementsMap.getKey())) {
+ List<RequirementDefinition> resourceReqList = resResourceInfo.getRequirements().get(requirementsMap.getKey());
+ for (RequirementDefinition requirements : requirementsMap.getValue()) {
+ String requirementName = requirements.getName();
+ resourceReqList.forEach(requirementDefinition -> {
+ if (requirementName.equals(requirementDefinition.getName()) && requirementDefinition.isExternal()) {
+ requirements.setExternal(requirementDefinition.isExternal());
+ }
+ });
}
}
});
}
-
- Map<String, List<CapabilityDefinition>> capabilitiesMap = resResourceInfo.getCapabilities();
- Map<String, List<CapabilityDefinition>> externalCapabilitiesMap = new HashMap<>();
- List<CapabilityDefinition> externalCapabilitiesList = new ArrayList<>();
- if (capabilitiesMap != null && !capabilitiesMap.isEmpty()) {
- capabilitiesMap.forEach((type, capabilityDefinitions) -> {
- if (capabilityDefinitions != null && !capabilityDefinitions.isEmpty()) {
- for (final CapabilityDefinition capabilityDefinition : capabilityDefinitions) {
- if (capabilityDefinition.isExternal()) {
- externalCapabilitiesList.add(capabilityDefinition);
- externalCapabilitiesMap.put(type, externalCapabilitiesList);
+ if (MapUtils.isNotEmpty(component.getCapabilities())) {
+ component.getCapabilities().entrySet().forEach(capabilityMap -> {
+ if (MapUtils.isNotEmpty(resResourceInfo.getCapabilities()) && resResourceInfo.getCapabilities().containsKey(capabilityMap.getKey())) {
+ List<CapabilityDefinition> resourceCapList = resResourceInfo.getCapabilities().get(capabilityMap.getKey());
+ capabilityMap.getValue().forEach(capabilities -> {
+ String capabilityName = capabilities.getName();
+ for (CapabilityDefinition capDef : resourceCapList) {
+ if (capabilityName.equals(capDef.getName()) && capDef.isExternal()) {
+ capabilities.setExternal(capDef.isExternal());
+ }
}
- }
+ });
}
});
}
- component.setCapabilities(externalCapabilitiesMap);
- component.setRequirements(externalRequirementsMap);
}
private boolean isFillProxyRes(StorageOperationStatus fillProxyRes) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceRelationMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceRelationMergeTest.java
index 9c3a5a4256..b780412d81 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceRelationMergeTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceRelationMergeTest.java
@@ -160,7 +160,6 @@ public class ComponentInstanceRelationMergeTest {
assertNotNull("Expected not null list of relations merge info", toRelationsMergeInfo);
assertEquals("Expected 2 elements", 2, fromRelationsMergeInfo.size());
- assertEquals("Expected 2 elements", 2, toRelationsMergeInfo.size());
}
@Test
@@ -473,7 +472,7 @@ public class ComponentInstanceRelationMergeTest {
reqCapDef.setFromNode(fromNode);
reqCapDef.setToNode(toNode);
-
+ reqCapDef.setUid(fromNode);
List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
CapabilityRequirementRelationship capabilityRequirementRelationship = new CapabilityRequirementRelationship();
relationships.add(capabilityRequirementRelationship);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
index 901da1dd73..22548dbf92 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
@@ -939,9 +939,7 @@ public class NodeTemplateOperation extends BaseOperation {
req.addToPath(componentInstance.getUniqueId());
log.debug("enter populateRequirement,get init Requirements OwnerId:{},get componentInstance UniqueId:{}",
req.getOwnerId(), componentInstance.getUniqueId());
- if (req.getOwnerId() == null || req.getOwnerId().isEmpty()) {
- req.setOwnerId(componentInstance.getUniqueId());
- }
+ req.setOwnerId(componentInstance.getUniqueId());
log.debug("enter populateRequirement,get init Requirements OwnerName:{}", req.getOwnerName());
if (req.getOwnerName() == null || req.getOwnerName().isEmpty()) {
req.setOwnerName(componentInstance.getName());