Fix bug
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / tosca / ToscaExportHandlerTest.java
index 6a3810f..4f26713 100644 (file)
@@ -22,6 +22,7 @@
 
 package org.openecomp.sdc.be.tosca;
 
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -49,7 +50,6 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 import java.util.stream.Collectors;
 import mockit.Deencapsulation;
 import org.apache.commons.collections.MapUtils;
@@ -63,12 +63,15 @@ import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyFilterConstraintDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyFilterDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
 import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
 import org.openecomp.sdc.be.exception.ToscaExportException;
@@ -87,7 +90,9 @@ import org.openecomp.sdc.be.model.GroupDefinition;
 import org.openecomp.sdc.be.model.GroupInstance;
 import org.openecomp.sdc.be.model.InputDefinition;
 import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.OutputDefinition;
 import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RelationshipImpl;
 import org.openecomp.sdc.be.model.RelationshipInfo;
 import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
 import org.openecomp.sdc.be.model.RequirementDefinition;
@@ -117,10 +122,13 @@ class ToscaExportHandlerTest extends BaseConfDependent {
     private static final String COMPONENT_PROPERTY_NAME = "prop1";
     private static final String COMPONENT_PROPERTY_TYPE = "string";
     private static final String COMPONENT_INPUT_NAME = "input1";
+    private static final String COMPONENT_OUTPUT_NAME = "output1";
     private static final String COMPONENT_INPUT_TYPE = "integer";
+    private static final String COMPONENT_OUTPUT_TYPE = "integer";
     private static final String RESOURCE_NAME = "resource";
     private static final String TOSCA_VERSION = "tosca_simple_yaml_1_1";
-    private static final Map<String, DataTypeDefinition> DATA_TYPES = new HashMap<>();
+    private static final String LOCAL_INTERFACE_TYPE = "Local";
+    private static final String UNIQUE_ID = "1L";
 
     @InjectMocks
     private ToscaExportHandler testSubject;
@@ -173,11 +181,12 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         MockitoAnnotations.openMocks(this);
         doReturn(new ToscaProperty()).when(propertyConvertor).convertProperty(any(), any(), eq(PROPERTY));
         doReturn(new HashMap<String, Object>()).when(interfacesOperationsConverter)
-            .getInterfacesMap(any(), isNull(), anyMap(), anyMap(), anyBoolean(), anyBoolean());
+                .getInterfacesMap(any(), isNull(), anyMap(), anyMap(), anyBoolean());
     }
 
     private Resource getNewResource() {
         Resource resource = new Resource();
+        resource.setUniqueId("resourceUniqueId");
         List<CategoryDefinition> categories = new ArrayList<>();
         CategoryDefinition category = new CategoryDefinition();
         List<SubCategoryDefinition> subcategories = new ArrayList<>();
@@ -187,13 +196,13 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         dataType.setName("dataTypeName");
         dataType.setDerivedFromName("tosca.datatypes.Root");
         PropertyDataDefinition propData = new PropertyDataDefinitionBuilder()
-            .setName("property")
-            .setType("type")
-            .build();
+                .setName("property")
+                .setType("type")
+                .build();
         List<PropertyDataDefinition> propDataList = Arrays.asList(propData);
         dataType.setPropertiesData(propDataList);
         List<PropertyDefinition> propList = propDataList.stream().map(PropertyDefinition::new)
-            .collect(Collectors.toList());
+                .collect(Collectors.toList());
         dataType.setProperties(propList);
         dataTypes.add(dataType);
 
@@ -203,6 +212,13 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         category.setSubcategories(subcategories);
         categories.add(category);
 
+        final List<PropertyDefinition> properties = new ArrayList<>();
+        properties.add(new PropertyDefinition());
+        resource.setProperties(properties);
+        Map<String, InterfaceDefinition> proxyInterfaces = new HashMap<>();
+        proxyInterfaces.put("Local", new InterfaceDefinition("Local", "desc", new HashMap<>()));
+        resource.setInterfaces(proxyInterfaces);
+
         resource.setCategories(categories);
         resource.setVersion("version");
         resource.setVendorName("vendorName");
@@ -242,9 +258,9 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
-            any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+                any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
         when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
-            .thenReturn(Either.left(Collections.emptyMap()));
+                .thenReturn(Either.left(Collections.emptyMap()));
 
         // default test when component is Resource
         result = testSubject.exportComponent(component);
@@ -252,7 +268,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         component = getNewService();
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Service.class),
-            any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+                any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
 
         // default test when component is Service
@@ -269,20 +285,30 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
         when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
-            .thenReturn(Either.left(Collections.emptyMap()));
+                .thenReturn(Either.left(Collections.emptyMap()));
         // default test when convertInterfaceNodeType is right
         result = testSubject.exportComponentInterface(component, false);
         assertNotNull(result);
 
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
-            any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+                any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
 
         // default test when convertInterfaceNodeType is left
         result = testSubject.exportComponentInterface(component, false);
         assertNotNull(result);
     }
 
+    @Test
+    void testExportDataType() {
+        DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
+        dataTypeDefinition.setUniqueId("uniqueId");
+        Either<ToscaRepresentation, ToscaError> result;
+        when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
+        result = testSubject.exportDataType(dataTypeDefinition);
+        assertNotNull(result);
+    }
+
     @Test
     void testConvertInterfaceNodeTypeProperties() {
 
@@ -301,37 +327,29 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         component.setToscaResourceName(RESOURCE_NAME);
 
         when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
-            .thenReturn(Either.left(Collections.emptyMap()));
+                .thenReturn(Either.left(Collections.emptyMap()));
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
         // when convertRequirements is called, make it return the same value as 3rd (index=2) argument.
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
-            any(ToscaNodeType.class))).thenAnswer(i -> Either.left(i.getArgument(2)));
+                any(ToscaNodeType.class))).thenAnswer(i -> Either.left(i.getArgument(2)));
 
-        Either<ToscaTemplate, ToscaError> result = (Either<ToscaTemplate, ToscaError>) Deencapsulation
-            .invoke(testSubject, "convertInterfaceNodeType", new HashMap<String, Component>(), component,
+        final var result = testSubject.convertInterfaceNodeType(new HashMap<String, Component>(), component,
                 new ToscaTemplate(TOSCA_VERSION), new HashMap<String, ToscaNodeType>(), false);
         assertNotNull(result);
         assertTrue(result.isLeft());
         Map<String, ToscaNodeType> nodeTypeMap = result.left().value().getNode_types();
-        assertEquals(1,nodeTypeMap.size());
+        assertNotNull(nodeTypeMap);
+        assertEquals(1, nodeTypeMap.size());
         ToscaNodeType toscaNodeType = nodeTypeMap.values().iterator().next();
+        assertNotNull(toscaNodeType);
         Map<String, ToscaProperty> propertyMap = toscaNodeType.getProperties();
         // Check if inputs and properties in component are merged properly
-        assertEquals(2, propertyMap.size());
-        assertTrue(propertyMap.containsKey(COMPONENT_INPUT_NAME));
+        assertNotNull(propertyMap);
+        assertEquals(1, propertyMap.size());
+        assertFalse(propertyMap.containsKey(COMPONENT_INPUT_NAME));
         assertTrue(propertyMap.containsKey(COMPONENT_PROPERTY_NAME));
     }
 
-    @Test
-    void testCreateToscaRepresentation() {
-        ToscaTemplate toscaTemplate = new ToscaTemplate("");
-        ToscaRepresentation result;
-
-        // default test
-        result = testSubject.createToscaRepresentation(toscaTemplate);
-        assertNotNull(result);
-    }
-
     @Test
     void testGetDependencies() {
 
@@ -411,7 +429,6 @@ class ToscaExportHandlerTest extends BaseConfDependent {
     void testConvertToscaTemplateWhenComponentContainsGroup() throws ToscaConversionException {
         Component component = getNewResource();
         ToscaTemplate toscaNode = new ToscaTemplate("");
-        Either<ToscaTemplate, ToscaError> result;
         component.setComponentInstances(new ArrayList<>());
 
         List<GroupDefinition> groups = new ArrayList<>();
@@ -423,15 +440,25 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         groups.add(group);
         component.setGroups(groups);
 
+        final var input = new InputDefinition();
+        input.setName(COMPONENT_INPUT_NAME);
+        input.setType(COMPONENT_INPUT_TYPE);
+        component.setInputs(Collections.singletonList(input));
+
+        final var output = new OutputDefinition();
+        output.setName(COMPONENT_OUTPUT_NAME);
+        output.setType(COMPONENT_OUTPUT_TYPE);
+        component.setOutputs(Collections.singletonList(output));
+
         Map<String, String[]> substitutionMappingMap = new HashMap<>();
         String[] array = {"value1", "value2"};
         substitutionMappingMap.put("key", array);
 
         when(capabilityRequirementConverter.convertSubstitutionMappingCapabilities(anyMap(),
-            any(Component.class))).thenReturn(Either.left(substitutionMappingMap));
+                any(Component.class))).thenReturn(Either.left(substitutionMappingMap));
 
         when(capabilityRequirementConverter.convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
-            .thenReturn(Either.left(Collections.emptyMap()));
+                .thenReturn(Either.left(Collections.emptyMap()));
 
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
 
@@ -444,7 +471,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         doReturn(map).when(outputConverter).convert(any(), any());
 
         // test component contains group
-        result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
+        final var result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
         assertNotNull(result);
     }
 
@@ -469,11 +496,11 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         substitutionMappingMap.put("key", array);
 
         when(capabilityRequirementConverter.convertSubstitutionMappingCapabilities(anyMap(), any(Component.class)))
-            .thenReturn(Either.left(substitutionMappingMap));
+                .thenReturn(Either.left(substitutionMappingMap));
 
         when(capabilityRequirementConverter
-            .convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
-            .thenReturn(Either.left(Collections.emptyMap()));
+                .convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
+                .thenReturn(Either.left(Collections.emptyMap()));
 
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
 
@@ -520,7 +547,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         component.setToscaArtifacts(toscaArtifacts);
 
         when(toscaOperationFacade.getToscaFullElement(any(String.class)))
-            .thenReturn(Either.left(component));
+                .thenReturn(Either.left(component));
 
         Resource baseType = getNewResource();
         Map<String, ArtifactDefinition> baseTypeToscaArtifacts = new HashMap<>();
@@ -584,10 +611,10 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST));
         when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
-            .thenReturn(Either.left(Collections.emptyMap()));
+                .thenReturn(Either.left(Collections.emptyMap()));
         // default test
         result = Deencapsulation
-            .invoke(testSubject, "convertNodeType", new HashMap<>(), component, toscaNode, nodeTypes);
+                .invoke(testSubject, "convertNodeType", new HashMap<>(), component, toscaNode, nodeTypes);
         assertNotNull(result);
     }
 
@@ -603,14 +630,14 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
         when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
-            .thenReturn(Either.left(Collections.emptyMap()));
+                .thenReturn(Either.left(Collections.emptyMap()));
 
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
-            any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+                any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
 
         // default test
         result = Deencapsulation.invoke(testSubject, "convertInterfaceNodeType", new HashMap<>(), component, toscaNode
-            , nodeTypes, false);
+                , nodeTypes, false);
         assertNotNull(result);
     }
 
@@ -624,28 +651,28 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         Either<ToscaTemplate, ToscaError> result;
 
         when(
-            capabilityRequirementConverter
-                .convertCapabilities(anyMap(), any(Resource.class), anyMap()))
-            .thenReturn(new HashMap<>());
+                capabilityRequirementConverter
+                        .convertCapabilities(anyMap(), any(Resource.class), anyMap()))
+                .thenReturn(new HashMap<>());
 
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
-            any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+                any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
 
         // default test
         result = Deencapsulation
-            .invoke(testSubject, "convertReqCapAndTypeName", new HashMap<>(), component, toscaNode, nodeTypes,
-                toscaNodeType, dataTypes);
+                .invoke(testSubject, "convertReqCapAndTypeName", new HashMap<>(), component, toscaNode, nodeTypes,
+                        toscaNodeType, dataTypes);
         assertNotNull(result);
 
         component = new Service();
 
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Service.class),
-            any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+                any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
 
         // test when component is service
         result = Deencapsulation
-            .invoke(testSubject, "convertReqCapAndTypeName", new HashMap<>(), component, toscaNode, nodeTypes,
-                toscaNodeType, dataTypes);
+                .invoke(testSubject, "convertReqCapAndTypeName", new HashMap<>(), component, toscaNode, nodeTypes,
+                        toscaNodeType, dataTypes);
         assertNotNull(result);
     }
 
@@ -727,6 +754,127 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         componentInstancesProperties.put("id", list);
         component.setComponentInstancesProperties(componentInstancesProperties);
 
+        when(capabilityRequirementConverter.getOriginComponent(anyMap(), any(ComponentInstance.class))).thenReturn(Either.left(component));
+        when(capabilityRequirementConverter
+                .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
+                .thenReturn(Either.left(new ToscaNodeTemplate()));
+        when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
+        when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
+        when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class), any(ToscaNodeType.class)))
+                .thenReturn(Either.left(new ToscaNodeType()));
+        when(toscaOperationFacade.getToscaFullElement("uid")).thenReturn(Either.left(component));
+        when(toscaOperationFacade.getToscaFullElement("sourceModelUid")).thenReturn(Either.left(component));
+        when(toscaOperationFacade.getLatestByName("serviceProxy", null)).thenReturn(Either.left(new Resource()));
+        when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(getNewResource()));
+
+        final Map<String, String[]> substitutionMappingMap = new HashMap<>();
+        final String[] array = {"value1", "value2"};
+        substitutionMappingMap.put("key", array);
+        when(capabilityRequirementConverter.convertSubstitutionMappingCapabilities(anyMap(), any(Component.class)))
+                .thenReturn(Either.left(substitutionMappingMap));
+
+        when(capabilityRequirementConverter
+                .convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
+                .thenReturn(Either.left(Collections.emptyMap()));
+
+        // default test
+        final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(component);
+        assertNotNull(toscaRepresentationToscaErrorEither);
+
+    }
+
+    @Test
+    void testConvertWithBooleanNodeFilterWhenComponentIsService() {
+        final Component component = getNewService();
+        final List<ComponentInstance> componentInstances = new ArrayList<>();
+        final Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
+        final Map<String, Component> componentCache = new HashMap<>();
+        final Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
+        final Map<String, CINodeFilterDataDefinition> componentInstanceNodeFilters = new HashMap<>();
+        CINodeFilterDataDefinition nodeFilter = new CINodeFilterDataDefinition();
+        PropertyFilterDataDefinition prop = new PropertyFilterDataDefinition();
+        prop.setName("nodeFilterPropBoolean");
+        prop.setType("boolean");
+        PropertyFilterConstraintDataDefinition constr = new PropertyFilterConstraintDataDefinition();
+        constr.setPropertyName(prop.getName());
+        constr.setOperator(ConstraintType.EQUAL);
+        constr.setValue("true");
+        constr.setOriginalType("boolean");
+        prop.setConstraints(List.of(constr));
+        ListDataDefinition<PropertyFilterDataDefinition> lstDataDef = new ListDataDefinition<>();
+        lstDataDef.add(prop);
+        nodeFilter.setProperties(lstDataDef);
+        final List<ComponentInstanceInput> inputs = new ArrayList<>();
+        final ComponentInstanceInput componentInstanceInput = new ComponentInstanceInput();
+        componentInstanceInput.setUniqueId("uuid");
+        inputs.add(componentInstanceInput);
+        componentInstancesInputs.put("uuid", inputs);
+        componentInstanceNodeFilters.put("uuid", nodeFilter);
+        final List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
+        final RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
+        reldef.setFromNode("node");
+        resourceInstancesRelations.add(reldef);
+        component.setComponentInstancesRelations(resourceInstancesRelations);
+
+        final ComponentInstance instance = new ComponentInstance();
+        instance.setNodeFilter(nodeFilter);
+        instance.setUniqueId("id");
+        instance.setComponentUid("uid");
+        instance.setOriginType(OriginTypeEnum.ServiceProxy);
+        final List<GroupInstance> groupInstances = new ArrayList<>();
+        final GroupInstance groupInst = new GroupInstance();
+        final List<String> artifacts = new ArrayList<>();
+        artifacts.add("artifact");
+        groupInst.setArtifacts(artifacts);
+        groupInst.setType("type");
+        groupInstances.add(groupInst);
+        instance.setGroupInstances(groupInstances);
+
+        final List<PropertyDefinition> properties = new ArrayList<>();
+        properties.add(new PropertyDefinition());
+        instance.setProperties(properties);
+
+        instance.setUniqueId("uuid");
+        instance.setDescription("desc");
+        instance.setSourceModelUid("sourceModelUid");
+
+        componentInstances.add(instance);
+
+        component.setComponentInstances(componentInstances);
+        component.setNodeFilterComponents(componentInstanceNodeFilters);
+        component.setComponentInstancesInputs(componentInstancesInputs);
+
+        component.setInvariantUUID("uuid");
+        component.setUUID("uuid");
+        component.setDescription("desc");
+        component.setUniqueId("uid");
+
+        componentCache.put("uid", component);
+
+        final List<ComponentInstanceProperty> componentInstanceProperties = new ArrayList<>();
+        componentInstanceProperties.add(new ComponentInstanceProperty());
+
+        componentInstancesProperties.put("uuid", componentInstanceProperties);
+        component.setComponentInstancesProperties(componentInstancesProperties);
+
+        final Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes = new HashMap<>();
+        final List<ComponentInstanceAttribute> componentInstanceAttributes = new ArrayList<>();
+        final ComponentInstanceAttribute componentInstanceAttribute = new ComponentInstanceAttribute();
+        componentInstanceAttribute.setDefaultValue("def value");
+        componentInstanceAttributes.add(componentInstanceAttribute);
+
+        componentInstancesAttributes.put("uuid", componentInstanceAttributes);
+        component.setComponentInstancesAttributes(componentInstancesAttributes);
+
+        ComponentInstanceProperty cip = new ComponentInstanceProperty();
+        cip.setInstanceUniqueId("id");
+
+        List<ComponentInstanceProperty> list = new ArrayList<>();
+        list.add(cip);
+
+        componentInstancesProperties.put("id", list);
+        component.setComponentInstancesProperties(componentInstancesProperties);
+
         when(capabilityRequirementConverter.getOriginComponent(anyMap(), any(ComponentInstance.class))).thenReturn(Either.left(component));
         when(capabilityRequirementConverter
             .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
@@ -738,7 +886,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         when(toscaOperationFacade.getToscaFullElement("uid")).thenReturn(Either.left(component));
         when(toscaOperationFacade.getToscaFullElement("sourceModelUid")).thenReturn(Either.left(component));
         when(toscaOperationFacade.getLatestByName("serviceProxy", null)).thenReturn(Either.left(new Resource()));
-        when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(new Resource()));
+        when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(getNewResource()));
 
         final Map<String, String[]> substitutionMappingMap = new HashMap<>();
         final String[] array = {"value1", "value2"};
@@ -753,7 +901,6 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         // default test
         final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(component);
         assertNotNull(toscaRepresentationToscaErrorEither);
-
     }
 
     @Test
@@ -853,29 +1000,36 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         when(capabilityRequirementConverter.getOriginComponent(anyMap(), any(ComponentInstance.class))).thenReturn(Either.left(component));
         when(capabilityRequirementConverter
-            .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
-            .thenReturn(Either.left(new ToscaNodeTemplate()));
+                .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
+                .thenReturn(Either.left(new ToscaNodeTemplate()));
         when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class), any(ToscaNodeType.class)))
-            .thenReturn(Either.left(new ToscaNodeType()));
+                .thenReturn(Either.left(new ToscaNodeType()));
         when(toscaOperationFacade.getToscaFullElement("uid")).thenReturn(Either.left(component));
         when(toscaOperationFacade.getToscaFullElement("sourceModelUid")).thenReturn(Either.left(component));
         when(toscaOperationFacade.getLatestByName("serviceProxy", null)).thenReturn(Either.left(new Resource()));
-        when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(new Resource()));
+
+        Resource newResource = getNewResource();
+        InputDefinition input = new InputDefinition();
+        input.setName(COMPONENT_INPUT_NAME);
+        input.setType(COMPONENT_INPUT_TYPE);
+        newResource.setInputs(Collections.singletonList(input));
+
+        when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(newResource));
 
         final Map<String, String[]> substitutionMappingMap = new HashMap<>();
         final String[] array = {"value1", "value2"};
         substitutionMappingMap.put("key", array);
         when(capabilityRequirementConverter.convertSubstitutionMappingCapabilities(anyMap(), any(Component.class)))
-            .thenReturn(Either.left(substitutionMappingMap));
+                .thenReturn(Either.left(substitutionMappingMap));
 
         when(capabilityRequirementConverter
-            .convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
-            .thenReturn(Either.left(Collections.emptyMap()));
+                .convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
+                .thenReturn(Either.left(Collections.emptyMap()));
 
         // default test
-        final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(component);
+        final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(newResource);
         assertNotNull(toscaRepresentationToscaErrorEither);
 
     }
@@ -916,12 +1070,12 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         when(capabilityRequirementConverter.getOriginComponent(anyMap(), any(ComponentInstance.class))).thenReturn(Either.left(component));
         when(capabilityRequirementConverter
-            .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
-            .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
+                .convertComponentInstanceCapabilities(any(ComponentInstance.class), anyMap(), any(ToscaNodeTemplate.class)))
+                .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
         when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
-            any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+                any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
 
         // default test
         final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(component);
@@ -972,7 +1126,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
-            any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+                any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
 
         // default test
         final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(component);
@@ -999,7 +1153,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         reldef.setToNode("node");
         List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
         CapabilityRequirementRelationship relationship = new CapabilityRequirementRelationship();
-        relationship.setRelation(new RelationshipInfo());
+        relationship.setRelation(new RelationshipInfo("requirement", new RelationshipImpl()));
         relationships.add(relationship);
         reldef.setRelationships(relationships);
         resourceInstancesRelations.add(reldef);
@@ -1011,13 +1165,16 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         artifactList.put("assettoscatemplate", artifact);
         component.setArtifacts(artifactList);
         component.setToscaArtifacts(artifactList);
+        component.setRequirements(Collections.singletonMap("mock", Collections.singletonList(new RequirementDefinition())));
 
         ComponentInstance instance = new ComponentInstance();
         instance.setUniqueId("id");
         instance.setComponentUid("id");
         instance.setOriginType(OriginTypeEnum.VF);
+        Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
+        requirements.put("mock1", Collections.singletonList(new RequirementDefinition()));
+        instance.setRequirements(requirements);
         componentInstances.add(instance);
-        component.setComponentInstances(componentInstances);
 
         component.setComponentInstancesInputs(componentInstancesInputs);
         component.setComponentInstances(componentInstances);
@@ -1027,9 +1184,9 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
-            any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+                any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
         when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
-            .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+                .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
         // default test
         final Either<ToscaRepresentation, ToscaError> result = testSubject.exportComponent(component);
@@ -1068,8 +1225,8 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         componentInstances.add(instance);
         container.setComponentInstances(componentInstances);
         when(toscaOperationFacade.getToscaElement(any(String.class),
-            any(ComponentParametersView.class)))
-            .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+                any(ComponentParametersView.class)))
+                .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
         result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
         assertTrue(result.isRight());
     }
@@ -1087,10 +1244,10 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         container.setComponentInstances(componentInstances);
 
         when(toscaOperationFacade.getToscaElement(any(String.class),
-            any(ComponentParametersView.class)))
-            .thenReturn(Either.left(new Resource()));
+                any(ComponentParametersView.class)))
+                .thenReturn(Either.left(new Resource()));
         when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
-            .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+                .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
         result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
         assertTrue(result.isRight());
     }
@@ -1107,16 +1264,15 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         componentInstances.add(instance);
         container.setComponentInstances(componentInstances);
 
-        when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
-            .thenReturn(Either.left(Collections.emptyMap()));
+        when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
 
         Component proxyResource = new Resource();
         Map<String, InterfaceDefinition> proxyInterfaces = new HashMap<>();
         proxyInterfaces.put("Local", new InterfaceDefinition("Local", "desc", new HashMap<>()));
         proxyResource.setInterfaces(proxyInterfaces);
-        when(toscaOperationFacade.getToscaElement(any(String.class),
-            any(ComponentParametersView.class)))
-            .thenReturn(Either.left(proxyResource));
+        when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(proxyResource));
+        when(interfacesOperationsConverter.addInterfaceTypeElement(any(Component.class), anyList()))
+                .thenReturn(Collections.singletonMap(LOCAL_INTERFACE_TYPE, new HashMap<>()));
 
         result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
         assertNotNull(result);
@@ -1138,7 +1294,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         container.setComponentInstances(componentInstances);
 
         when(toscaOperationFacade.getLatestByName("serviceProxy", null))
-            .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+                .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
         // test when getLatestByName return is right
         result = Deencapsulation.invoke(testSubject, "createProxyNodeTypes", componentCache, container);
@@ -1166,10 +1322,10 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         containerService.setComponentInstances(componentInstances);
 
         when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
-            .thenReturn(Either.left(Collections.emptyMap()));
+                .thenReturn(Either.left(Collections.emptyMap()));
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Service.class),
-            any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
+                any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
 
         ToscaTemplate toscaNode = new ToscaTemplate("1_1");
 
@@ -1197,8 +1353,8 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         parameterView.setIgnoreCategories(false);
 
         when(toscaOperationFacade.getToscaElement(any(String.class),
-            any(ComponentParametersView.class)))
-            .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+                any(ComponentParametersView.class)))
+                .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
         when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
 
@@ -1219,7 +1375,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         // default test
         result = Deencapsulation.invoke(testSubject, "createProxyNodeType", componentCache, origComponent,
-            proxyComponent, instance);
+                proxyComponent, instance);
         assertNotNull(result);
     }
 
@@ -1235,7 +1391,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         // default test
         result = Deencapsulation.invoke(testSubject, "convertComponentInstanceRequirements", component,
-            componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
+                componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
         assertNotNull(result);
 
         RequirementCapabilityRelDef reldef = new RequirementCapabilityRelDef();
@@ -1255,7 +1411,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         // test when filteredRElations ins't empty
         result = Deencapsulation.invoke(testSubject, "convertComponentInstanceRequirements", component,
-            componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
+                componentInstance, relations, nodeTypeTemplate, originComponent, componentCache);
         assertNotNull(result);
     }
 
@@ -1276,15 +1432,15 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         final List<ComponentInstance> instancesList = new ArrayList<>();
         instancesList.add(fromInstance);
         String expectedError = String
-            .format("Failed to find a relation from the node %s to the node %s", fromInstance.getName(),
-                relationshipDefinition.getToNode());
-        assertThrows(ToscaExportException.class, () ->
-            Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
-                instancesList, relationshipDefinition, new HashMap<>()), expectedError);
+                .format("Failed to find a relation from the node %s to the node %s", fromInstance.getName(),
+                        relationshipDefinition.getToNode());
+        assertDoesNotThrow(() ->
+                Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
+                        instancesList, relationshipDefinition, new HashMap<>()), expectedError);
 
         try {
             Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
-                instancesList, relationshipDefinition, new HashMap<>());
+                    instancesList, relationshipDefinition, new HashMap<>());
         } catch (Exception e) {
             assertTrue(e instanceof ToscaExportException);
             assertEquals(expectedError, e.getMessage());
@@ -1308,25 +1464,25 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         relationshipDefinition.setToNode(fromInstanceUid);
 
         expectedError = String
-            .format("Failed to find a requirement with uniqueId %s on a component with uniqueId %s",
-                relation.getRequirementUid(), fromOriginComponent.getUniqueId());
+                .format("Failed to find a requirement with uniqueId %s on a component with uniqueId %s",
+                        relation.getRequirementUid(), fromOriginComponent.getUniqueId());
 
         assertThrows(ToscaExportException.class, () ->
-            Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
-                instancesList, relationshipDefinition, new HashMap<>()), expectedError);
+                Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
+                        instancesList, relationshipDefinition, new HashMap<>()), expectedError);
 
         requirementDefinition.setName(requirementName);
 
         when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
-            .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+                .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
 
         expectedError = String.format(
-            "Failed to build substituted name for the requirement %s. "
-                + "Failed to get an origin component with uniqueId %s",
-            requirementName, fromInstance.getActualComponentUid());
+                "Failed to build substituted name for the requirement %s. "
+                        + "Failed to get an origin component with uniqueId %s",
+                requirementName, fromInstance.getActualComponentUid());
         assertThrows(ToscaExportException.class, () -> Deencapsulation
-            .invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
-                relationshipDefinition, new HashMap<>()), expectedError);
+                .invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
+                        relationshipDefinition, new HashMap<>()), expectedError);
 
         final Component toOriginComponent = new Resource();
         final Map<String, List<CapabilityDefinition>> capabilityMap = new HashMap<>();
@@ -1340,7 +1496,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         capabilityMap.put(capabilityName, Collections.singletonList(capabilityDefinition));
         toOriginComponent.setCapabilities(capabilityMap);
         when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
-            .thenReturn(Either.left(toOriginComponent));
+                .thenReturn(Either.left(toOriginComponent));
 
         requirementDefinition.setCapability(capabilityName);
         relation.setCapability("wrong");
@@ -1349,13 +1505,13 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         requirementDefinition.setPath(new ArrayList<>());
 
         expectedError = String
-            .format("Failed to find a capability with name %s on a component with uniqueId %s",
-                relation.getCapability(), fromOriginComponent.getUniqueId());
+                .format("Failed to find a capability with name %s on a component with uniqueId %s",
+                        relation.getCapability(), fromOriginComponent.getUniqueId());
 
         assertThrows(ToscaExportException.class, () -> Deencapsulation
-                .invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
-                    relationshipDefinition, new HashMap<>()),
-            expectedError);
+                        .invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
+                                relationshipDefinition, new HashMap<>()),
+                expectedError);
     }
 
     @Test
@@ -1406,24 +1562,24 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         toOriginComponent.setCapabilities(capabilityMap);
 
         when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
-            .thenReturn(Either.left(toOriginComponent));
+                .thenReturn(Either.left(toOriginComponent));
         final String builtCapabilityName = "builtCapabilityName";
         when(
-            capabilityRequirementConverter
-                .buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq(capabilityName), eq(
-                    capabilityPreviousName), any()))
-            .thenReturn(Either.left(builtCapabilityName));
+                capabilityRequirementConverter
+                        .buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq(capabilityName), eq(
+                                capabilityPreviousName), any()))
+                .thenReturn(Either.left(builtCapabilityName));
 
         final String builtRequirementName = "builtRequirementName";
         when(
-            capabilityRequirementConverter
-                .buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq(requirementName), eq(
-                    requirementPreviousName), any()))
-            .thenReturn(Either.left(builtRequirementName));
+                capabilityRequirementConverter
+                        .buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq(requirementName), eq(
+                                requirementPreviousName), any()))
+                .thenReturn(Either.left(builtRequirementName));
 
         final Map<String, ToscaTemplateRequirement> actualRequirementMap =
-            Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
-                instancesList, relationshipDefinition, componentCache);
+                Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
+                        instancesList, relationshipDefinition, componentCache);
         assertNotNull(actualRequirementMap);
         assertFalse(actualRequirementMap.isEmpty());
         assertTrue(actualRequirementMap.containsKey(builtRequirementName));
@@ -1433,10 +1589,10 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         //to toOriginComponent not found
         when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
-            .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+                .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
 
         assertThrows(ToscaExportException.class, () -> Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent,
-            instancesList, relationshipDefinition, componentCache));
+                instancesList, relationshipDefinition, componentCache));
     }
 
     @Test
@@ -1485,21 +1641,21 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         fromOriginComponent.setCapabilities(capabilities);
 
         when(toscaOperationFacade.getToscaElement(any(String.class),
-            any(ComponentParametersView.class))).thenReturn(Either.left(fromOriginComponent));
+                any(ComponentParametersView.class))).thenReturn(Either.left(fromOriginComponent));
 
         when(
-            capabilityRequirementConverter
-                .buildSubstitutedName(anyMap(), any(Component.class), anyList(), anyString(), anyString(), any()))
-            .thenReturn(Either.right(false));
+                capabilityRequirementConverter
+                        .buildSubstitutedName(anyMap(), any(Component.class), anyList(), anyString(), anyString(), any()))
+                .thenReturn(Either.right(false));
 
         final String expectedErrorMsg =
-            String.format("Failed to build a substituted capability name for the capability "
-                    + "with name %s on a component with uniqueId %s",
-                cap.getRequirement(), fromOriginComponent.getUniqueId());
+                String.format("Failed to build a substituted capability name for the capability "
+                                + "with name %s on a component with uniqueId %s",
+                        cap.getRequirement(), fromOriginComponent.getUniqueId());
 
         assertThrows(ToscaExportException.class, () ->
-            Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
-                rel, componentCache), expectedErrorMsg);
+                Deencapsulation.invoke(testSubject, "buildRequirement", fromInstance, fromOriginComponent, instancesList,
+                        rel, componentCache), expectedErrorMsg);
     }
 
     @Test
@@ -1521,19 +1677,19 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         reqAndRelationshipPair.setRequirement("req");
 
         when(
-            capabilityRequirementConverter
-                .buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq("cap"), anyString(), any()))
-            .thenReturn(Either.left("buildCapNameRes"));
+                capabilityRequirementConverter
+                        .buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq("cap"), anyString(), any()))
+                .thenReturn(Either.left("buildCapNameRes"));
 
         when(
-            capabilityRequirementConverter
-                .buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("req"), anyString(), any()))
-            .thenReturn(Either.left("buildReqNameRes"));
+                capabilityRequirementConverter
+                        .buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("req"), anyString(), any()))
+                .thenReturn(Either.left("buildReqNameRes"));
 
         // default test
         final Map<String, ToscaTemplateRequirement> requirementMap =
-            Deencapsulation.invoke(testSubject, "buildRequirement", fromOriginComponent, toOriginComponent,
-                capability, requirement, capabilityRequirementRelationship, toInstance, componentCache);
+                Deencapsulation.invoke(testSubject, "buildRequirement", fromOriginComponent, toOriginComponent,
+                        capability, requirement, capabilityRequirementRelationship, toInstance, componentCache);
         assertNotNull(requirementMap);
         assertFalse(requirementMap.isEmpty());
         assertTrue(requirementMap.containsKey("buildReqNameRes"));
@@ -1560,13 +1716,13 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         final String builtCapabilityOrRequirementName = "builtCapabilityOrRequirementName";
         when(capabilityRequirementConverter.buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("cap"), any(), any()))
-            .thenReturn(Either.left(builtCapabilityOrRequirementName));
+                .thenReturn(Either.left(builtCapabilityOrRequirementName));
         when(capabilityRequirementConverter.buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq("req"), any(), any()))
-        .thenReturn(Either.left(builtCapabilityOrRequirementName));
+                .thenReturn(Either.left(builtCapabilityOrRequirementName));
 
         final Map<String, ToscaTemplateRequirement> requirementMap = Deencapsulation
-            .invoke(testSubject, "buildRequirement", fromOriginComponent, toOriginComponent, capability, requirement,
-                capabilityRequirementRelationship, toInstance, componentCache);
+                .invoke(testSubject, "buildRequirement", fromOriginComponent, toOriginComponent, capability, requirement,
+                        capabilityRequirementRelationship, toInstance, componentCache);
         assertNotNull(requirementMap);
         assertFalse(requirementMap.isEmpty());
         assertTrue(requirementMap.containsKey(builtCapabilityOrRequirementName));
@@ -1589,7 +1745,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         // test return false
         result = Deencapsulation.invoke(testSubject, "isRequirementBelongToRelation", originComponent,
-            reqAndRelationshipPair, requirement, fromInstanceId);
+                reqAndRelationshipPair, requirement, fromInstanceId);
         assertFalse(result);
     }
 
@@ -1599,12 +1755,14 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         Component originComponent = new Service();
         RelationshipInfo reqAndRelationshipPair = new RelationshipInfo();
         RequirementDefinition requirement = new RequirementDefinition();
+        requirement.setUniqueId(UNIQUE_ID);
+        reqAndRelationshipPair.setRequirementUid(UNIQUE_ID);
         String fromInstanceId = "";
         boolean result;
 
         // default test return true
         result = Deencapsulation.invoke(testSubject, "isRequirementBelongToRelation", originComponent,
-            reqAndRelationshipPair, requirement, fromInstanceId);
+                reqAndRelationshipPair, requirement, fromInstanceId);
         assertTrue(result);
     }
 
@@ -1622,7 +1780,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         // default test
         result = Deencapsulation.invoke(testSubject, "isRequirementBelongToOwner", reqAndRelationshipPair, requirement,
-            fromInstanceId, originComponent);
+                fromInstanceId, originComponent);
         assertFalse(result);
     }
 
@@ -1643,11 +1801,11 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         final Either<Map<String, String[]>, ToscaError> expectedResult = Either.right(ToscaError.NODE_TYPE_CAPABILITY_ERROR);
         when(capabilityRequirementConverter.convertSubstitutionMappingCapabilities(componentCache, component))
-            .thenReturn(expectedResult);
+                .thenReturn(expectedResult);
 
         // default test return isRight
         final Either<Map<String, String[]>, ToscaError> actualResult =
-            Deencapsulation.invoke(testSubject, "convertSubstitutionMappingCapabilities", component, componentCache);
+                Deencapsulation.invoke(testSubject, "convertSubstitutionMappingCapabilities", component, componentCache);
         assertNotNull(actualResult);
         assertEquals(expectedResult, actualResult);
     }
@@ -1664,7 +1822,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
 
         // default test
         result = Deencapsulation
-            .invoke(testSubject, "convertCapabilities", new HashMap<>(), component, nodeType, dataTypes);
+                .invoke(testSubject, "convertCapabilities", new HashMap<>(), component, nodeType, dataTypes);
         assertNotNull(result);
     }
 
@@ -1683,127 +1841,9 @@ class ToscaExportHandlerTest extends BaseConfDependent {
         assertEquals("test_type", result.get("test_art").getType());
     }
 
-    @Test
-    void testGetProxyNodeTypeInterfacesNoInterfaces() {
-        Component service = new Service();
-        Optional<Map<String, Object>> proxyNodeTypeInterfaces =
-            testSubject.getProxyNodeTypeInterfaces(service, DATA_TYPES);
-        assertFalse(proxyNodeTypeInterfaces.isPresent());
-    }
-
-    @Test
-    void testGetProxyNodeTypeInterfaces() {
-        Component service = getTestComponent();
-        Optional<Map<String, Object>> proxyNodeTypeInterfaces =
-            testSubject.getProxyNodeTypeInterfaces(service, DATA_TYPES);
-        assertTrue(proxyNodeTypeInterfaces.isPresent());
-        Map<String, Object> componentInterfaces = proxyNodeTypeInterfaces.get();
-        assertNotNull(componentInterfaces);
-    }
-
-
-    @Test
-    void testGetProxyNodeTypePropertiesComponentNull() {
-        Optional<Map<String, ToscaProperty>> proxyNodeTypeProperties =
-            testSubject.getProxyNodeTypeProperties(null, DATA_TYPES);
-        assertFalse(proxyNodeTypeProperties.isPresent());
-    }
-
-    @Test
-    void testGetProxyNodeTypePropertiesNoProperties() {
-        Component service = new Service();
-        Optional<Map<String, ToscaProperty>> proxyNodeTypeProperties =
-            testSubject.getProxyNodeTypeProperties(service, DATA_TYPES);
-        assertFalse(proxyNodeTypeProperties.isPresent());
-    }
-
-    @Test
-    void testGetProxyNodeTypeProperties() {
-        Component service = getTestComponent();
-        service.setProperties(Arrays.asList(createMockProperty("componentPropStr", "Default String Prop"),
-            createMockProperty("componentPropInt", null)));
-        Optional<Map<String, ToscaProperty>> proxyNodeTypeProperties =
-            testSubject.getProxyNodeTypeProperties(service, DATA_TYPES);
-        assertTrue(proxyNodeTypeProperties.isPresent());
-        Map<String, ToscaProperty> componentProperties = proxyNodeTypeProperties.get();
-        assertNotNull(componentProperties);
-        assertEquals(2, componentProperties.size());
-    }
-
-    @Test
-    void testAddInputsToPropertiesNoInputs() {
-        Component service = getTestComponent();
-        service.setProperties(Arrays.asList(createMockProperty("componentPropStr", "Default String Prop"),
-            createMockProperty("componentPropInt", null)));
-        Optional<Map<String, ToscaProperty>> proxyNodeTypePropertiesResult =
-            testSubject.getProxyNodeTypeProperties(service, DATA_TYPES);
-
-        assertTrue(proxyNodeTypePropertiesResult.isPresent());
-        Map<String, ToscaProperty> proxyNodeTypeProperties = proxyNodeTypePropertiesResult.get();
-        testSubject.addInputsToProperties(DATA_TYPES, null, proxyNodeTypeProperties);
-        assertNotNull(proxyNodeTypeProperties);
-        assertEquals(2, proxyNodeTypeProperties.size());
-        testSubject.addInputsToProperties(DATA_TYPES, new ArrayList<>(), proxyNodeTypeProperties);
-        assertEquals(2, proxyNodeTypeProperties.size());
-    }
-
-    @Test
-    void testAddInputsToPropertiesWithInputs() {
-        Component service = getTestComponent();
-        service.setProperties(Arrays.asList(createMockProperty("componentPropStr", "Default String Prop"),
-            createMockProperty("componentPropInt", null)));
-        service.setInputs(Arrays.asList(createMockInput("componentInputStr1",
-            "Default String Input1"), createMockInput("componentInputStr2", "Default String Input2")));
-        Optional<Map<String, ToscaProperty>> proxyNodeTypePropertiesResult =
-            testSubject.getProxyNodeTypeProperties(service, DATA_TYPES);
-
-        assertTrue(proxyNodeTypePropertiesResult.isPresent());
-        Map<String, ToscaProperty> proxyNodeTypeProperties = proxyNodeTypePropertiesResult.get();
-        testSubject.addInputsToProperties(DATA_TYPES, service.getInputs(), proxyNodeTypeProperties);
-        assertNotNull(proxyNodeTypeProperties);
-        assertEquals(4, proxyNodeTypeProperties.size());
-    }
-
-    @Test
-    void testAddInputsToPropertiesOnlyInputs() {
-        Component service = getTestComponent();
-        service.setInputs(Arrays.asList(createMockInput("componentInputStr1",
-            "Default String Input1"), createMockInput("componentInputStr2", "Default String Input2")));
-        Optional<Map<String, ToscaProperty>> proxyNodeTypePropertiesResult =
-            testSubject.getProxyNodeTypeProperties(service, DATA_TYPES);
-
-        assertTrue(proxyNodeTypePropertiesResult.isPresent());
-        Map<String, ToscaProperty> proxyNodeTypeProperties = proxyNodeTypePropertiesResult.get();
-        testSubject.addInputsToProperties(DATA_TYPES, service.getInputs(), proxyNodeTypeProperties);
-        assertNotNull(proxyNodeTypeProperties);
-        assertEquals(2, proxyNodeTypeProperties.size());
-    }
-
-    @Test
-    void testOperationImplementationInProxyNodeTypeNotPresent() {
-        Component service = getTestComponent();
-        InterfaceDefinition interfaceDefinition =
-            service.getInterfaces().get("normalizedServiceComponentName-interface");
-        interfaceDefinition.setOperations(new HashMap<>());
-        final OperationDataDefinition operation = new OperationDataDefinition();
-        operation.setName("start");
-        operation.setDescription("op description");
-        final ArtifactDataDefinition implementation = new ArtifactDataDefinition();
-        implementation.setArtifactName("createBPMN.bpmn");
-        operation.setImplementation(implementation);
-        interfaceDefinition.getOperations().put(operation.getName(), operation);
-        service.getInterfaces().put("normalizedServiceComponentName-interface", interfaceDefinition);
-        service.setInputs(Arrays.asList(createMockInput("componentInputStr1",
-            "Default String Input1"), createMockInput("componentInputStr2", "Default String Input2")));
-        Optional<Map<String, Object>> proxyNodeTypeInterfaces =
-            testSubject.getProxyNodeTypeInterfaces(service, DATA_TYPES);
-        assertTrue(proxyNodeTypeInterfaces.isPresent());
-        Map<String, Object> componentInterfaces = proxyNodeTypeInterfaces.get();
-        assertNotNull(componentInterfaces);
-    }
-
     private Component getTestComponent() {
         Component component = new Service();
+        component.setUniqueId("serviceUniqueId");
         component.setNormalizedName("normalizedServiceComponentName");
         InterfaceDefinition addedInterface = new InterfaceDefinition();
         addedInterface.setType("com.some.service.or.other.serviceName");