aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2021-11-03 20:43:16 +0000
committerMichael Morris <michael.morris@est.tech>2021-12-06 14:05:00 +0000
commita7dd2ece847fa88dda4912994f2e5220bd4adb7b (patch)
tree737a199af0cf70b26cb99d696c6c7f0872859f5b
parentd5edf5274286e9808dfabf2f49a03a1ba235b70c (diff)
Update import service to import node filter
Issue-ID: SDC-3775 Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Change-Id: Ide75c9319ad321d796a1ead34cbf425ad8de5504
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java86
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java14
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java16
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java51
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java14
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java55
6 files changed, 221 insertions, 15 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
index 43187a59d6..729538c640 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
@@ -21,11 +21,17 @@ package org.openecomp.sdc.be.components.impl;
import static org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR;
import fj.data.Either;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.components.impl.exceptions.BusinessLogicException;
+import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.utils.CINodeFilterUtils;
import org.openecomp.sdc.be.components.impl.utils.NodeFilterConstraintAction;
import org.openecomp.sdc.be.components.validation.NodeFilterValidator;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -38,6 +44,7 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeFilterConstraintType;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.UploadNodeFilterInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
@@ -318,4 +325,83 @@ public class ComponentNodeFilterBusinessLogic extends BaseBusinessLogic {
new ConstraintConvertor().convert(uiConstraint), true, componentTypeEnum, nodeFilterConstraintType,
StringUtils.isEmpty(uiConstraint.getCapabilityName()) ? "" : uiConstraint.getCapabilityName());
}
+
+ public StorageOperationStatus associateNodeFilterToComponentInstance(final String componentId,
+ final Map<String, UploadNodeFilterInfo> instNodeFilter) {
+ for (Entry<String, UploadNodeFilterInfo> filter : instNodeFilter.entrySet()) {
+ String componentInstanceId = filter.getKey();
+ CINodeFilterDataDefinition ciNodeFilterDataDefinition = new CINodeFilterUtils()
+ .getNodeFilterDataDefinition(filter.getValue(), componentInstanceId);
+ Either<CINodeFilterDataDefinition, StorageOperationStatus> nodeFilter = nodeFilterOperation.createNodeFilter(componentId,
+ componentInstanceId);
+ if (nodeFilter.isRight()) {
+ LOGGER.error(BUSINESS_PROCESS_ERROR, "Failed to Create Node filter on component instance with id {}",
+ filter.getKey());
+ return nodeFilter.right().value();
+ }
+
+ //associate node filter properties to component instance
+ List<RequirementNodeFilterPropertyDataDefinition> properties = ciNodeFilterDataDefinition.getProperties()
+ .getListToscaDataDefinition();
+ if (!properties.isEmpty()) {
+ properties.forEach(property -> {
+ RequirementNodeFilterPropertyDataDefinition requirementNodeFilterPropertyDataDefinition =
+ getRequirementNodeFilterPropertyDataDefinition(property);
+ Either<CINodeFilterDataDefinition, StorageOperationStatus> nodeFilterProperty = nodeFilterOperation
+ .addNewProperty(componentId, componentInstanceId, nodeFilter.left().value(), requirementNodeFilterPropertyDataDefinition);
+ if (nodeFilterProperty.isRight()) {
+ throw new ComponentException(
+ componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(nodeFilterProperty.right().value()),
+ componentInstanceId));
+ }
+ });
+ }
+
+ //associate node filter capabilities to component instance
+ List<RequirementNodeFilterCapabilityDataDefinition> capabilities = ciNodeFilterDataDefinition.getCapabilities()
+ .getListToscaDataDefinition();
+ if (!capabilities.isEmpty()) {
+ capabilities.forEach(capability -> {
+ RequirementNodeFilterCapabilityDataDefinition requirementNodeFilterCapabilityDataDefinition =
+ new RequirementNodeFilterCapabilityDataDefinition();
+ requirementNodeFilterCapabilityDataDefinition.setName(capability.getName());
+ requirementNodeFilterCapabilityDataDefinition.setProperties(getProperties(capability.getProperties()));
+ Either<CINodeFilterDataDefinition, StorageOperationStatus> nodeFilterCapability = nodeFilterOperation
+ .addNewCapabilities(componentId, componentInstanceId, nodeFilter.left().value(),
+ requirementNodeFilterCapabilityDataDefinition);
+ if (nodeFilterCapability.isRight()) {
+ throw new ComponentException(
+ componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(nodeFilterCapability.right().value()),
+ componentInstanceId));
+ }
+ });
+ }
+ }
+ return StorageOperationStatus.OK;
+ }
+
+ private List<String> getNodeFilterConstraints(String name, List<String> value) {
+ List<String> constraints = new ArrayList<>();
+ String values = value.get(0).split("\n")[0];
+ constraints.add(name + ": {" + values + "}");
+ return constraints;
+ }
+
+ private ListDataDefinition<RequirementNodeFilterPropertyDataDefinition> getProperties(ListDataDefinition<RequirementNodeFilterPropertyDataDefinition> properties) {
+ ListDataDefinition<RequirementNodeFilterPropertyDataDefinition> updatedProperties = new ListDataDefinition<>();
+ properties.getListToscaDataDefinition().forEach(property -> {
+ RequirementNodeFilterPropertyDataDefinition requirementNodeFilterPropertyDataDefinition = getRequirementNodeFilterPropertyDataDefinition(
+ property);
+ updatedProperties.add(requirementNodeFilterPropertyDataDefinition);
+ });
+ return updatedProperties;
+ }
+
+ private RequirementNodeFilterPropertyDataDefinition getRequirementNodeFilterPropertyDataDefinition(
+ RequirementNodeFilterPropertyDataDefinition property) {
+ RequirementNodeFilterPropertyDataDefinition requirementNodeFilterPropertyDataDefinition = new RequirementNodeFilterPropertyDataDefinition();
+ requirementNodeFilterPropertyDataDefinition.setName(property.getName());
+ requirementNodeFilterPropertyDataDefinition.setConstraints(getNodeFilterConstraints(property.getName(), property.getConstraints()));
+ return requirementNodeFilterPropertyDataDefinition;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index d3e7085e4f..2fa20ea3a9 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -68,6 +68,7 @@ import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
+import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
@@ -171,6 +172,8 @@ public class ServiceImportBusinessLogic {
private ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic;
@Autowired
private ServiceImportParseLogic serviceImportParseLogic;
+ @Autowired
+ private ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic;
@Autowired
public ServiceImportBusinessLogic(IElementOperation elementDao, IGroupOperation groupOperation, IGroupInstanceOperation groupInstanceOperation,
@@ -971,6 +974,7 @@ public class ServiceImportBusinessLogic {
Map<String, Resource> originCompMap = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+ Map<String, UploadNodeFilterInfo> instNodeFilter = new HashMap<>();
log.debug("enter ServiceImportBusinessLogic createResourceInstancesRelations#createResourceInstancesRelations - Before get all datatypes. ");
final ApplicationDataTypeCache applicationDataTypeCache = serviceBusinessLogic.applicationDataTypeCache;
@@ -979,7 +983,7 @@ public class ServiceImportBusinessLogic {
uploadResInstancesMap.values().forEach(
i -> processComponentInstance(yamlName, finalResource, componentInstancesList,
componentsUtils.getAllDataTypes(applicationDataTypeCache, finalResource.getModel()), instProperties, instCapabilities,
- instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, i));
+ instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, instNodeFilter, i));
}
serviceImportParseLogic.associateComponentInstancePropertiesToComponent(yamlName, resource, instProperties);
serviceImportParseLogic.associateComponentInstanceInputsToComponent(yamlName, resource, instInputs);
@@ -1334,6 +1338,7 @@ public class ServiceImportBusinessLogic {
Map<String, Resource> originCompMap = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+ Map<String, UploadNodeFilterInfo> instNodeFilter = new HashMap<>();
log.debug("enter ServiceImportBusinessLogic createServiceInstancesRelations#createResourceInstancesRelations - Before get all datatypes. ");
final ApplicationDataTypeCache applicationDataTypeCache = serviceBusinessLogic.applicationDataTypeCache;
if (applicationDataTypeCache != null) {
@@ -1341,10 +1346,11 @@ public class ServiceImportBusinessLogic {
uploadResInstancesMap.values().forEach(
i -> processComponentInstance(yamlName, finalResource, componentInstancesList,
componentsUtils.getAllDataTypes(applicationDataTypeCache, finalResource.getModel()), instProperties,
- instCapabilities, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, i));
+ instCapabilities, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, instNodeFilter, i));
}
serviceImportParseLogic.associateComponentInstancePropertiesToComponent(yamlName, service, instProperties);
serviceImportParseLogic.associateComponentInstanceInputsToComponent(yamlName, service, instInputs);
+ serviceImportParseLogic.associateCINodeFilterToComponent(yamlName, service, instNodeFilter);
serviceImportParseLogic.associateDeploymentArtifactsToInstances(user, yamlName, service, instDeploymentArtifacts);
serviceImportParseLogic.associateArtifactsToInstances(yamlName, service, instArtifacts);
serviceImportParseLogic.associateOrAddCalculatedCapReq(yamlName, service, instCapabilities, instRequirements);
@@ -1379,6 +1385,7 @@ public class ServiceImportBusinessLogic {
Map<String, Map<String, ArtifactDefinition>> instArtifacts,
Map<String, List<AttributeDefinition>> instAttributes, Map<String, Resource> originCompMap,
Map<String, List<ComponentInstanceInput>> instInputs,
+ Map<String, UploadNodeFilterInfo> instNodeFilter,
UploadComponentInstanceInfo uploadComponentInstanceInfo) {
log.debug("enter ServiceImportBusinessLogic processComponentInstance");
Optional<ComponentInstance> currentCompInstanceOpt = componentInstancesList.stream()
@@ -1409,6 +1416,9 @@ public class ServiceImportBusinessLogic {
if (originResource.getAttributes() != null && !originResource.getAttributes().isEmpty()) {
instAttributes.put(resourceInstanceId, originResource.getAttributes());
}
+ if (uploadComponentInstanceInfo.getUploadNodeFilterInfo() != null) {
+ instNodeFilter.put(resourceInstanceId, uploadComponentInstanceInfo.getUploadNodeFilterInfo());
+ }
if (originResource.getResourceType() != ResourceTypeEnum.VF) {
ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, component, originResource,
currentCompInstance, instProperties, allDataTypes);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
index 196fc679ad..d9f5e1a5b9 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
@@ -23,6 +23,7 @@ import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
import fj.data.Either;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
@@ -49,6 +50,7 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
@@ -87,6 +89,7 @@ import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.UploadCapInfo;
import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
import org.openecomp.sdc.be.model.UploadInfo;
+import org.openecomp.sdc.be.model.UploadNodeFilterInfo;
import org.openecomp.sdc.be.model.UploadPropInfo;
import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.UploadResourceInfo;
@@ -147,6 +150,8 @@ public class ServiceImportParseLogic {
private IInterfaceLifecycleOperation interfaceTypeOperation = null;
@Autowired
private ICapabilityTypeOperation capabilityTypeOperation = null;
+ @Autowired
+ private ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic;
public Either<Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandle(
Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo, Service oldResource) {
@@ -2127,6 +2132,17 @@ public class ServiceImportParseLogic {
}
}
+ public void associateCINodeFilterToComponent(String yamlName, Service service, Map<String, UploadNodeFilterInfo> nodeFilter) {
+ log.trace("************* Going to associate all resource node filters {}", yamlName);
+ if (MapUtils.isNotEmpty(nodeFilter)) {
+ StorageOperationStatus status = componentNodeFilterBusinessLogic.associateNodeFilterToComponentInstance(service.getUniqueId(), nodeFilter);
+ if (status != StorageOperationStatus.OK) {
+ throw new ComponentException(
+ componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), yamlName));
+ }
+ }
+ }
+
public void associateComponentInstancePropertiesToComponent(String yamlName, Service service,
Map<String, List<ComponentInstanceProperty>> instProperties) {
Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addPropToInst = toscaOperationFacade
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java
index a5ff6d9ce4..cd708599f5 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java
@@ -21,6 +21,7 @@ package org.openecomp.sdc.be.components.impl;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -41,6 +42,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -50,6 +52,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.components.impl.exceptions.BusinessLogicException;
+import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.impl.utils.NodeFilterConstraintAction;
import org.openecomp.sdc.be.components.validation.NodeFilterValidator;
import org.openecomp.sdc.be.components.validation.UserValidations;
@@ -71,6 +74,8 @@ import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.UploadNodeFilterInfo;
+import org.openecomp.sdc.be.model.UploadNodeFilterPropertyInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
@@ -540,6 +545,52 @@ public class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock
}
@Test
+ public void testAssociateNodeFilterToComponentInstance() {
+ CINodeFilterDataDefinition ciNodeFilterDataDefinition = new CINodeFilterDataDefinition();
+
+ UploadNodeFilterInfo filter = new UploadNodeFilterInfo();
+ UploadNodeFilterPropertyInfo propertyDataDefinition = new UploadNodeFilterPropertyInfo();
+ propertyDataDefinition.setName("order");
+ propertyDataDefinition.setValues(Collections.singletonList("order: {equal: 2"));
+ List<UploadNodeFilterPropertyInfo> propertyList = new LinkedList<>();
+ propertyList.add(propertyDataDefinition);
+ filter.setProperties(Collections.singletonList(propertyDataDefinition));
+
+ Map<String, UploadNodeFilterInfo> nodeFilterMap = new HashMap<>();
+ nodeFilterMap.put(componentInstanceId, filter);
+
+ when(nodeFilterOperation.createNodeFilter(componentId, componentInstanceId)).thenReturn(Either.left(ciNodeFilterDataDefinition));
+ when(nodeFilterOperation.addNewProperty(anyString(), anyString(), any(CINodeFilterDataDefinition.class),
+ any(RequirementNodeFilterPropertyDataDefinition.class))).thenReturn(Either.left(ciNodeFilterDataDefinition));
+
+ StorageOperationStatus status = componentNodeFilterBusinessLogic.associateNodeFilterToComponentInstance(componentId, nodeFilterMap);
+ assertEquals(StorageOperationStatus.OK, status);
+ }
+
+ @Test
+ public void testAssociateNodeFilterToComponentInstanceFail() {
+ CINodeFilterDataDefinition ciNodeFilterDataDefinition = new CINodeFilterDataDefinition();
+
+ UploadNodeFilterInfo filter = new UploadNodeFilterInfo();
+ UploadNodeFilterPropertyInfo propertyDataDefinition = new UploadNodeFilterPropertyInfo();
+ propertyDataDefinition.setName("order");
+ propertyDataDefinition.setValues(Collections.singletonList("order: {equal: 2"));
+ List<UploadNodeFilterPropertyInfo> propertyList = new LinkedList<>();
+ propertyList.add(propertyDataDefinition);
+ filter.setProperties(Collections.singletonList(propertyDataDefinition));
+
+ Map<String, UploadNodeFilterInfo> nodeFilterMap = new HashMap<>();
+ nodeFilterMap.put(componentInstanceId, filter);
+
+ when(nodeFilterOperation.createNodeFilter(componentId, componentInstanceId)).thenReturn(Either.left(ciNodeFilterDataDefinition));
+ when(nodeFilterOperation.addNewProperty(anyString(), anyString(), any(CINodeFilterDataDefinition.class),
+ any(RequirementNodeFilterPropertyDataDefinition.class))).thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
+
+ Assertions.assertThrows(ComponentException.class, () -> componentNodeFilterBusinessLogic.associateNodeFilterToComponentInstance(componentId,
+ nodeFilterMap));
+ }
+
+ @Test
public void validateUserTes() {
final String USER_ID = "jh0003";
final User user = new User();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
index ee52431a4f..822fad5f5f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
@@ -61,6 +61,7 @@ import org.openecomp.sdc.be.components.impl.utils.CreateServiceFromYamlParameter
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -93,6 +94,7 @@ import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
+import org.openecomp.sdc.be.model.UploadNodeFilterInfo;
import org.openecomp.sdc.be.model.UploadPropInfo;
import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.UploadResourceInfo;
@@ -848,6 +850,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
+ Map<String, UploadNodeFilterInfo> instNodeFilter = new HashMap<>();
Map<String, Resource> originCompMap = new HashMap<>();
originCompMap.put("componentUid", originResource);
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -857,7 +860,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Assertions.assertNotNull(yamlName);
sIB1.processComponentInstance(yamlName, resource, componentInstancesList, allDataTypes.left().value(), instProperties,
instCapabilties, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes,
- originCompMap, instInputs, uploadComponentInstanceInfo);
+ originCompMap, instInputs, instNodeFilter, uploadComponentInstanceInfo);
}
@Test
@@ -874,6 +877,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
Map<String, Resource> originCompMap = new HashMap<>();
+ Map<String, UploadNodeFilterInfo> instNodeFilter = new HashMap<>();
originCompMap.put("componentUid", originResource);
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
@@ -882,7 +886,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Assertions.assertThrows(ComponentException.class, () -> sIB1.processComponentInstance(yamlName,
resource, componentInstancesList, null, instProperties, instCapabilties,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap,
- instInputs, uploadComponentInstanceInfo));
+ instInputs, instNodeFilter, uploadComponentInstanceInfo));
}
@Test
@@ -1194,6 +1198,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
+ Map<String, UploadNodeFilterInfo> instNodeFilter = new HashMap<>();
Map<String, Resource> originCompMap = new HashMap<>();
originCompMap.put("componentUid", originResource);
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -1203,7 +1208,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
sIB1.processComponentInstance(yamlName, service, componentInstancesList, allDataTypes.left().value(),
instProperties, instCapabilties, instRequirements, instDeploymentArtifacts,
- instArtifacts, instAttributes, originCompMap, instInputs,
+ instArtifacts, instAttributes, originCompMap, instInputs, instNodeFilter,
uploadComponentInstanceInfo);
}
@@ -1220,6 +1225,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
+ Map<String, UploadNodeFilterInfo> instNodeFilter = new HashMap<>();
Map<String, Resource> originCompMap = new HashMap<>();
originCompMap.put("componentUid", originResource);
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -1229,7 +1235,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Assertions.assertThrows(ComponentException.class, () -> sIB1.processComponentInstance(yamlName,
service, componentInstancesList, null, instProperties, instCapabilties,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap,
- instInputs, uploadComponentInstanceInfo));
+ instInputs, instNodeFilter, uploadComponentInstanceInfo));
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
index ccc7139fa6..6d9467dd80 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
@@ -24,6 +24,9 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import fj.data.Either;
@@ -45,7 +48,6 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.ElementOperationMock;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
@@ -55,10 +57,13 @@ import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterPropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
@@ -84,6 +89,8 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.UploadCapInfo;
import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
+import org.openecomp.sdc.be.model.UploadNodeFilterInfo;
+import org.openecomp.sdc.be.model.UploadNodeFilterPropertyInfo;
import org.openecomp.sdc.be.model.UploadPropInfo;
import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.User;
@@ -110,14 +117,15 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
private static final String RESOURCE_SUBCATEGORY = "Router";
- private final ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
- private final ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
- private final ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class);
- private final ICapabilityTypeOperation capabilityTypeOperation = Mockito.mock(ICapabilityTypeOperation.class);
- private final IElementOperation elementDao = Mockito.mock(IElementOperation.class);
- private final IInterfaceLifecycleOperation interfaceTypeOperation = Mockito.mock(IInterfaceLifecycleOperation.class);
- private final InputsBusinessLogic inputsBusinessLogic = Mockito.mock(InputsBusinessLogic.class);
- private final LifecycleBusinessLogic lifecycleBusinessLogic = Mockito.mock(LifecycleBusinessLogic.class);
+ private final ComponentsUtils componentsUtils = new ComponentsUtils(mock(AuditingManager.class));
+ private final ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
+ private final ServiceBusinessLogic serviceBusinessLogic = mock(ServiceBusinessLogic.class);
+ private final ICapabilityTypeOperation capabilityTypeOperation = mock(ICapabilityTypeOperation.class);
+ private final IElementOperation elementDao = mock(IElementOperation.class);
+ private final IInterfaceLifecycleOperation interfaceTypeOperation = mock(IInterfaceLifecycleOperation.class);
+ private final InputsBusinessLogic inputsBusinessLogic = mock(InputsBusinessLogic.class);
+ private final LifecycleBusinessLogic lifecycleBusinessLogic = mock(LifecycleBusinessLogic.class);
+ private final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic = mock(ComponentNodeFilterBusinessLogic.class);
private ResponseFormatManager responseManager = null;
private User user = null;
@@ -151,6 +159,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
testSubject.setInterfaceTypeOperation(interfaceTypeOperation);
testSubject.setInputsBusinessLogic(inputsBusinessLogic);
testSubject.setLifecycleBusinessLogic(lifecycleBusinessLogic);
+ testSubject.setComponentNodeFilterBusinessLogic(componentNodeFilterBusinessLogic);
}
@Test
@@ -1154,6 +1163,34 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
}
@Test
+ public void testAssociateCINodeFilterToComponent() {
+ String yamlName = "yamlName.yml";
+ Service service = createServiceObject(true);
+ Map<String, UploadNodeFilterInfo> nodeFilterMap = new HashMap<>();
+ nodeFilterMap.put("componentInstanceID", new UploadNodeFilterInfo());
+
+ when(componentNodeFilterBusinessLogic.associateNodeFilterToComponentInstance(service.getUniqueId(), nodeFilterMap))
+ .thenReturn(StorageOperationStatus.OK);
+
+ testSubject.associateCINodeFilterToComponent(yamlName, service, nodeFilterMap);
+ verify(componentNodeFilterBusinessLogic, times(1)).associateNodeFilterToComponentInstance(service.getUniqueId(),
+ nodeFilterMap);
+ }
+
+ @Test
+ public void testAssociateCINodeFilterToComponentFail() {
+ String yamlName = "yamlName.yml";
+ Service service = createServiceObject(true);
+ Map<String, UploadNodeFilterInfo> nodeFilterMap = new HashMap<>();
+ nodeFilterMap.put("componentInstanceID", new UploadNodeFilterInfo());
+
+ when(componentNodeFilterBusinessLogic.associateNodeFilterToComponentInstance(service.getUniqueId(), nodeFilterMap))
+ .thenReturn(StorageOperationStatus.NOT_FOUND);
+
+ Assertions.assertThrows(ComponentException.class, () -> testSubject.associateCINodeFilterToComponent(yamlName, service, nodeFilterMap));
+ }
+
+ @Test
void testCreateServiceTransaction() {
Service service = createServiceObject(true);
List<ComponentInstance> list = new ArrayList<>();