import org.openecomp.sdc.logging.api.Logger;
 import org.openecomp.sdc.logging.api.LoggerFactory;
 import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.tosca.datatypes.model.Directive;
+import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
 import org.openecomp.sdc.tosca.services.DataModelUtil;
 import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
 import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
 
+import static org.openecomp.sdc.tosca.services.ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME;
+
 public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface {
 
   private EnrichedServiceModelDao enrichedServiceModelDao;
   private ComponentDao componentDao;
   private ComponentArtifactDao componentArtifactDao;
   private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+  private static final String COMPONENT_PREFIX = "org.openecomp.resource.vfc.";
+
+  private final Logger LOG = LoggerFactory.getLogger(this.getClass().getName());
 
-  private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
   /**
    * Enrich map.
    *
    * @param enrichmentInfo the enrichmentInfo
    * @return the map
    */
-  public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) {
+  public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo,
+                                                ToscaServiceModel serviceModel) {
 
     Map<String, List<ErrorMessage>> errors = new HashMap<>();
     String vspId = enrichmentInfo.getKey();
     Collection<ComponentEntity> components =
         getComponentDao().list(new ComponentEntity(vspId, version, null));
     components
-        .forEach(componentEntry -> errors.putAll(enrichComponent(componentEntry, vspId, version)));
+        .forEach(componentEntry -> errors.putAll(enrichComponent(vspId, version, componentEntry,
+            serviceModel)));
 
     return errors;
   }
 
-  Map<String, List<ErrorMessage>> enrichComponent(ComponentEntity componentEntry, String vspId,
-                                                  Version version) {
+  private Map<String, List<ErrorMessage>> enrichComponent(String vspId,
+                                                  Version version,
+                                                  ComponentEntity component,
+                                                  ToscaServiceModel serviceModel) {
+    Set<String> abstractNodeTypes =
+        extractAbstractTypesFromSameTypeFromServiceModel(component, serviceModel);
+    return enrichComponent(vspId, version, component, abstractNodeTypes);
+  }
+
+  private Set<String> extractAbstractTypesFromSameTypeFromServiceModel(ComponentEntity component,
+                                                                       ToscaServiceModel serviceModel) {
+    Set<String> abstractNodeTypes = new HashSet<>();
+    Map<String, ServiceTemplate> serviceTemplates = serviceModel.getServiceTemplates();
+    String typeToCheck =
+        getComponentVfcTypeToCheck(component.getComponentCompositionData().getName());
+
+    for (ServiceTemplate serviceTemplate : serviceTemplates.values()) {
+      collectAllAbstractNodeTypesPointingToType(
+          typeToCheck, serviceTemplate, serviceTemplates, abstractNodeTypes);
+    }
+
+    return abstractNodeTypes;
+  }
+
+  private String getComponentVfcTypeToCheck(String type) {
+    return Objects.isNull(type) ? ""
+        : type.replace(COMPONENT_PREFIX, COMPONENT_PREFIX + "compute.");
+  }
+
+  private void collectAllAbstractNodeTypesPointingToType(String typeToCheck,
+                                                         ServiceTemplate serviceTemplate,
+                                                         Map<String, ServiceTemplate> serviceTemplates,
+                                                         Set<String> abstractNodeTypes) {
+    Map<String, NodeTemplate> nodeTemplates =
+        DataModelUtil.getNodeTemplates(serviceTemplate);
+
+    for (Map.Entry<String, NodeTemplate> nodeTemplateEntry : nodeTemplates.entrySet()) {
+      handleNodeTemplate(nodeTemplateEntry.getValue(), typeToCheck,
+          serviceTemplates, abstractNodeTypes);
+    }
+  }
+
+  private void handleNodeTemplate(NodeTemplate nodeTemplate,
+                                  String typeToCheck,
+                                  Map<String, ServiceTemplate> serviceTemplates,
+                                  Set<String> abstractNodeTypes) {
+    List<String> directives = DataModelUtil.getDirectives(nodeTemplate);
+    if (directives.contains(Directive.SUBSTITUTABLE.getDisplayName())) {
+      handleSubstitutionServiceTemplate(typeToCheck, nodeTemplate, serviceTemplates,
+          abstractNodeTypes);
+    }
+  }
+
+  private void handleSubstitutionServiceTemplate(String typeToCheck,
+                                                 NodeTemplate nodeTemplate,
+                                                 Map<String, ServiceTemplate> serviceTemplates,
+                                                 Set<String> abstractNodeTypes) {
+    Object serviceTemplateFilter =
+        DataModelUtil.getPropertyValue(nodeTemplate, SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
+    if (Objects.nonNull(serviceTemplateFilter) && serviceTemplateFilter instanceof Map) {
+      String substituteServiceTemplateName =
+          (String) ((Map<String, Object>) serviceTemplateFilter)
+              .get(SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME);
+      ServiceTemplate substituteServiceTemplate =
+          serviceTemplates.get(substituteServiceTemplateName);
+      if (doesNodeTypeExistInSubServiceTemplate(typeToCheck, substituteServiceTemplate)) {
+        abstractNodeTypes.add(nodeTemplate.getType());
+      }
+    }
+  }
+
+  private boolean doesNodeTypeExistInSubServiceTemplate(String nodeTypeId,
+                                                        ServiceTemplate substituteServiceTemplate) {
+    return Objects
+        .nonNull(DataModelUtil.getNodeType(substituteServiceTemplate, nodeTypeId));
+  }
+
+  Map<String, List<ErrorMessage>> enrichComponent(String vspId,
+                                                  Version version,
+                                                  ComponentEntity componentEntry,
+                                                  Set<String> abstractNodeTypes) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     Map<String, List<ErrorMessage>> errors = new HashMap<>();
-    ComponentMonitoringUploadInfo componentMonitoringUploadInfo =
-        extractComponentMibInfo(componentEntry, vspId, version, errors);
-    enrichComponentMib(componentMonitoringUploadInfo, vspId, version, errors);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    List<ComponentMonitoringUploadInfo> componentMonitoringUploadInfoList =
+        extractComponentMibInfo(vspId, version, componentEntry, abstractNodeTypes);
+
+    componentMonitoringUploadInfoList.forEach(
+        componentUploadInfo -> enrichComponentMib(vspId, version, componentUploadInfo, errors));
+
+    mdcDataDebugMessage.debugExitMessage(null);
     return errors;
   }
 
-  private ComponentMonitoringUploadInfo extractComponentMibInfo(ComponentEntity componentEntity,
-                                                                String vspId,
-                                                                Version version,
-                                                                Map<String, List<ErrorMessage>> errors) {
+  private List<ComponentMonitoringUploadInfo> extractComponentMibInfo(String vspId, Version version,
+                                                                      ComponentEntity componentEntity,
+                                                                      Set<String> abstractNodeTypes) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     String componentId = componentEntity.getId();
     ComponentMonitoringUploadEntity entity = new ComponentMonitoringUploadEntity();
     entity.setVspId(vspId);
     entity.setVersion(version);
     entity.setComponentId(componentId);
-    String componentName = componentEntity.getComponentCompositionData().getName();
-    ComponentMonitoringUploadInfo componentMonitoringUploadInfo =
-        new ComponentMonitoringUploadInfo();
-    for (MonitoringUploadType monitoringUploadType : MonitoringUploadType.values()) {
-      updComponentMibInfoByType(componentName, monitoringUploadType, entity,
-          componentMonitoringUploadInfo,
-          errors);
-    }
-//    updComponentMibInfoByType(componentName, MonitoringUploadType.SNMP_POLL, entity,
-//        componentMonitoringUploadInfo,
-//        errors);
-//    updComponentMibInfoByType(componentName, MonitoringUploadType.SNMP_TRAP, entity,
-//        componentMonitoringUploadInfo,
-//        errors);
-
-    mdcDataDebugMessage.debugExitMessage(null, null);
-    return componentMonitoringUploadInfo;
+    List<ComponentMonitoringUploadInfo> componentMonitoringUploadInfoList = new ArrayList<>();
+
+    abstractNodeTypes.forEach(unifiedComponentNodeType -> componentMonitoringUploadInfoList
+        .add(updComponentMibInfoByType(unifiedComponentNodeType, entity)));
+
+    mdcDataDebugMessage.debugExitMessage(null);
+    return componentMonitoringUploadInfoList;
   }
 
-  private void updComponentMibInfoByType(String componentName, MonitoringUploadType type,
-                                         ComponentMonitoringUploadEntity componentMonitoringUploadEntity,
-                                         ComponentMonitoringUploadInfo componentMonitoringUploadInfo,
-                                         Map<String, List<ErrorMessage>> errors) {
+  private ComponentMonitoringUploadInfo updComponentMibInfoByType(String componentName,
+                                                                  ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
-    String path;
-    componentMonitoringUploadEntity.setType(type);
-    Optional<ComponentMonitoringUploadEntity> artifact =
-        getComponentArtifactDao().getByType(componentMonitoringUploadEntity);
+    ComponentMonitoringUploadInfo componentMonitoringUploadInfo =
+        new ComponentMonitoringUploadInfo();
 
-    if (!artifact.isPresent()) {
-      return;
+    for (MonitoringUploadType type : MonitoringUploadType.values()) {
+      componentMonitoringUploadEntity.setType(type);
+      Optional<ComponentMonitoringUploadEntity> artifact =
+          getComponentArtifactDao().getByType(componentMonitoringUploadEntity);
+
+      if (!artifact.isPresent()) {
+        continue;
+      }
+      ComponentMonitoringUploadEntity mibArtifact = artifact.get();
+      updateComponentMonitoringUploadInfoWithMib(getArtifactPath(type, componentName), type,
+          mibArtifact,
+          componentMonitoringUploadInfo);
     }
-    String unifiedComponentNodeType =
-        ToscaNodeType.ABSTRACT_NODE_TYPE_PREFIX + DataModelUtil.getNamespaceSuffix(componentName);
-    path = unifiedComponentNodeType + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName()
+
+    mdcDataDebugMessage.debugExitMessage(null);
+    return componentMonitoringUploadInfo;
+  }
+
+  private String getArtifactPath(MonitoringUploadType type, String unifiedComponentNodeType) {
+    return unifiedComponentNodeType + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName()
         + File.separator + type.name();
+  }
+
+  private void updateComponentMonitoringUploadInfoWithMib(String path,
+                                                          MonitoringUploadType type,
+                                                          ComponentMonitoringUploadEntity mibArtifact,
+                                                          ComponentMonitoringUploadInfo componentMonitoringUploadInfo) {
     MonitoringArtifactInfo monitoringArtifactInfo = new MonitoringArtifactInfo();
     monitoringArtifactInfo.setName(path);
-    monitoringArtifactInfo.setContent(artifact.get().getArtifact().array());
-    switch (type) { //todo as part of ATTASDC-4503
-      case SNMP_POLL:
-        componentMonitoringUploadInfo.setSnmpPoll(monitoringArtifactInfo);
-        break;
-      case SNMP_TRAP:
-        componentMonitoringUploadInfo.setSnmpTrap(monitoringArtifactInfo);
-        break;
-      case VES_EVENTS:
-        componentMonitoringUploadInfo.setVesEvent(monitoringArtifactInfo);
-        break;
-      default:
-        break;
-    }
-
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    monitoringArtifactInfo.setContent(mibArtifact.getArtifact().array());
+    componentMonitoringUploadInfo.setMonitoringArtifactFile(type, monitoringArtifactInfo);
   }
 
-  private void enrichComponentMib(ComponentMonitoringUploadInfo componentMonitoringUploadInfo,
-                                  String vspId,
+  private void enrichComponentMib(String vspId,
                                   Version version,
+                                  ComponentMonitoringUploadInfo componentUploadInfo,
                                   Map<String, List<ErrorMessage>> errors) {
-
-
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     ServiceArtifact mibServiceArtifact = new ServiceArtifact();
     mibServiceArtifact.setVspId(vspId);
     mibServiceArtifact.setVersion(version);
-    enrichMibFiles(mibServiceArtifact, componentMonitoringUploadInfo, errors);
+    enrichMibFiles(mibServiceArtifact, componentUploadInfo, errors);
+
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   private void enrichMibFiles(ServiceArtifact monitoringArtifact,
                               Map<String, List<ErrorMessage>> errors) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (componentMonitoringUploadInfo == null) {
       return;
     }
-    //todo fix as part of ATTASDC-4503
     enrichMibByType(componentMonitoringUploadInfo.getSnmpTrap(), MonitoringUploadType.SNMP_TRAP,
         monitoringArtifact,
         errors);
         monitoringArtifact,
         errors);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   private void enrichMibByType(MonitoringArtifactInfo monitoringArtifactInfo,
                                Map<String, List<ErrorMessage>> errors) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (monitoringArtifactInfo == null) {
       return;
       mibs = FileUtils
           .getFileContentMapFromZip(FileUtils.toByteArray(monitoringArtifactInfo.getContent()));
     } catch (IOException ioException) {
-      log.debug("",ioException);
+      LOG.debug("", ioException);
       ErrorMessage.ErrorMessageUtil
           .addMessage(mibServiceArtifact.getName() + "." + type.name(), errors)
           .add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
       getEnrichedServiceModelDao().storeExternalArtifact(mibServiceArtifact);
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   private EnrichedServiceModelDao getEnrichedServiceModelDao() {
 
 
 package org.openecomp.sdc.enrichment.impl.external.artifact;
 
+import org.apache.commons.collections4.CollectionUtils;
 import org.mockito.ArgumentCaptor;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.openecomp.core.utilities.file.FileUtils;
 import org.openecomp.sdc.enrichment.EnrichmentInfo;
 import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
 import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
+import org.openecomp.sdc.tosca.services.YamlUtil;
 import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
 import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
 import org.testng.annotations.Test;
 
 import java.io.File;
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
-import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.Optional;
+import java.util.Set;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import static org.mockito.Matchers.anyObject;
 import static org.mockito.Mockito.atLeastOnce;
   @Test
   public void testEnrichComponent() throws Exception {
     String vspId = "123";
-    String componentId = "1111111111";
+    String componentId = "1";
     Version version = new Version();
     version.setMajor(1);
     version.setMinor(0);
 
-    ComponentEntity componentEntity = getComponentEntity(vspId, version, componentId);
-    setMockToEnrichComponent(vspId, componentId, version);
-    monitoringMibEnricher.enrichComponent(componentEntity, vspId, version);
-
+    ComponentEntity componentEntity = getComponentEntity(vspId, version, componentId, vspId +
+        "enrichMib_server");
+    setMockToEnrichComponent(vspId, version, componentId);
     String componentName = componentEntity.getComponentCompositionData().getName();
     String unifiedComponentName =
         ToscaNodeType.ABSTRACT_NODE_TYPE_PREFIX + DataModelUtil.getNamespaceSuffix(componentName);
+
     ArgumentCaptor<ServiceArtifact> expectedServiceArtifact =
         ArgumentCaptor.forClass(ServiceArtifact.class);
+    monitoringMibEnricher.enrichComponent(vspId, version, componentEntity,
+        Stream.of(unifiedComponentName).collect(Collectors.toSet()));
+
     Mockito.verify(enrichedServiceModelDaoMock, atLeastOnce())
         .storeExternalArtifact(expectedServiceArtifact.capture());
     Assert.assertEquals(expectedServiceArtifact.getValue().getName()
   }
 
   @Test
-  public void testEnrich() throws Exception {
+  public void testEnrichmentOfTwoComponentsFromSameType() throws IOException {
     EnrichmentInfo enrichmentInfo = new EnrichmentInfo();
     Version version = new Version();
     version.setMajor(1);
     String vspId = "123";
     enrichmentInfo.setKey(vspId);
     enrichmentInfo.setVersion(version);
-    String componentId1 = "1111111111";
-    String componentId2 = "2222222222";
+    String componentId1 = "1";
+    String componentId2 = "2";
+    String abstType = "org.openecomp.resource.abstract.nodes.pd_server";
+    String abstType1 = "org.openecomp.resource.abstract.nodes.pd_server_1";
+
+    List<ComponentEntity> returnedComponents = new ArrayList<>();
+    returnedComponents.add(getComponentEntity(vspId, version, componentId1,
+        "pd_server"));
+    returnedComponents.add(getComponentEntity(vspId, version, componentId2,
+        "pd_server"));
+    Mockito.when(componentDaoMock.list(anyObject()))
+        .thenReturn(returnedComponents);
+    setMockToEnrichComponent(vspId, version, componentId1);
 
+    ToscaServiceModel mockServiceModel =
+        getMockServiceModel("/mock/enrichMib/toscaModel/twoAbstractNodesFromSameType");
 
-    Collection<ComponentEntity> returnedComponents = new ArrayList<>();
-    returnedComponents.add(getComponentEntity(vspId, version, componentId1));
-    returnedComponents.add(getComponentEntity(vspId, version, componentId2));
+    ArgumentCaptor<ServiceArtifact> expectedServiceArtifact =
+        ArgumentCaptor.forClass(ServiceArtifact.class);
+    monitoringMibEnricher.enrich(enrichmentInfo, mockServiceModel);
 
-    Mockito.when(componentDaoMock.list(anyObject()))
-        .thenReturn(returnedComponents);
-    setMockToEnrichComponent(vspId, componentId1, version);
+    Mockito.verify(enrichedServiceModelDaoMock, times(24))
+        .storeExternalArtifact(expectedServiceArtifact.capture());
+
+    Set<String> prefixes = getAllMibDirectoryPrefixes(expectedServiceArtifact.getAllValues());
 
-    monitoringMibEnricher.enrich(enrichmentInfo);
-    Mockito.verify(enrichedServiceModelDaoMock, times(12)).storeExternalArtifact(anyObject());
+    validateExpectedAbstractTypes(Stream.of(abstType, abstType1).collect(Collectors.toSet()), prefixes);
+  }
 
+  private void validateExpectedAbstractTypes(Set<String> expectedAbstractTypes,
+                                             Set<String> prefixes) {
+    for(String abstType : expectedAbstractTypes){
+      Assert.assertTrue(prefixes.contains(abstType));
+    }
   }
 
-  private void setMockToEnrichComponent(String vspId, String componentId, Version version) {
+  private void setMockToEnrichComponent(String vspId, Version version, String componentId) {
     ComponentMonitoringUploadEntity returnedArtifact = new ComponentMonitoringUploadEntity();
     returnedArtifact.setVspId(vspId);
     returnedArtifact.setVersion(version);
     Mockito.doNothing().when(enrichedServiceModelDaoMock).storeExternalArtifact(anyObject());
   }
 
-  private ComponentEntity getComponentEntity(String vspId, Version version, String componentId) {
+  private ComponentEntity getComponentEntity(String vspId,
+                                             Version version,
+                                             String componentId,
+                                             String componentNameSuffix) {
     ComponentEntity componentEntity = new ComponentEntity();
     componentEntity.setId(componentId);
     componentEntity.setVspId(vspId);
     componentEntity.setVersion(version);
 
-    String componentName = vspId + "enrichMib_server";
     String compositionData = "{\n" +
-        "  \"name\": \"org.openecomp.resource.vfc.nodes.heat." + componentName + "\",\n" +
-        "  \"displayName\": \"" + componentName + "\"\n" +
+        "  \"name\": \"org.openecomp.resource.vfc.nodes.heat." + componentNameSuffix + "\",\n" +
+        "  \"displayName\": \"" + componentNameSuffix + "\"\n" +
         "}";
     componentEntity.setCompositionData(compositionData);
     return componentEntity;
 
   private ByteBuffer getMibByteBuffer(String fileName) {
     byte[] mibBytes = FileUtils.readViaInputStream(this.getClass().getResource(fileName),
-        stream -> FileUtils.toByteArray(stream));
+        FileUtils::toByteArray);
     return ByteBuffer.wrap(mibBytes);
   }
 
+  private ToscaServiceModel getMockServiceModel(String serviceTemplatesDirectory)
+      throws IOException {
+    File directory = new File(this.getClass().getResource(serviceTemplatesDirectory).getFile());
+    ToscaServiceModel serviceModel = new ToscaServiceModel();
+    Map<String, ServiceTemplate> serviceTemplates = new HashMap<>();
+
+    for (final File serviceTemplateFile : directory.listFiles()) {
+      byte[] content = FileUtils
+          .readViaInputStream(this.getClass().getResource(serviceTemplatesDirectory + File
+                  .separator + serviceTemplateFile.getName()),
+              FileUtils::toByteArray);
+      ServiceTemplate serviceTemplate =
+          new YamlUtil().yamlToObject(new String(content), ServiceTemplate.class);
+      serviceTemplates.put(ToscaUtil.getServiceTemplateFileName(serviceTemplate), serviceTemplate);
+    }
+
+    serviceModel.setServiceTemplates(serviceTemplates);
+    return serviceModel;
+  }
+
+  private Set<String> getAllMibDirectoryPrefixes(List<ServiceArtifact> serviceArtifacts) {
+    if(CollectionUtils.isEmpty(serviceArtifacts)){
+      return new HashSet<>();
+    }
+
+    Set<String> prefixes = new HashSet<>();
+    for(ServiceArtifact serviceArtifact : serviceArtifacts){
+      String absolutePath = serviceArtifact.getName();
+      prefixes.add(absolutePath.split(Pattern.quote(File.separator))[0]);
+    }
+
+    return prefixes;
+  }
+
 }
 
 import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
 import org.openecomp.sdc.tosca.datatypes.model.CapabilityAssignment;
 import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
-import org.openecomp.sdc.tosca.datatypes.model.CapabilityType;
 import org.openecomp.sdc.tosca.datatypes.model.Constraint;
 import org.openecomp.sdc.tosca.datatypes.model.EntrySchema;
 import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
    * Add substitution mapping.
    */
 
-  private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+  private static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
   private static final Logger logger = LoggerFactory.getLogger(DataModelUtil.class);
+  private static final String SERVICE_TEMPLATE = "Service Template";
+  private static final String NODE_TYPE = "Node Type";
 
   /**
    * Add substitution mapping.
    */
   public static void addSubstitutionMapping(ServiceTemplate serviceTemplate,
                                             SubstitutionMapping substitutionMapping) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
           LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(),
           LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION);
       throw new CoreException(
-          new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping", "Service Template")
+          new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping", SERVICE_TEMPLATE)
               .build());
     }
 
     }
     serviceTemplate.getTopology_template().setSubstitution_mappings(substitutionMapping);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
+  }
+
+  public static List<String> getDirectives(NodeTemplate nodeTemplate) {
+    if (Objects.isNull(nodeTemplate)
+        || Objects.isNull(nodeTemplate.getDirectives())) {
+      return Collections.emptyList();
+    }
+
+    return nodeTemplate.getDirectives();
   }
 
   /**
                                                List<String> substitutionMappingRequirementList) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
           LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION);
       throw new CoreException(
           new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping Requirements",
-              "Service Template").build());
+              SERVICE_TEMPLATE).build());
     }
 
     if (serviceTemplate.getTopology_template() == null) {
     serviceTemplate.getTopology_template().getSubstitution_mappings().getRequirements()
         .put(substitutionMappingRequirementId, substitutionMappingRequirementList);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   /**
                                                       List<String> substitutionMappingCapabilityList) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
           LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION);
       throw new CoreException(
           new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping Capabilities",
-              "Service Template").build());
+              SERVICE_TEMPLATE).build());
     }
 
     if (serviceTemplate.getTopology_template() == null) {
     serviceTemplate.getTopology_template().getSubstitution_mappings().getCapabilities()
         .putIfAbsent(substitutionMappingCapabilityId, substitutionMappingCapabilityList);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
-  public static Map<String, NodeTemplate> getNodeTemplates(ServiceTemplate serviceTemplate){
+  public static Map<String, NodeTemplate> getNodeTemplates(ServiceTemplate serviceTemplate) {
     if (Objects.isNull(serviceTemplate)
         || Objects.isNull(serviceTemplate.getTopology_template())
-        || MapUtils.isEmpty(serviceTemplate.getTopology_template().getNode_templates())){
+        || MapUtils.isEmpty(serviceTemplate.getTopology_template().getNode_templates())) {
       return new HashMap<>();
     }
 
                                      NodeTemplate nodeTemplate) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
           LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(),
           LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION);
       throw new CoreException(
-          new InvalidAddActionNullEntityErrorBuilder("Node Template", "Service Template").build());
+          new InvalidAddActionNullEntityErrorBuilder("Node Template", SERVICE_TEMPLATE).build());
     }
     TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
     if (Objects.isNull(topologyTemplate)) {
     }
     topologyTemplate.getNode_templates().put(nodeTemplateId, nodeTemplate);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
-
-  }
-
-  /**
-   * Add capability def.
-   *
-   * @param nodeType             the node type
-   * @param capabilityId         the capability id
-   * @param capabilityDefinition the capability definition
-   */
-  public static void addCapabilityDef(NodeType nodeType, String capabilityId,
-                                      CapabilityDefinition capabilityDefinition) {
-
-
-    mdcDataDebugMessage.debugEntryMessage(null, null);
-
-    if (nodeType == null) {
-      throw new CoreException(
-          new InvalidAddActionNullEntityErrorBuilder("Capability Definition", "Node Type").build());
-    }
-    if (Objects.isNull(nodeType.getCapabilities())) {
-      nodeType.setCapabilities(new HashMap<>());
-    }
-    nodeType.getCapabilities().put(capabilityId, capabilityDefinition);
+    mdcDataDebugMessage.debugExitMessage(null);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
   }
 
   /**
    */
   public static void addNodeTypeCapabilitiesDef(NodeType nodeType,
                                                 Map<String, CapabilityDefinition> capabilities) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
-    if (capabilities == null || capabilities.entrySet().size() == 0) {
+    if (MapUtils.isEmpty(capabilities) || capabilities.entrySet().isEmpty()) {
       return;
     }
 
     if (nodeType == null) {
       throw new CoreException(
-          new InvalidAddActionNullEntityErrorBuilder("Capability Definition", "Node Type").build());
+          new InvalidAddActionNullEntityErrorBuilder("Capability Definition", NODE_TYPE).build());
     }
 
     if (MapUtils.isEmpty(nodeType.getCapabilities())) {
       nodeType.getCapabilities().put(entry.getKey(), entry.getValue());
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   /**
                                          PolicyDefinition policyDefinition) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
           LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(),
           LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION);
       throw new CoreException(
-          new InvalidAddActionNullEntityErrorBuilder("Policy Definition", "Service Template")
+          new InvalidAddActionNullEntityErrorBuilder("Policy Definition", SERVICE_TEMPLATE)
               .build());
     }
     TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
     }
     topologyTemplate.getPolicies().put(policyId, policyDefinition);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   /**
                                  NodeType nodeType) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
           LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(),
           LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION);
       throw new CoreException(
-          new InvalidAddActionNullEntityErrorBuilder("Node Type", "Service Template").build());
+          new InvalidAddActionNullEntityErrorBuilder(NODE_TYPE, SERVICE_TEMPLATE).build());
     }
     if (serviceTemplate.getNode_types() == null) {
       serviceTemplate.setNode_types(new HashMap<>());
     }
     serviceTemplate.getNode_types().put(nodeTypeId, nodeType);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   public static void removeNodeType(ServiceTemplate serviceTemplate,
-                                    String nodeTypeId){
+                                    String nodeTypeId) {
     if (serviceTemplate == null) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
           LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(),
           LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION);
       throw new CoreException(
-          new InvalidAddActionNullEntityErrorBuilder("Node Type", "Service Template").build());
+          new InvalidAddActionNullEntityErrorBuilder(NODE_TYPE, SERVICE_TEMPLATE).build());
     }
     if (serviceTemplate.getNode_types() == null) {
       serviceTemplate.setNode_types(new HashMap<>());
     }
     serviceTemplate.getNode_types().remove(nodeTypeId);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   /**
                                              RelationshipTemplate relationshipTemplate) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
           LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(),
           LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION);
       throw new CoreException(
-          new InvalidAddActionNullEntityErrorBuilder("Relationship Template", "Service Template")
+          new InvalidAddActionNullEntityErrorBuilder("Relationship Template", SERVICE_TEMPLATE)
               .build());
     }
     if (serviceTemplate.getTopology_template() == null) {
     serviceTemplate.getTopology_template().getRelationship_templates()
         .put(relationshipTemplateId, relationshipTemplate);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   /**
                                               RequirementAssignment requirementAssignment) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (nodeTemplate == null) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
     requirement.put(requirementId, requirementAssignment);
     nodeTemplate.getRequirements().add(requirement);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   /**
   public static NodeTemplate getNodeTemplate(ServiceTemplate serviceTemplate,
                                              String nodeTemplateId) {
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null
         || serviceTemplate.getTopology_template() == null
       return null;
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId);
   }
 
   public static NodeType getNodeType(ServiceTemplate serviceTemplate, String nodeTypeId) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
     if (serviceTemplate == null || serviceTemplate.getNode_types() == null) {
       return null;
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return serviceTemplate.getNode_types().get(nodeTypeId);
   }
 
       String requirementDefinitionId) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (nodeType == null || nodeType.getRequirements() == null || requirementDefinitionId == null) {
       return Optional.empty();
       }
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return Optional.empty();
   }
 
   /**
-   * get requirement defenition from requirement defenition list by req key.
+   * get requirement definition from requirement definition list by req key.
    *
-   * @param requirementsDefinitionList requirement defenition list
+   * @param requirementsDefinitionList requirement definition list
    * @param requirementKey             requirement key
    */
   public static Optional<RequirementDefinition> getRequirementDefinition(
       List<Map<String, RequirementDefinition>> requirementsDefinitionList,
       String requirementKey) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
     if (CollectionUtils.isEmpty(requirementsDefinitionList)) {
       return Optional.empty();
     }
 
     for (Map<String, RequirementDefinition> requirementMap : requirementsDefinitionList) {
       if (requirementMap.containsKey(requirementKey)) {
-        mdcDataDebugMessage.debugExitMessage(null, null);
+        mdcDataDebugMessage.debugExitMessage(null);
         return Optional.of(requirementMap.get(requirementKey));
       }
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return Optional.empty();
   }
 
       String capabilityDefinitionId) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (nodeType == null || nodeType.getCapabilities() == null || capabilityDefinitionId == null) {
       return Optional.empty();
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return Optional.ofNullable(nodeType.getCapabilities().get(capabilityDefinitionId));
   }
 
                                                           String groupName, GroupDefinition group) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
           LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(),
           LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION);
       throw new CoreException(
-          new InvalidAddActionNullEntityErrorBuilder("Group Definition", "Service Template")
+          new InvalidAddActionNullEntityErrorBuilder("Group Definition", SERVICE_TEMPLATE)
               .build());
     }
 
     }
 
     serviceTemplate.getTopology_template().getGroups().put(groupName, group);
-    mdcDataDebugMessage.debugExitMessage(null, null);
-  }
-
-  /**
-   * Create property definition property definition.
-   *
-   * @param type        the type
-   * @param description the description
-   * @param required    the required
-   * @param constraints the constraints
-   * @param status      the status
-   * @param entrySchema the entry schema
-   * @param defaultVal  the default val
-   * @return the property definition
-   */
-  public static PropertyDefinition createPropertyDefinition(String type, String description,
-                                                            boolean required,
-                                                            List<Constraint> constraints,
-                                                            Status status,
-                                                            EntrySchema entrySchema,
-                                                            Object defaultVal) {
-
-
-    mdcDataDebugMessage.debugEntryMessage(null, null);
-
-    PropertyDefinition propDef = new PropertyDefinition();
-    propDef.setType(type);
-    propDef.setDescription(description);
-    propDef.setRequired(required);
-    propDef.setConstraints(constraints);
-    if (status != null) {
-      propDef.setStatus(status);
-    }
-    propDef.setEntry_schema(entrySchema);
-    propDef.set_default(defaultVal);
-
-    mdcDataDebugMessage.debugExitMessage(null, null);
-    return propDef;
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   /**
                                                               Object defaultVal) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     ParameterDefinition paramDef = new ParameterDefinition();
     paramDef.setType(type);
     paramDef.setEntry_schema(entrySchema == null ? null : entrySchema.clone());
     paramDef.set_default(defaultVal);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return paramDef;
   }
 
                                                         String relationship, Object[] occurrences) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     RequirementDefinition requirementDefinition = new RequirementDefinition();
     requirementDefinition.setCapability(capability);
       requirementDefinition.setOccurrences(occurrences);
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return requirementDefinition;
   }
 
-  /**
-   * Create attribute definition attribute definition.
-   *
-   * @param type        the type
-   * @param description the description
-   * @param status      the status
-   * @param entrySchema the entry schema
-   * @param defaultVal  the default val
-   * @return the attribute definition
-   */
-  public static AttributeDefinition createAttributeDefinition(String type, String description,
-                                                              Status status,
-                                                              EntrySchema entrySchema,
-                                                              Object defaultVal) {
-
-
-    mdcDataDebugMessage.debugEntryMessage(null, null);
-
-    AttributeDefinition attributeDef = new AttributeDefinition();
-    attributeDef.setType(type);
-
-    if (description != null) {
-      attributeDef.setDescription(description);
-    }
-    if (status != null) {
-      attributeDef.setStatus(status);
-    }
-    attributeDef.setEntry_schema(entrySchema);
-    attributeDef.set_default(defaultVal);
-
-    mdcDataDebugMessage.debugExitMessage(null, null);
-    return attributeDef;
-  }
-
-  /**
-   * Create valid values constraint constraint.
-   *
-   * @param values the values
-   * @return the constraint
-   */
-  public static Constraint createValidValuesConstraint(Object... values) {
-
-
-    mdcDataDebugMessage.debugEntryMessage(null, null);
-
-    Constraint validValues = new Constraint();
-    for (Object value : values) {
-      validValues.addValidValue(value);
-    }
-
-    mdcDataDebugMessage.debugExitMessage(null, null);
-    return validValues;
-  }
-
-  /**
-   * Create metadata metadata.
-   *
-   * @param templateName    the template name
-   * @param templateVersion the template version
-   * @param templateAuthor  the template author
-   * @return the metadata
-   */
-  public static Map<String, String> createMetadata(String templateName, String templateVersion,
-                                                   String templateAuthor) {
-
-
-    mdcDataDebugMessage.debugEntryMessage(null, null);
-    Map<String, String> metadata = new HashMap<>();
-    metadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, templateName);
-    metadata.put("template_version", templateVersion);
-    metadata.put("template_author", templateAuthor);
-
-    mdcDataDebugMessage.debugExitMessage(null, null);
-    return metadata;
-  }
-
   /**
    * Create entry schema entry schema.
    *
                                               List<Constraint> constraints) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
-    if(Objects.isNull(type) && Objects.isNull(description) && CollectionUtils.isEmpty(constraints)){
+    if (Objects.isNull(type) && Objects.isNull(description) &&
+        CollectionUtils.isEmpty(constraints)) {
       return null;
     }
 
     entrySchema.setDescription(description);
     entrySchema.setConstraints(constraints);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return entrySchema;
   }
 
-  /**
-   * Create valid values constraints list list.
-   *
-   * @param values the values
-   * @return the list
-   */
-  public static List<Constraint> createValidValuesConstraintsList(String... values) {
-
-
-    mdcDataDebugMessage.debugEntryMessage(null, null);
-
-    List<Constraint> constraints;
-    Constraint validValues;
-    constraints = new ArrayList<>();
-    validValues = DataModelUtil.createValidValuesConstraint(values);
-    constraints.add(validValues);
-
-    mdcDataDebugMessage.debugExitMessage(null, null);
-    return constraints;
-  }
-
-  /**
-   * Create greater or equal constrain constraint.
-   *
-   * @param value the value
-   * @return the constraint
-   */
-  public static Constraint createGreaterOrEqualConstrain(Object value) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
-
-    Constraint constraint = new Constraint();
-    constraint.setGreater_or_equal(value);
-
-    mdcDataDebugMessage.debugExitMessage(null, null);
-    return constraint;
-  }
-
-  /**
-   * Gets constrain list.
-   *
-   * @param constrains the constrains
-   * @return the constrain list
-   */
-  public static List<Constraint> getConstrainList(Constraint... constrains) {
-    return Arrays.asList(constrains);
-
-  }
-
   /**
    * Create get input property value from list parameter map.
    *
                                                                  String... nestedPropertyName) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     List propertyList = new ArrayList<>();
     propertyList.add(inputPropertyListName);
     Map getInputProperty = new HashMap<>();
     getInputProperty.put(ToscaFunctions.GET_INPUT.getDisplayName(), propertyList);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return getInputProperty;
   }
 
       PropertyDefinition propertyDefinition) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (propertyDefinition == null) {
       return null;
     parameterDefinition.setHidden(false);
     parameterDefinition.setImmutable(false);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return parameterDefinition;
   }
 
       AttributeDefinition attributeDefinition, Map<String, List> outputValue) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (attributeDefinition == null) {
       return null;
     parameterDefinition.setDescription(attributeDefinition.getDescription());
     parameterDefinition.setValue(outputValue);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return parameterDefinition;
   }
 
-  /**
-   * Convert capability type to capability definition capability definition.
-   *
-   * @param capabilityTypeId the capability type id
-   * @param capabilityType   the capability type
-   * @param properties       the properties
-   * @return the capability definition
-   */
-  public static CapabilityDefinition convertCapabilityTypeToCapabilityDefinition(
-      String capabilityTypeId, CapabilityType capabilityType, Map<String, Object> properties) {
-
-
-    mdcDataDebugMessage.debugEntryMessage(null, null);
-
-    CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
-    capabilityDefinition.setAttributes(cloneAttributeDefinitionMap(capabilityType.getAttributes()));
-    capabilityDefinition.setProperties(clonePropertyDefinitionMap(capabilityType.getProperties()));
-    capabilityDefinition.setDescription(capabilityType.getDescription());
-    capabilityDefinition.setType(capabilityTypeId);
-
-    capabilityDefinition.getProperties()
-        .entrySet()
-        .stream()
-        .filter(entry -> properties.containsKey(entry.getKey()))
-        .forEach(entry -> entry.getValue()
-            .set_default(properties.get(entry.getKey())));
-
-    mdcDataDebugMessage.debugExitMessage(null, null);
-    return capabilityDefinition;
-  }
-
-  /**
-   * Clone property definition map map.
-   *
-   * @param propertyDefinitionMap the property definition map
-   * @return the map
-   */
-  public static Map clonePropertyDefinitionMap(
-      Map<String, PropertyDefinition> propertyDefinitionMap) {
-
-
-    mdcDataDebugMessage.debugEntryMessage(null, null);
-
-    Map outMap = new HashMap<>();
-    for (String propertyDefKey : propertyDefinitionMap.keySet()) {
-      PropertyDefinition propertyDefValue = propertyDefinitionMap.get(propertyDefKey);
-      outMap.put(new String(propertyDefKey), propertyDefValue.clone());
-    }
-
-    mdcDataDebugMessage.debugExitMessage(null, null);
-    return outMap;
-  }
-
-  /**
-   * Clone attribute definition map map.
-   *
-   * @param attributeDefinitionMap the attribute definition map
-   * @return the map
-   */
-  public static Map cloneAttributeDefinitionMap(
-      Map<String, AttributeDefinition> attributeDefinitionMap) {
-
-
-    mdcDataDebugMessage.debugEntryMessage(null, null);
-
-    Map outMap = new HashMap<>();
-    for (String attributeDefKey : attributeDefinitionMap.keySet()) {
-      AttributeDefinition attributeDefinition = attributeDefinitionMap.get(attributeDefKey);
-      outMap.put(new String(attributeDefKey), attributeDefinition.clone());
-    }
-
-    mdcDataDebugMessage.debugExitMessage(null, null);
-    return outMap;
-  }
-
   public static boolean isNodeTemplate(String entryId, ServiceTemplate serviceTemplate) {
     return serviceTemplate.getTopology_template().getNode_templates() != null
         && serviceTemplate.getTopology_template().getNode_templates().get(entryId) != null;
                                                          ParameterDefinition parameterDefinition) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (Objects.isNull(serviceTemplate)) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
           LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION);
       throw new CoreException(
           new InvalidAddActionNullEntityErrorBuilder("Topology Template Input Parameter",
-              "Service Template").build());
+              SERVICE_TEMPLATE).build());
     }
     TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
     if (Objects.isNull(topologyTemplate)) {
     }
     topologyTemplate.getInputs().put(parameterDefinitionId, parameterDefinition);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
 
   }
 
                                                           ParameterDefinition parameterDefinition) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (Objects.isNull(serviceTemplate)) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
           LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(),
           LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION);
       throw new CoreException(
-          new InvalidAddActionNullEntityErrorBuilder("Topology Template Ouput Parameter",
-              "Service Template").build());
+          new InvalidAddActionNullEntityErrorBuilder("Topology Template Output Parameter",
+              SERVICE_TEMPLATE).build());
     }
     TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template();
     if (Objects.isNull(topologyTemplate)) {
     }
     topologyTemplate.getOutputs().put(parameterDefinitionId, parameterDefinition);
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
 
   }
 
       return;
     }
     if (requirementList == null) {
-      requirementList = new ArrayList<Map<String, RequirementDefinition>>();
+      requirementList = new ArrayList<>();
     }
 
     for (Map.Entry<String, RequirementDefinition> entry : requirementDef.entrySet()) {
    */
   public static Map<String, RequirementAssignment> getNodeTemplateRequirements(
       NodeTemplate nodeTemplate) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (Objects.isNull(nodeTemplate)) {
       return null;
       }
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return nodeTemplateRequirementsAssignment;
   }
 
    */
   public static List<Map<String, RequirementAssignment>> getNodeTemplateRequirementList(
       NodeTemplate nodeTemplate) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
     ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
     //Creating concrete objects
     List<Map<String, RequirementAssignment>> requirements = nodeTemplate.getRequirements();
       requirements.addAll(concreteRequirementList);
       nodeTemplate.setRequirements(requirements);
     }
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return concreteRequirementList;
   }
 
   /**
    * get requirement assignment from requirement assignment list by req key.
    *
-   * @param requirementsAssignmentList requirement defenition list
+   * @param requirementsAssignmentList requirement definition list
    * @param requirementKey             requirement key
    */
   public static Optional<List<RequirementAssignment>> getRequirementAssignment(
       List<Map<String, RequirementAssignment>> requirementsAssignmentList,
       String requirementKey) {
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
     if (CollectionUtils.isEmpty(requirementsAssignmentList)) {
       return Optional.empty();
     }
       }
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
-    return Optional.ofNullable(matchRequirementAssignmentList);
+    mdcDataDebugMessage.debugExitMessage(null);
+    return Optional.of(matchRequirementAssignmentList);
   }
 
   /**
-   * remove requirement defenition from requirement defenition list by req key.
+   * remove requirement definition from requirement definition list by req key.
    *
-   * @param requirementsDefinitionList requirement defenition list
+   * @param requirementsDefinitionList requirement definition list
    * @param requirementKey             requirement key
    */
   public static void removeRequirementsDefinition(
       List<Map<String, RequirementDefinition>> requirementsDefinitionList,
       String requirementKey) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
     if (requirementsDefinitionList == null) {
       return;
     }
       requirementsDefinitionList.remove(removeMap);
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   /**
-   * remove requirement assignment from requirement defenition list by req key.
+   * remove requirement assignment from requirement definition list by req key.
    *
    * @param requirementsAssignmentList requirement Assignment list
    * @param requirementKey             requirement key
   public static void removeRequirementsAssignment(
       List<Map<String, RequirementAssignment>> requirementsAssignmentList,
       String requirementKey) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
     if (requirementsAssignmentList == null) {
       return;
     }
       requirementsAssignmentList.remove(removeMap);
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
 
       NodeTemplate nodeTemplate,
       String requirementKey,
       RequirementAssignment requirementAssignmentToBeDeleted) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
     ToscaAnalyzerService toscaAnalyzerService = new ToscaAnalyzerServiceImpl();
     List<Map<String, RequirementAssignment>> nodeTemplateRequirements = nodeTemplate
         .getRequirements();
       return;
     }
 
-    Map<String, RequirementAssignment> mapToBeRemoved = new HashMap<>();
     ListIterator<Map<String, RequirementAssignment>> iter = nodeTemplateRequirements.listIterator();
     while (iter.hasNext()) {
       Map<String, RequirementAssignment> reqMap = iter.next();
       }
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   /**
-   * Return the suffix of the input namespace
-   * For an exmpale - for abc.sdf.vsrx, retrun vsrx
+   * Return the suffix of the input namespace For an exampale - for abc.sdf.vsrx, return vsrx
    *
    * @param namespace namespace
    * @return String namespace suffix
    *
    * @param imports  namespace
    * @param importId namespace
-   * @return true if exist, flase if not exist
+   * @return true if exist, false if not exist
    */
   public static boolean isImportAddedToServiceTemplate(List<Map<String, Import>> imports,
                                                        String importId) {
    */
   public static ParameterDefinition getOuputParameter(ServiceTemplate serviceTemplate,
                                                       String outputParameterId) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null
         || serviceTemplate.getTopology_template() == null
       return null;
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return serviceTemplate.getTopology_template().getOutputs().get(outputParameterId);
   }
 
    */
   public static Object getPropertyValue(NodeTemplate nodeTemplate,
                                         String propertyId) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (nodeTemplate == null
         || nodeTemplate.getProperties() == null) {
       return null;
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return nodeTemplate.getProperties().get(propertyId);
   }
 
   /**
    * Get node template properties according to the input node template id.
    *
-   * @param serviceTemplate       service template
-   * @param nodeTemplateId        node template id
+   * @param serviceTemplate service template
+   * @param nodeTemplateId  node template id
    * @return node template properties
    */
   public static Map<String, Object> getNodeTemplateProperties(ServiceTemplate serviceTemplate,
                                                               String nodeTemplateId) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null
         || serviceTemplate.getTopology_template() == null
       return null;
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId)
         .getProperties();
   }
    * @return the substitution mappings
    */
   public static SubstitutionMapping getSubstitutionMappings(ServiceTemplate serviceTemplate) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (serviceTemplate == null
         || serviceTemplate.getTopology_template() == null
       return null;
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return serviceTemplate.getTopology_template().getSubstitution_mappings();
   }
 
   /**
    * Compare two requirement assignment objects for equality.
    *
-   * @param first  the first requirement assignement object
-   * @param second the second  requirement assignement object
+   * @param first  the first requirement assignment object
+   * @param second the second  requirement assignment object
    * @return true if objects are equal and false otherwise
    */
   public static boolean compareRequirementAssignment(RequirementAssignment first,
                                                      RequirementAssignment second) {
-    if (first.getCapability().equals(second.getCapability())
+    return (first.getCapability().equals(second.getCapability())
         && first.getNode().equals(second.getNode())
-        && first.getRelationship().equals(second.getRelationship())) {
-      return true;
-    }
-    return false;
+        && first.getRelationship().equals(second.getRelationship()));
   }
 
   /**
                                                     NodeTemplate portNodeTemplate) {
 
 
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
     RequirementAssignment requirementAssignment = new RequirementAssignment();
     requirementAssignment.setCapability(ToscaCapabilityType.NATIVE_NETWORK_BINDABLE);
     requirementAssignment.setRelationship(ToscaRelationshipType.NATIVE_NETWORK_BINDS_TO);
     requirementAssignment.setNode(computeNodeTemplateId);
     addRequirementAssignment(portNodeTemplate, ToscaConstants.BINDING_REQUIREMENT_ID,
         requirementAssignment);
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
   public static SubstitutionMapping createSubstitutionTemplateSubMapping(
       String nodeTypeKey,
       NodeType substitutionNodeType,
       Map<String, Map<String, List<String>>> mapping) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
     SubstitutionMapping substitutionMapping = new SubstitutionMapping();
     substitutionMapping.setNode_type(nodeTypeKey);
     substitutionMapping.setCapabilities(
         manageRequirementMapping(substitutionNodeType.getRequirements(),
             mapping.get("requirement")));
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return substitutionMapping;
   }
 
   private static Map<String, List<String>> manageRequirementMapping(
       List<Map<String, RequirementDefinition>> requirementList,
       Map<String, List<String>> requirementSubstitutionMapping) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (requirementList == null) {
       return null;
       }
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return requirementMapping;
   }
 
   private static Map<String, List<String>> manageCapabilityMapping(
       Map<String, CapabilityDefinition> capabilities,
       Map<String, List<String>> capabilitySubstitutionMapping) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
     if (capabilities == null) {
-      mdcDataDebugMessage.debugExitMessage(null, null);
+      mdcDataDebugMessage.debugExitMessage(null);
       return null;
     }
 
       capabilityMapping.put(capabilityKey, capabilityMap);
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
     return capabilityMapping;
   }
 
                                                          List<Map<String, RequirementDefinition>>
                                                              requirementsList,
                                                          String templateName) {
-    mdcDataDebugMessage.debugEntryMessage(null, null);
+    mdcDataDebugMessage.debugEntryMessage(null);
 
-    if (requirementsList == null || requirementsList.size() == 0) {
+    if (CollectionUtils.isEmpty(requirementsList)) {
       return;
     }
 
       }
     }
 
-    mdcDataDebugMessage.debugExitMessage(null, null);
+    mdcDataDebugMessage.debugExitMessage(null);
   }
 
-  public static boolean isNodeTemplateSectionMissingFromServiceTemplate(ServiceTemplate serviceTemplate){
-    return Objects.isNull(serviceTemplate.getTopology_template() )
+  public static boolean isNodeTemplateSectionMissingFromServiceTemplate(
+      ServiceTemplate serviceTemplate) {
+    return Objects.isNull(serviceTemplate.getTopology_template())
         || MapUtils.isEmpty(serviceTemplate.getTopology_template().getNode_templates());
   }
 }