diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
index b689959..e373f5d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
@@ -86,7 +86,7 @@
      * @param component to work on
      * @return the added element
      */
-    public static Map<String, Object> addInterfaceTypeElement(Component component, List<String> allInterfaceTypes) {
+    public Map<String, Object> addInterfaceTypeElement(Component component, List<String> allInterfaceTypes) {
         if (component instanceof Product) {
             return null;
         }
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 91d2bd5..069e4f3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -22,15 +22,15 @@
 import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
 import static org.apache.commons.collections.MapUtils.isNotEmpty;
 import static org.openecomp.sdc.be.components.utils.PropertiesUtils.resolvePropertyValueFromInput;
-import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.addInterfaceTypeElement;
 import static org.openecomp.sdc.tosca.datatypes.ToscaFunctions.GET_ATTRIBUTE;
 import static org.openecomp.sdc.tosca.datatypes.ToscaFunctions.GET_INPUT;
 import static org.openecomp.sdc.tosca.datatypes.ToscaFunctions.GET_PROPERTY;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.JsonParser;
+import com.google.common.primitives.Ints;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
 import com.google.gson.stream.JsonReader;
 import fj.data.Either;
 import java.io.StringReader;
@@ -52,7 +52,6 @@
 import java.util.Set;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
-import com.google.common.primitives.Ints;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.io.FilenameUtils;
@@ -234,7 +233,8 @@
         if (component.getDerivedFromGenericType() != null && !component.getDerivedFromGenericType()
             .startsWith("org.openecomp.resource.abstract.nodes.")) {
             final Either<Component, StorageOperationStatus> baseType = toscaOperationFacade
-                .getByToscaResourceNameAndVersion(component.getDerivedFromGenericType(), component.getDerivedFromGenericVersion(), component.getModel());
+                .getByToscaResourceNameAndVersion(component.getDerivedFromGenericType(), component.getDerivedFromGenericVersion(),
+                    component.getModel());
             if (baseType.isLeft() && baseType.left().value() != null) {
                 addDependencies(imports, dependencies, baseType.left().value());
             } else {
@@ -260,7 +260,7 @@
         return Either.left(toscaRepresentation);
     }
 
-    public ToscaRepresentation createToscaRepresentation(ToscaTemplate toscaTemplate) {
+    private ToscaRepresentation createToscaRepresentation(ToscaTemplate toscaTemplate) {
         CustomRepresenter representer = new CustomRepresenter();
         DumperOptions options = new DumperOptions();
         options.setAllowReadOnlyProperties(false);
@@ -311,11 +311,11 @@
         }
     }
 
-    public List<Map<String, Map<String, String>>> getDefaultToscaImports(final String modelId) {
+    private List<Map<String, Map<String, String>>> getDefaultToscaImports(final String modelId) {
         if (modelId == null) {
             return getDefaultToscaImportConfig();
         }
-        
+
         final List<ToscaImportByModel> allModelImports = modelOperation.findAllModelImports(modelId, true);
         final List<Map<String, Map<String, String>>> importList = new ArrayList<>();
         final Set<Path> addedPathList = new HashSet<>();
@@ -458,17 +458,17 @@
             throw new ToscaExportException("Could not convert substitution mapping requirements", requirements.right().value());
         }
         final Map<String, String[]> requirementMap = requirements.left().value();
-        if (!requirementMap.isEmpty()) {
+        if (MapUtils.isNotEmpty(requirementMap)) {
             substitutionMapping.setRequirements(requirementMap);
         }
 
         final Map<String, String[]> propertyMappingMap = buildSubstitutionMappingPropertyMapping(component);
-        if (!propertyMappingMap.isEmpty()) {
+        if (MapUtils.isNotEmpty(propertyMappingMap)) {
             substitutionMapping.setProperties(propertyMappingMap);
         }
 
         final Map<String, String[]> attributesMappingMap = buildSubstitutionMappingAttributesMapping(component);
-        if (!attributesMappingMap.isEmpty()) {
+        if (MapUtils.isNotEmpty(attributesMappingMap)) {
             substitutionMapping.setAttributes(attributesMappingMap);
         }
 
@@ -782,23 +782,21 @@
         if (lifecycleTypeEither.isLeft()) {
             List<String> allGlobalInterfaceTypes = lifecycleTypeEither.left().value().values().stream().map(InterfaceDataDefinition::getType)
                 .collect(Collectors.toList());
-            toscaNode.setInterface_types(addInterfaceTypeElement(component, allGlobalInterfaceTypes));
+            toscaNode.setInterface_types(interfacesOperationsConverter.addInterfaceTypeElement(component, allGlobalInterfaceTypes));
         }
-        Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(component.getModel());
+        final var dataTypesEither = applicationDataTypeCache.getAll(component.getModel());
         if (dataTypesEither.isRight()) {
             log.debug("Failed to fetch all data types :", dataTypesEither.right().value());
             return Either.right(ToscaError.GENERAL_ERROR);
         }
         Map<String, DataTypeDefinition> dataTypes = dataTypesEither.left().value();
         List<InputDefinition> inputDef = component.getInputs();
-        Map<String, ToscaProperty> mergedProperties = new HashMap<>();
         interfacesOperationsConverter.addInterfaceDefinitionElement(component, toscaNodeType, dataTypes, isAssociatedComponent);
-        addInputsToProperties(dataTypes, inputDef, mergedProperties);
-        final Map<String, ToscaAttribute> toscaAttributeMap;
-        toscaAttributeMap = convertToToscaAttributes(component.getAttributes(), dataTypes);
+        final var toscaAttributeMap = convertToToscaAttributes(component.getAttributes(), dataTypes);
         if (!toscaAttributeMap.isEmpty()) {
             toscaNodeType.setAttributes(toscaAttributeMap);
         }
+        final var mergedProperties = convertInputsToProperties(dataTypes, inputDef, component.getUniqueId());
         if (CollectionUtils.isNotEmpty(component.getProperties())) {
             List<PropertyDefinition> properties = component.getProperties();
             Map<String, ToscaProperty> convertedProperties = properties.stream()
@@ -827,7 +825,8 @@
                         .collect(Collectors.toMap(
                             PropertyDataDefinition::getName,
                             s -> propertyConvertor.convertProperty(dataTypes, s, PropertyType.PROPERTY),
-                            (toscaPropertyTobeValidated, toscaProperty) -> validateToscaProperty(privateDataTypes, toscaPropertyTobeValidated, toscaProperty)
+                            (toscaPropertyTobeValidated, toscaProperty) -> validateToscaProperty(privateDataTypes, toscaPropertyTobeValidated,
+                                toscaProperty)
                         )));
                 }
                 toscaDataTypeMap.put(dataType.getName(), toscaDataType);
@@ -922,16 +921,16 @@
             if (MapUtils.isNotEmpty(componentInstance.getToscaArtifacts())) {
                 nodeTemplate.setArtifacts(convertToNodeTemplateArtifacts(componentInstance.getToscaArtifacts()));
             }
-            if (componentInstance.getMinOccurrences() != null && componentInstance.getMaxOccurrences()!= null){
+            if (componentInstance.getMinOccurrences() != null && componentInstance.getMaxOccurrences() != null) {
                 List<Object> occur = new ArrayList<>();
                 occur.add(parseToIntIfPossible(componentInstance.getMinOccurrences()));
                 occur.add(parseToIntIfPossible(componentInstance.getMaxOccurrences()));
                 nodeTemplate.setOccurrences(occur);
             }
-            if (componentInstance.getInstanceCount() != null){
+            if (componentInstance.getInstanceCount() != null) {
                 ObjectMapper objectMapper = new ObjectMapper();
                 Object obj = convertToToscaObject(componentInstance.getInstanceCount());
-                if(obj != null) {
+                if (obj != null) {
                     Map<String, String> map = objectMapper.convertValue(obj, Map.class);
                     nodeTemplate.setInstance_count(map);
                 }
@@ -1040,7 +1039,7 @@
         return convertNodeTemplatesRes;
     }
 
-    public Object convertToToscaObject(String value) {
+    private Object convertToToscaObject(String value) {
         try {
             ToscaMapValueConverter mapConverterInst = ToscaMapValueConverter.getInstance();
             JsonParser jsonParser = new JsonParser();
@@ -1105,7 +1104,8 @@
         List<ComponentInstanceInput> instanceInputsList = componentInstancesInputs.get(instanceUniqueId);
         if (instanceInputsList != null) {
             instanceInputsList.forEach(input -> {
-                Supplier<String> supplier = () -> input.getValue() != null && !Objects.isNull(input.getValue()) ? input.getValue() : input.getDefaultValue();
+                Supplier<String> supplier = () -> input.getValue() != null && !Objects.isNull(input.getValue()) ? input.getValue()
+                    : input.getDefaultValue();
                 propertyConvertor.convertAndAddValue(dataTypes, props, input, supplier);
             });
         }
@@ -1217,7 +1217,7 @@
                 .map(InterfaceDataDefinition::getType)
                 .collect(Collectors.toList());
             //Add interface types for local interfaces in the original service component for proxy
-            Map<String, Object> localInterfaceTypes = addInterfaceTypeElement(serviceComponent,
+            Map<String, Object> localInterfaceTypes = interfacesOperationsConverter.addInterfaceTypeElement(serviceComponent,
                 allGlobalInterfaceTypes);
             if (MapUtils.isNotEmpty(localInterfaceTypes)) {
                 proxyInterfaceTypes.putAll(localInterfaceTypes);
@@ -1312,7 +1312,8 @@
         String derivedFrom = ((Resource) origComponent).getToscaResourceName();
 
         toscaNodeType.setDerived_from(derivedFrom);
-        Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(origComponent.getModel());
+        Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(
+            origComponent.getModel());
         if (dataTypesEither.isRight()) {
             log.debug("Failed to retrieve all data types {}", dataTypesEither.right().value());
         }
@@ -1359,7 +1360,8 @@
             relations);
         if (isNotEmpty(requirementDefinitionList)) {
             try {
-                final List<Map<String, ToscaTemplateRequirement>> toscaRequirements = buildRequirements(component, componentInstance, requirementDefinitionList, originComponent, componentCache);
+                final List<Map<String, ToscaTemplateRequirement>> toscaRequirements = buildRequirements(component, componentInstance,
+                    requirementDefinitionList, originComponent, componentCache);
                 if (!toscaRequirements.isEmpty()) {
                     nodeTypeTemplate.setRequirements(toscaRequirements);
                 }
@@ -1528,7 +1530,7 @@
                                                             String fromInstanceId) {
         for (List<RequirementDefinition> reqList : reqMap.values()) {
             Optional<RequirementDefinition> reqOpt = reqList.stream().filter(
-                r -> isRequirementBelongToRelation(fromOriginComponent, reqAndRelationshipPair, r, fromInstanceId))
+                    r -> isRequirementBelongToRelation(fromOriginComponent, reqAndRelationshipPair, r, fromInstanceId))
                 .findFirst();
             if (reqOpt.isPresent()) {
                 return reqOpt;
@@ -1751,33 +1753,30 @@
             .collect(Collectors.toMap(outputName -> outputName, outputName -> new String[]{outputName}, (outputName1, outputName2) -> outputName1));
     }
 
-    Optional<Map<String, ToscaProperty>> getProxyNodeTypeProperties(Component proxyComponent, Map<String, DataTypeDefinition> dataTypes) {
+    private Optional<Map<String, ToscaProperty>> getProxyNodeTypeProperties(Component proxyComponent, Map<String, DataTypeDefinition> dataTypes) {
         if (Objects.isNull(proxyComponent)) {
             return Optional.empty();
         }
-        Map<String, ToscaProperty> proxyProperties = new HashMap<>();
-        addInputsToProperties(dataTypes, proxyComponent.getInputs(), proxyProperties);
+        final var proxyProperties = convertInputsToProperties(dataTypes, proxyComponent.getInputs(), proxyComponent.getUniqueId());
         if (CollectionUtils.isNotEmpty(proxyComponent.getProperties())) {
             proxyProperties.putAll(proxyComponent.getProperties().stream()
                 .map(propertyDefinition -> resolvePropertyValueFromInput(propertyDefinition, proxyComponent.getInputs())).collect(Collectors
                     .toMap(PropertyDataDefinition::getName,
-                        property -> propertyConvertor.convertProperty(dataTypes, property, PropertyConvertor.PropertyType.PROPERTY))));
+                        property -> propertyConvertor.convertProperty(dataTypes, property, PropertyType.PROPERTY))));
         }
         return MapUtils.isNotEmpty(proxyProperties) ? Optional.of(proxyProperties) : Optional.empty();
     }
 
-    void addInputsToProperties(Map<String, DataTypeDefinition> dataTypes, List<InputDefinition> componentInputs,
-                               Map<String, ToscaProperty> mergedProperties) {
+    private Map<String, ToscaProperty> convertInputsToProperties(Map<String, DataTypeDefinition> dataTypes, List<InputDefinition> componentInputs,
+                                                             String componentUniqueId) {
         if (CollectionUtils.isEmpty(componentInputs)) {
-            return;
+            return new HashMap<>();
         }
-        for (InputDefinition input : componentInputs) {
-            ToscaProperty property = propertyConvertor.convertProperty(dataTypes, input, PropertyConvertor.PropertyType.INPUT);
-            mergedProperties.put(input.getName(), property);
-        }
+        return componentInputs.stream().filter(input -> componentUniqueId.equals(input.getInstanceUniqueId()))
+            .collect(Collectors.toMap(InputDefinition::getName, i -> propertyConvertor.convertProperty(dataTypes, i, PropertyType.INPUT)));
     }
 
-    Optional<Map<String, Object>> getProxyNodeTypeInterfaces(Component proxyComponent, Map<String, DataTypeDefinition> dataTypes) {
+    private Optional<Map<String, Object>> getProxyNodeTypeInterfaces(Component proxyComponent, Map<String, DataTypeDefinition> dataTypes) {
         if (Objects.isNull(proxyComponent) || MapUtils.isEmpty(proxyComponent.getInterfaces())) {
             return Optional.empty();
         }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java
index e3e4590..caae11b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java
@@ -20,19 +20,15 @@
 package org.openecomp.sdc.be.tosca;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.anEmptyMap;
 import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.SELF;
-import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.addInterfaceTypeElement;
 import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DEFAULT;
 import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DESCRIPTION;
 import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.INPUTS;
@@ -78,7 +74,6 @@
 import org.openecomp.sdc.be.model.tosca.ToscaType;
 import org.openecomp.sdc.be.tosca.model.ToscaInterfaceDefinition;
 import org.openecomp.sdc.be.tosca.model.ToscaNodeType;
-import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
 import org.openecomp.sdc.common.util.YamlToObjectConverter;
 import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
 import org.yaml.snakeyaml.Yaml;
@@ -105,8 +100,7 @@
 
     @BeforeEach
     public void setUpBeforeTest() {
-        interfacesOperationsConverter =
-            new InterfacesOperationsConverter(new PropertyConvertor());
+        interfacesOperationsConverter = new InterfacesOperationsConverter(new PropertyConvertor());
     }
 
     @Test
@@ -122,19 +116,14 @@
         final String interfaceType = "normalizedComponentName-interface";
         component.setInterfaces(new HashMap<>());
         component.getInterfaces().put(interfaceType, addedInterface);
-        final Map<String, Object> interfaceTypeElement =
-            addInterfaceTypeElement(component, new ArrayList<>());
+        final Map<String, Object> interfaceTypeElement = interfacesOperationsConverter.addInterfaceTypeElement(component, new ArrayList<>());
+        assertNotNull(interfaceTypeElement);
+        assertTrue(interfaceTypeElement.containsKey("org.openecomp.interfaces.node.lifecycle.NodeTypeName"));
+        Object o = interfaceTypeElement.get("org.openecomp.interfaces.node.lifecycle.NodeTypeName");
+        assertNotNull(o);
+        assertTrue(o instanceof Map);
+        assertEquals(7, ((Map) o).size());
 
-        ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
-            interfacesOperationsConverter, null);
-        ToscaTemplate template = new ToscaTemplate("test");
-        template.setInterface_types(interfaceTypeElement);
-        final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
-
-        assertTrue(all(
-            containsAll("NodeTypeName"),
-            containsNone("operations")
-        ).apply(new String(toscaRepresentation.getMainYaml())));
     }
 
     @Test
@@ -150,19 +139,14 @@
         final String interfaceType = "normalizedServiceComponentName-interface";
         component.setInterfaces(new HashMap<>());
         component.getInterfaces().put(interfaceType, addedInterface);
-        final Map<String, Object> interfaceTypeElement =
-            addInterfaceTypeElement(component, new ArrayList<>());
+        final Map<String, Object> interfaceTypeElement = interfacesOperationsConverter.addInterfaceTypeElement(component, new ArrayList<>());
+        assertNotNull(interfaceTypeElement);
+        assertTrue(interfaceTypeElement.containsKey("org.openecomp.interfaces.node.lifecycle.NodeTypeName"));
+        Object o = interfaceTypeElement.get("org.openecomp.interfaces.node.lifecycle.NodeTypeName");
+        assertNotNull(o);
+        assertTrue(o instanceof Map);
+        assertEquals(7, ((Map) o).size());
 
-        ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
-            interfacesOperationsConverter, null);
-        ToscaTemplate template = new ToscaTemplate("testService");
-        template.setInterface_types(interfaceTypeElement);
-        final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
-
-        assertTrue(all(
-            containsAll("NodeTypeName"),
-            containsNone("operations")
-        ).apply(new String(toscaRepresentation.getMainYaml())));
     }
 
     @Test
@@ -178,22 +162,15 @@
         component.getInterfaces().put(interfaceType, addedInterface);
         ToscaNodeType nodeType = new ToscaNodeType();
         interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, dataTypes, false);
+        Map<String, Object> interfaces = nodeType.getInterfaces();
+        assertNotNull(interfaces);
+        assertEquals(1, interfaces.size());
+        assertTrue(interfaces.containsKey("resourceName"));
+        Object resourceName = interfaces.get("resourceName");
+        assertNotNull(resourceName);
+        assertTrue(resourceName instanceof Map);
+        assertEquals(4, ((Map) resourceName).size());
 
-        ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
-            interfacesOperationsConverter, null);
-        ToscaTemplate template = new ToscaTemplate(NODE_TYPE_NAME);
-        Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
-        nodeTypes.put(NODE_TYPE_NAME, nodeType);
-        template.setNode_types(nodeTypes);
-        final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
-
-        String mainYaml = new String(toscaRepresentation.getMainYaml());
-        assertTrue(all(
-            containsAll("resourceName:", "inputs:", "has description", MAPPED_PROPERTY_NAME, "com.some.resource.or.other.resourceName"),
-            containsNone("operations", "defaultp")
-        ).apply(mainYaml));
-
-        validateOperationInputs(mainYaml, 2, null);
     }
 
     @Test
@@ -208,19 +185,15 @@
         component.getInterfaces().put(interfaceType, addedInterface);
         ToscaNodeType nodeType = new ToscaNodeType();
         interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, dataTypes, false);
+        Map<String, Object> interfaces = nodeType.getInterfaces();
+        assertNotNull(interfaces);
+        assertEquals(1, interfaces.size());
+        assertTrue(interfaces.containsKey("serviceName"));
+        Object resourceName = interfaces.get("serviceName");
+        assertNotNull(resourceName);
+        assertTrue(resourceName instanceof Map);
+        assertEquals(4, ((Map) resourceName).size());
 
-        ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null, null, null);
-        ToscaTemplate template = new ToscaTemplate("testService");
-        Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
-        nodeTypes.put(NODE_TYPE_NAME, nodeType);
-        template.setNode_types(nodeTypes);
-        final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
-        String mainYaml = new String(toscaRepresentation.getMainYaml());
-        assertTrue(all(
-            containsAll("serviceName", "inputs:", "has description", MAPPED_PROPERTY_NAME, "com.some.service.or.other.serviceName"),
-            containsNone("operations", "defaultp")
-        ).apply(mainYaml));
-        validateOperationInputs(mainYaml, 2, null);
     }
 
 
@@ -235,23 +208,15 @@
         final String interfaceType = "normalizedComponentName-interface";
         component.setInterfaces(new HashMap<>());
         component.getInterfaces().put(interfaceType, addedInterface);
-        Map<String, Object> interfacesMap = interfacesOperationsConverter
-            .getInterfacesMap(component, null, component.getInterfaces(), null, false, true);
-        ToscaNodeType nodeType = new ToscaNodeType();
-        nodeType.setInterfaces(interfacesMap);
-        ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null, null, null);
-        ToscaTemplate template = new ToscaTemplate(NODE_TYPE_NAME);
-        Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
-        nodeTypes.put(NODE_TYPE_NAME, nodeType);
-        template.setNode_types(nodeTypes);
-        final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
+        final var interfacesMap = interfacesOperationsConverter.getInterfacesMap(component, null, component.getInterfaces(), null, false, true);
+        assertNotNull(interfacesMap);
+        assertEquals(1, interfacesMap.size());
+        assertTrue(interfacesMap.containsKey("resourceName"));
+        Object resourceName = interfacesMap.get("resourceName");
+        assertNotNull(resourceName);
+        assertTrue(resourceName instanceof Map);
+        assertEquals(4, ((Map) resourceName).size());
 
-        String mainYaml = new String(toscaRepresentation.getMainYaml());
-        assertTrue(all(
-            containsAll("resourceName:", "inputs:", "has description", MAPPED_PROPERTY_NAME, "com.some.resource.or.other.resourceName"),
-            containsNone("operations", "defaultp")
-        ).apply(mainYaml));
-        validateServiceProxyOperationInputs(mainYaml);
     }
 
     @Test
@@ -266,19 +231,15 @@
         component.getInterfaces().put(interfaceType, addedInterface);
         ToscaNodeType nodeType = new ToscaNodeType();
         interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, null, false);
+        Map<String, Object> interfaces = nodeType.getInterfaces();
+        assertNotNull(interfaces);
+        assertEquals(1, interfaces.size());
+        assertTrue(interfaces.containsKey("resourceNameNoInputs"));
+        Object resourceName = interfaces.get("resourceNameNoInputs");
+        assertNotNull(resourceName);
+        assertTrue(resourceName instanceof Map);
+        assertEquals(4, ((Map) resourceName).size());
 
-        ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
-            interfacesOperationsConverter, null);
-        ToscaTemplate template = new ToscaTemplate("test");
-        Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
-        nodeTypes.put("test", nodeType);
-        template.setNode_types(nodeTypes);
-        final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
-
-        assertTrue(all(
-            containsAll("resourceNameNoInputs", "has description", "com.some.resource.or.other.resourceName"),
-            containsNone("operations", INPUT_NAME_PREFIX, "defaultp")
-        ).apply(new String(toscaRepresentation.getMainYaml())));
     }
 
     @Test
@@ -300,20 +261,15 @@
         component.getInterfaces().put(addedInterfaceType, addedInterface);
         ToscaNodeType nodeType = new ToscaNodeType();
         interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, dataTypes, false);
+        Map<String, Object> interfaces = nodeType.getInterfaces();
+        assertNotNull(interfaces);
+        assertEquals(1, interfaces.size());
+        assertTrue(interfaces.containsKey("resourceNameInputMappedToOutput"));
+        Object resourceName = interfaces.get("resourceNameInputMappedToOutput");
+        assertNotNull(resourceName);
+        assertTrue(resourceName instanceof Map);
+        assertEquals(3, ((Map) resourceName).size());
 
-        ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
-            interfacesOperationsConverter, null);
-        ToscaTemplate template = new ToscaTemplate("test");
-        Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
-        nodeTypes.put("test", nodeType);
-        template.setNode_types(nodeTypes);
-        final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
-        String mainYaml = new String(toscaRepresentation.getMainYaml());
-        assertTrue(all(
-            containsAll("resourceNameInputMappedToOutput:", "inputs:"),
-            containsNone("operations")
-        ).apply(mainYaml));
-        validateOperationInputs(mainYaml, 2, "name_for_op_1");
     }
 
     @Test
@@ -323,6 +279,7 @@
         component.setNormalizedName("normalizedComponentName");
         InterfaceDefinition addedInterface = new InterfaceDefinition();
         addedInterface.setType(addedInterfaceType);
+        addedInterface.setToscaResourceName("com.some.resource.or.other.resourceName");
         addOperationsToInterface(component, addedInterface, 2, 2, true, true);
         addedInterface.getOperationsMap().values().stream()
             .filter(operationInputDefinition -> operationInputDefinition.getName().equalsIgnoreCase(
@@ -335,6 +292,7 @@
         String secondInterfaceType = "org.test.lifecycle.standard.interfaceType.second";
         InterfaceDefinition secondInterface = new InterfaceDefinition();
         secondInterface.setType(secondInterfaceType);
+        secondInterface.setToscaResourceName("com.some.resource.or.other.resourceName");
         addOperationsToInterface(component, secondInterface, 2, 2, true, true);
         secondInterface.getOperationsMap().values().stream()
             .filter(operationInputDefinition -> operationInputDefinition.getName().equalsIgnoreCase(
@@ -349,21 +307,21 @@
 
         ToscaNodeType nodeType = new ToscaNodeType();
         interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, dataTypes, false);
+        Map<String, Object> interfaces = nodeType.getInterfaces();
+        assertNotNull(interfaces);
+        assertEquals(2, interfaces.size());
+        assertTrue(interfaces.containsKey("resourceNameInputMappedToOutput"));
+        Object resourceName = interfaces.get("resourceNameInputMappedToOutput");
+        assertNotNull(resourceName);
+        assertTrue(resourceName instanceof Map);
+        assertEquals(3, ((Map) resourceName).size());
 
-        ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
-            interfacesOperationsConverter, null);
-        ToscaTemplate template = new ToscaTemplate("test");
-        Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
-        nodeTypes.put("test", nodeType);
-        template.setNode_types(nodeTypes);
-        final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
+        assertTrue(interfaces.containsKey("second"));
+        resourceName = interfaces.get("second");
+        assertNotNull(resourceName);
+        assertTrue(resourceName instanceof Map);
+        assertEquals(3, ((Map) resourceName).size());
 
-        String mainYaml = new String(toscaRepresentation.getMainYaml());
-        assertTrue(all(
-            containsAll("resourceNameInputMappedToOutput:", "inputs:"),
-            containsNone("operations")
-        ).apply(mainYaml));
-        validateOperationInputs(mainYaml, 2, "name_for_op_1");
     }
 
     @Test
@@ -385,17 +343,15 @@
         component.getInterfaces().put(interfaceName, anInterfaceWithInput);
         final ToscaNodeType nodeType = new ToscaNodeType();
         interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, dataTypes, false);
-        final ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
-            interfacesOperationsConverter, null);
-        final ToscaTemplate template = new ToscaTemplate("testService");
-        final Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
-        nodeTypes.put(NODE_TYPE_NAME, nodeType);
-        template.setNode_types(nodeTypes);
-        final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
-        final String toscaTemplateYaml = new String(toscaRepresentation.getMainYaml());
-        assertThat(toscaTemplateYaml,
-            allOf(containsString(INPUTS.getElementName() + ":"), containsString(input1Name), containsString(interfaceName)));
-        validateInterfaceInputs(toscaTemplateYaml, interfaceName, inputMap);
+        Map<String, Object> interfaces = nodeType.getInterfaces();
+        assertNotNull(interfaces);
+        assertEquals(1, interfaces.size());
+        assertTrue(interfaces.containsKey("myInterfaceName"));
+        Object resourceName = interfaces.get("myInterfaceName");
+        assertNotNull(resourceName);
+        assertTrue(resourceName instanceof Map);
+        assertEquals(2, ((Map) resourceName).size());
+
     }
 
     @Test
@@ -442,12 +398,12 @@
         final Map<String, Object> actualArtifactImplementationMap = (Map<String, Object>) actualImplementationMap.get("primary");
         assertTrue(actualArtifactImplementationMap.containsKey("properties"));
         final Map<String, Object> actualArtifactPropertiesMap = (Map<String, Object>) actualArtifactImplementationMap.get("properties");
-        assertEquals(actualArtifactPropertiesMap.keySet().size(), 1);
+        assertEquals(1, actualArtifactPropertiesMap.keySet().size());
         assertTrue(actualArtifactPropertiesMap.containsKey(listOfStringProperty.getName()));
         final Object expectedListObject = actualArtifactPropertiesMap.get(listOfStringProperty.getName());
         assertTrue(expectedListObject instanceof List);
         final List<String> expectedListOfStringPropValue = (List<String>) expectedListObject;
-        assertEquals(expectedListOfStringPropValue.size(), 3);
+        assertEquals(3, expectedListOfStringPropValue.size());
         assertTrue(expectedListOfStringPropValue.contains("value1"));
         assertTrue(expectedListOfStringPropValue.contains("value2"));
         assertTrue(expectedListOfStringPropValue.contains("value3"));
@@ -494,7 +450,9 @@
     }
 
     @FunctionalInterface
-    interface MainYamlAssertion extends Function<String, Boolean> {}
+    interface MainYamlAssertion extends Function<String, Boolean> {
+
+    }
 
     private static Function<String, Boolean> all(MainYamlAssertion... fs) {
         return s -> io.vavr.collection.List.of(fs).map(f -> f.apply(s)).fold(true, (l, r) -> l && r);
@@ -706,7 +664,7 @@
         service.getComponentMetadataDefinition().getMetadataDataDefinition().setSystemName("LocalInterface");
         service.setInterfaces(Collections.singletonMap("Local", new InterfaceDefinition("Local", null, new HashMap<>())));
 
-        Map<String, Object> resultMap = InterfacesOperationsConverter.addInterfaceTypeElement(service,
+        Map<String, Object> resultMap = interfacesOperationsConverter.addInterfaceTypeElement(service,
             Collections.singletonList("org.openecomp.interfaces.node.lifecycle.Standard"));
 
         assertTrue(MapUtils.isNotEmpty(resultMap)
@@ -732,14 +690,15 @@
     void testRemoveInterfacesWithoutOperationsEmptyMap() {
         final Map<String, Object> interfaceMap = new HashMap<>();
         interfacesOperationsConverter.removeInterfacesWithoutOperations(interfaceMap);
-        assertThat(interfaceMap, is(anEmptyMap()));
+        assertNotNull(interfaceMap);
+        assertTrue(interfaceMap.isEmpty());
     }
 
     @Test
     void testRemoveInterfacesWithoutOperationsNullParameter() {
         final Map<String, Object> interfaceMap = null;
         interfacesOperationsConverter.removeInterfacesWithoutOperations(interfaceMap);
-        assertThat(interfaceMap, is(nullValue()));
+        assertNull(interfaceMap);
     }
 
     @Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
index 6a3810f..040907b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
@@ -49,7 +49,6 @@
 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,8 +62,6 @@
 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.PropertyDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition;
@@ -87,6 +84,7 @@
 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.RelationshipInfo;
 import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
@@ -117,10 +115,12 @@
     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";
 
     @InjectMocks
     private ToscaExportHandler testSubject;
@@ -178,6 +178,7 @@
 
     private Resource getNewResource() {
         Resource resource = new Resource();
+        resource.setUniqueId("resourceUniqueId");
         List<CategoryDefinition> categories = new ArrayList<>();
         CategoryDefinition category = new CategoryDefinition();
         List<SubCategoryDefinition> subcategories = new ArrayList<>();
@@ -203,6 +204,13 @@
         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");
@@ -307,32 +315,24 @@
         when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
             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,
-                new ToscaTemplate(TOSCA_VERSION), new HashMap<String, ToscaNodeType>(), false);
+        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() {
 
         Component component = new Resource();
@@ -411,7 +411,6 @@
     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,6 +422,16 @@
         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);
@@ -444,7 +453,7 @@
         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);
     }
 
@@ -738,7 +747,7 @@
         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"};
@@ -862,7 +871,14 @@
         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"};
@@ -875,7 +891,7 @@
             .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);
 
     }
@@ -1107,16 +1123,15 @@
         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);
@@ -1562,7 +1577,7 @@
         when(capabilityRequirementConverter.buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("cap"), any(), any()))
             .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,
@@ -1683,127 +1698,9 @@
         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");
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInputDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInputDefinition.java
index 0fcdd9c..62587ef 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInputDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInputDefinition.java
@@ -15,12 +15,15 @@
  */
 package org.openecomp.sdc.be.datatypes.elements;
 
-
 import com.fasterxml.jackson.annotation.JsonCreator;
+import lombok.Getter;
+import lombok.Setter;
 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
 
-
+@Getter
+@Setter
 public class OperationInputDefinition extends InputDataDefinition {
+
     private String source;
     private String sourceProperty;
     private String toscaDefaultValue;
@@ -60,27 +63,4 @@
         setToscaPresentationValue(JsonPresentationFields.ARTIFACT_LABEL, name);
     }
 
-    public String getSource() {
-        return source;
-    }
-
-    public void setSource(String source) {
-        this.source = source;
-    }
-
-    public String getSourceProperty() {
-        return sourceProperty;
-    }
-
-    public void setSourceProperty(String sourceProperty) {
-        this.sourceProperty = sourceProperty;
-    }
-
-    public String getToscaDefaultValue() {
-        return toscaDefaultValue;
-    }
-
-    public void setToscaDefaultValue(String toscaDefaultValue) {
-        this.toscaDefaultValue = toscaDefaultValue;
-    }
 }
