From 4a01181974575ada4348359788d47313616c33a3 Mon Sep 17 00:00:00 2001 From: vasraz Date: Wed, 20 May 2020 17:27:25 +0100 Subject: Add interface inputs handling Enables interface inputs specified in a node_type to be imported and included in the generated csar Signed-off-by: Vasyl Razinkov Change-Id: Ia3acaad50b4091831d0c0471b07ba2b2e9bd380d Issue-ID: SDC-3077 --- .../sdc/be/components/impl/ImportUtils.java | 1 + .../be/components/impl/ResourceImportManager.java | 126 ++++++++++++++++----- .../java/org/openecomp/sdc/be/tosca/CsarUtils.java | 34 ++++-- .../openecomp/sdc/be/tosca/ToscaExportHandler.java | 30 ++++- .../sdc/be/tosca/utils/OperationArtifactUtil.java | 61 +++++----- .../be/components/ResourceImportManagerTest.java | 2 +- 6 files changed, 178 insertions(+), 76 deletions(-) diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java index 687b18ecf6..cc6b359098 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java @@ -170,6 +170,7 @@ public final class ImportUtils { public static final String UI_JSON_PAYLOAD_NAME = "payloadName"; public static final String CVFC_DESCRIPTION = "Complex node type that is used as nested type in VF"; public static final String ESCAPED_DOUBLE_QUOTE = "\""; + public static final String QUOTE = "'"; private Constants() {} } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java index 79543ce5cf..46942d96d4 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java @@ -22,7 +22,10 @@ package org.openecomp.sdc.be.components.impl; +import static org.openecomp.sdc.be.components.impl.ImportUtils.Constants.QUOTE; + import fj.data.Either; +import java.util.LinkedHashMap; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -40,7 +43,9 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; @@ -67,7 +72,9 @@ import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo; import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo; +import org.openecomp.sdc.be.tosca.utils.OperationArtifactUtil; import org.openecomp.sdc.be.utils.TypeUtils; +import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.util.ThreadLocalsHolder; import org.openecomp.sdc.common.util.ValidationUtils; @@ -93,8 +100,16 @@ import java.util.stream.Collectors; @Component("resourceImportManager") public class ResourceImportManager { + private static final Logger log = Logger.getLogger(ResourceImportManager.class); + static final Pattern PROPERTY_NAME_PATTERN_IGNORE_LENGTH = Pattern.compile("[\\w\\-\\_\\d\\:]+"); private static final String IMPLEMENTATION = "implementation"; + private static final String INPUTS = "inputs"; + private static final String TYPE = "type"; + private static final String DESCRIPTION = "description"; + private static final String REQUIRED = "required"; + private static final String DEFAULT = "default"; + private static final String STATUS = "status"; private ServletContext servletContext; @@ -103,15 +118,13 @@ public class ResourceImportManager { private InterfaceOperationBusinessLogic interfaceOperationBusinessLogic; private IGraphLockOperation graphLockOperation; - protected ToscaOperationFacade toscaOperationFacade; + private ToscaOperationFacade toscaOperationFacade; - protected final ComponentsUtils componentsUtils; + private final ComponentsUtils componentsUtils; private final CapabilityTypeOperation capabilityTypeOperation; private ResponseFormatManager responseFormatManager; - private static final Logger log = Logger.getLogger(ResourceImportManager.class); - @Autowired public ResourceImportManager(ComponentsUtils componentsUtils, CapabilityTypeOperation capabilityTypeOperation) { this.componentsUtils = componentsUtils; @@ -268,9 +281,8 @@ public class ResourceImportManager { } - void populateResourceFromYaml(String resourceYml, Resource resource) { + private void populateResourceFromYaml(String resourceYml, Resource resource) { @SuppressWarnings("unchecked") -// Either eitherResult = Either.left(true); Object ymlObj = new Yaml().load(resourceYml); if (ymlObj instanceof Map) { Map toscaJsonAll = (Map) ymlObj; @@ -331,42 +343,44 @@ public class ResourceImportManager { } private Either createModuleInterface(Object interfaceJson, Resource resource) { - InterfaceDefinition interf = new InterfaceDefinition(); + final InterfaceDefinition interf = new InterfaceDefinition(); Either result = Either.left(interf); try { if (interfaceJson instanceof String) { - String requirementJsonString = (String) interfaceJson; + final String requirementJsonString = (String) interfaceJson; interf.setType(requirementJsonString); - } - else if (interfaceJson instanceof Map && ResourceTypeEnum.VFC.equals(resource.getResourceType())) { - Map requirementJsonMap = (Map) interfaceJson; - Map operations = new HashMap<>(); + } else if (interfaceJson instanceof Map && ResourceTypeEnum.VFC.equals(resource.getResourceType())) { + final Map requirementJsonMap = (Map) interfaceJson; + final Map operations = new HashMap<>(); for (final Entry entry : requirementJsonMap.entrySet()) { - if (entryIsInterfaceType(entry)) { - String type = (String) requirementJsonMap.get(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName()); + if (entryIsInterfaceType(entry)) { + final String type = (String) requirementJsonMap + .get(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName()); interf.setType(type); interf.setUniqueId(type.toLowerCase()); - } else if (entryContainsImplementationForAKnownOperation(entry, interf.getType())){ - - OperationDataDefinition operation = new OperationDataDefinition(); - operation.setName(entry.getKey()); - - ArtifactDataDefinition implementation = new ArtifactDataDefinition(); - // Adding the artifact name in quotes to indicate that this is a literal value, rather than a reference to - // an SDC artifact - implementation.setArtifactName(Constants.ESCAPED_DOUBLE_QUOTE + ((Map)entry.getValue()).get(IMPLEMENTATION) + Constants.ESCAPED_DOUBLE_QUOTE); - operation.setImplementation(implementation); - - operations.put(entry.getKey(), operation); + } else if (entryContainsImplementationForAKnownOperation(entry, interf.getType())) { + + final OperationDataDefinition operation = new OperationDataDefinition(); + operation.setName(entry.getKey()); + + final Map entryValue = (Map) entry.getValue(); + if (entryValue.containsKey(IMPLEMENTATION)) { + operation.setImplementation(handleOperationImplementation(entry)); + } + if (entryValue.containsKey(INPUTS)) { + final Map interfaceInputs = (Map) entryValue + .get(ToscaTagNamesEnum.INPUTS.getElementName()); + operation.setInputs(handleInterfaceInput(interfaceInputs)); + } + operations.put(entry.getKey(), operation); } } if (!operations.isEmpty()) { - interf.setOperations(operations); + interf.setOperations(operations); } - } - else { + } else { result = Either.right(ResultStatusEnum.GENERAL_ERROR); } @@ -379,7 +393,58 @@ public class ResourceImportManager { return result; } - + + private ArtifactDataDefinition handleOperationImplementation(final Entry entry) { + final ArtifactDataDefinition implementation = new ArtifactDataDefinition(); + final String artifactName = ((Map) entry.getValue()).get(IMPLEMENTATION); + if (OperationArtifactUtil.artifactNameIsALiteralValue(artifactName)) { + implementation.setArtifactName(artifactName); + } else { + implementation.setArtifactName(QUOTE + artifactName + QUOTE); + } + return implementation; + } + + private ListDataDefinition handleInterfaceInput(final Map interfaceInputs) { + final ListDataDefinition inputs = new ListDataDefinition<>(); + for (final Entry interfaceInput : interfaceInputs.entrySet()) { + final OperationInputDefinition operationInput = new OperationInputDefinition(); + operationInput.setName(interfaceInput.getKey()); + if (interfaceInput.getValue() instanceof Map) { + final LinkedHashMap inputPropertyValue = + (LinkedHashMap) interfaceInput.getValue(); + log.info("createModuleInterface: i interfaceInput.getKey() {}, {} , {} ", + interfaceInput.getKey(), inputPropertyValue.keySet(), + inputPropertyValue.values()); + if (inputPropertyValue.get(TYPE) != null) { + operationInput.setType(inputPropertyValue.get(TYPE).toString()); + } + if (inputPropertyValue.get(DESCRIPTION) != null) { + operationInput.setDescription(inputPropertyValue.get(DESCRIPTION).toString()); + } + if (inputPropertyValue.get(REQUIRED) != null) { + operationInput.setRequired( + Boolean.getBoolean(inputPropertyValue.get(REQUIRED).toString())); + } + if (inputPropertyValue.get(DEFAULT) != null) { + operationInput.setToscaDefaultValue(inputPropertyValue.get(DEFAULT).toString()); + } + if (inputPropertyValue.get(STATUS) != null) { + operationInput.setStatus(inputPropertyValue.get(STATUS).toString()); + } + + } else if (interfaceInput.getValue() instanceof String) { + final String value = (String) interfaceInput.getValue(); + operationInput.setDefaultValue(value); + operationInput.setToscaDefaultValue(value); + operationInput.setValue(value); + } + inputs.getListToscaDataDefinition().add(operationInput); + inputs.add(operationInput); + } + return inputs; + } + private boolean entryIsInterfaceType(final Entry entry) { if(entry.getKey().equals(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName())) { if (entry.getValue() instanceof String) { @@ -992,5 +1057,4 @@ public class ResourceImportManager { this.auditingManager = auditingManager; } - } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java index 478cf28d2e..eaf6eb8ada 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java @@ -71,6 +71,7 @@ import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao; +import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; @@ -1052,34 +1053,41 @@ public class CsarUtils { private Either writeOperationsArtifactsToCsar(Component component, ZipOutputStream zipstream) { - if (checkComponentBeforeOperation(component)) return Either.left(zipstream); + if (checkComponentBeforeOperation(component)) { + return Either.left(zipstream); + } final Map interfaces = ((Resource) component).getInterfaces(); for (Map.Entry interfaceEntry : interfaces.entrySet()) { for (OperationDataDefinition operation : interfaceEntry.getValue().getOperations().values()) { try { - if (checkComponentBeforeWrite(component, interfaceEntry, operation)) continue; + if (checkComponentBeforeWrite(component, interfaceEntry, operation)) { + continue; + } final String artifactUUID = operation.getImplementation().getArtifactUUID(); + if (artifactUUID == null) { + continue; + } final Either artifactFromCassandra = getFromCassandra(artifactUUID); final String artifactName = operation.getImplementation().getArtifactName(); if (artifactFromCassandra.isRight()) { log.error(ARTIFACT_NAME_UNIQUE_ID, artifactName, artifactUUID); log.error("Failed to get {} payload from DB reason: {}", artifactName, - artifactFromCassandra.right().value()); + artifactFromCassandra.right().value()); return Either.right(componentsUtils.getResponseFormat( - ActionStatus.ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION, "Resource", - component.getUniqueId(), artifactName, artifactUUID)); + ActionStatus.ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION, "Resource", + component.getUniqueId(), artifactName, artifactUUID)); } final byte[] payloadData = artifactFromCassandra.left().value(); zipstream.putNextEntry(new ZipEntry(OperationArtifactUtil.createOperationArtifactPath( - component, null, operation,true))); + component, null, operation, true))); zipstream.write(payloadData); } catch (IOException e) { log.error("Component Name {}, Interface Name {}, Operation Name {}", component.getNormalizedName(), - interfaceEntry.getKey(), operation.getName()); + interfaceEntry.getKey(), operation.getName()); log.error("Error while writing the operation's artifacts to the CSAR " + "{}", e); return Either.right(componentsUtils - .getResponseFormat(ActionStatus.ERROR_DURING_CSAR_CREATION, "Resource", - component.getUniqueId())); + .getResponseFormat(ActionStatus.ERROR_DURING_CSAR_CREATION, "Resource", + component.getUniqueId())); } } } @@ -1087,19 +1095,21 @@ public class CsarUtils { } private boolean checkComponentBeforeWrite(Component component, Entry interfaceEntry, OperationDataDefinition operation) { - if (Objects.isNull(operation.getImplementation())) { + final ArtifactDataDefinition implementation = operation.getImplementation(); + if (Objects.isNull(implementation)) { log.debug("Component Name {}, Interface Id {}, Operation Name {} - no Operation Implementation found", component.getNormalizedName(), interfaceEntry.getValue().getUniqueId(), operation.getName()); return true; } - if (Objects.isNull(operation.getImplementation().getArtifactName())) { + final String artifactName = implementation.getArtifactName(); + if (Objects.isNull(artifactName)) { log.debug("Component Name {}, Interface Id {}, Operation Name {} - no artifact found", component.getNormalizedName(), interfaceEntry.getValue().getUniqueId(), operation.getName()); return true; } - if (operation.getImplementation().getArtifactName().startsWith(Constants.ESCAPED_DOUBLE_QUOTE) && operation.getImplementation().getArtifactName().endsWith(Constants.ESCAPED_DOUBLE_QUOTE)) { + if (OperationArtifactUtil.artifactNameIsALiteralValue(artifactName)) { log.debug("Component Name {}, Interface Id {}, Operation Name {} - artifact name is a literal value rather than an SDC artifact", component.getNormalizedName(), interfaceEntry.getValue().getUniqueId(), operation.getName()); 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 92e9913e65..a492f01953 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 @@ -33,6 +33,7 @@ import java.beans.IntrospectionException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -125,6 +126,8 @@ import org.yaml.snakeyaml.representer.Representer; @org.springframework.stereotype.Component("tosca-export-handler") public class ToscaExportHandler { + private static final Logger log = Logger.getLogger(ToscaExportHandler.class); + private ApplicationDataTypeCache dataTypeCache; private ToscaOperationFacade toscaOperationFacade; private CapabilityRequirementConverter capabilityRequirementConverter; @@ -152,9 +155,6 @@ public class ToscaExportHandler { this.interfacesOperationsConverter = interfacesOperationsConverter; } - - private static final Logger log = Logger.getLogger(ToscaExportHandler.class); - private static final String TOSCA_VERSION = "tosca_simple_yaml_1_1"; private static final String SERVICE_NODE_TYPE_PREFIX = "org.openecomp.service."; private static final String IMPORTS_FILE_KEY = "file"; @@ -1529,12 +1529,35 @@ public class ToscaExportHandler { if ("dependencies".equals(property.getName())) { return null; } + removeDefaultP(propertyValue); NodeTuple defaultNode = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag); return "_defaultp_".equals(property.getName()) ? new NodeTuple(representData("default"), defaultNode.getValueNode()) : defaultNode; } + private void removeDefaultP(final Object propertyValue) { + if (propertyValue instanceof Map) { + final Map mapPropertyValue = ((Map) propertyValue); + + final Iterator iter = mapPropertyValue.entrySet().iterator(); + Object defaultValue = null; + while (iter.hasNext()) { + final Map.Entry entry = iter.next(); + + if ("_defaultp_".equals(entry.getKey())) { + defaultValue = entry.getValue(); + iter.remove(); + } else if (entry.getValue() instanceof Map) { + removeDefaultP(entry.getValue()); + } + } + if (defaultValue != null) { + mapPropertyValue.putIfAbsent("default", defaultValue); + } + } + } + @Override protected MappingNode representJavaBean(Set properties, Object javaBean) { // remove the bean type from the output yaml (!! ...) @@ -1637,4 +1660,3 @@ public class ToscaExportHandler { .forEach(operations -> operations.values().forEach(operation -> operation.setImplementation(null))); } } - diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java index 08e4406d6a..f6a76919f6 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java @@ -49,69 +49,73 @@ public class OperationArtifactUtil { } /** - * This method assumes that operation.getImplementation() is not NULL ( it should be verified by the caller method) + * This method assumes that operation.getImplementation() is not NULL ( it should be verified by the caller + * method) * - * @param operation the specific operation name + * @param operation the specific operation name * @return the full path including file name for operation's artifacts */ public static String createOperationArtifactPath(Component component, ComponentInstance componentInstance, - OperationDataDefinition operation, boolean isAssociatedComponent) { + OperationDataDefinition operation, boolean isAssociatedComponent) { if (!(component instanceof Resource || component instanceof Service)) { return null; } if (isAssociatedComponent) { // Service Proxy is only in Node Template interface - if(componentInstance != null) { + if (componentInstance != null) { return createOperationArtifactPathInService(componentInstance.getToscaComponentName() - + "_v" + componentInstance.getComponentVersion(), operation); + + "_v" + componentInstance.getComponentVersion(), operation); } // Resource Instance is part of Node Type interface else { ResourceMetadataDataDefinition resourceMetadataDataDefinition = - (ResourceMetadataDataDefinition) component.getComponentMetadataDefinition().getMetadataDataDefinition(); + (ResourceMetadataDataDefinition) component.getComponentMetadataDefinition() + .getMetadataDataDefinition(); return createOperationArtifactPathInService(resourceMetadataDataDefinition.getToscaResourceName() - + "_v" + component.getVersion(), operation); + + "_v" + component.getVersion(), operation); } } return createOperationArtifactPathInComponent(operation); } - private static String createOperationArtifactPathInComponent(OperationDataDefinition operation) { - if (artifactNameIsALiteralValue(operation.getImplementation().getArtifactName())) { - final String implementationArtifactName = operation.getImplementation().getArtifactName(); - return implementationArtifactName.substring(1, implementationArtifactName.length()-1); - } else { - return CsarUtils.ARTIFACTS + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) - + File.separator + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH - + File.separator + operation.getImplementation().getArtifactName(); - } + final String implementationArtifactName = operation.getImplementation().getArtifactName(); + if (artifactNameIsALiteralValue(implementationArtifactName)) { + return implementationArtifactName.substring(1, implementationArtifactName.length()-1); + } else { + return CsarUtils.ARTIFACTS + File.separator + WordUtils + .capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) + + File.separator + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + + File.separator + implementationArtifactName; + } } - private static boolean artifactNameIsALiteralValue(final String artifactName) { - return artifactName.startsWith(Constants.ESCAPED_DOUBLE_QUOTE) && artifactName.endsWith(Constants.ESCAPED_DOUBLE_QUOTE); + public static boolean artifactNameIsALiteralValue(final String artifactName) { + return (artifactName.startsWith(Constants.QUOTE) || artifactName.startsWith(Constants.ESCAPED_DOUBLE_QUOTE)) + && (artifactName.endsWith(Constants.QUOTE) || artifactName.endsWith(Constants.ESCAPED_DOUBLE_QUOTE)); } private static String createOperationArtifactPathInService(String toscaComponentName, - OperationDataDefinition operation) { + OperationDataDefinition operation) { return CsarUtils.ARTIFACTS + File.separator + toscaComponentName + File.separator + - WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) + File.separator + - ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + - operation.getImplementation().getArtifactName(); + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) + File.separator + + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + + operation.getImplementation().getArtifactName(); } - public static Map getDistinctInterfaceOperationArtifactsByName(Component originComponent) { + public static Map getDistinctInterfaceOperationArtifactsByName( + Component originComponent) { Map distinctInterfaceArtifactsByName = new HashMap<>(); Map interfaces = originComponent.getInterfaces(); if (MapUtils.isEmpty(interfaces)) { return distinctInterfaceArtifactsByName; } Map interfaceArtifacts = interfaces.values().stream() - .flatMap(interfaceDefinition -> interfaceDefinition.getOperationsMap().values().stream()) - .map(Operation::getImplementationArtifact).filter(Objects::nonNull) - .collect(Collectors.toMap(ArtifactDataDefinition::getUniqueId, - artifactDefinition -> artifactDefinition, (a1, a2) -> a1)); + .flatMap(interfaceDefinition -> interfaceDefinition.getOperationsMap().values().stream()) + .map(Operation::getImplementationArtifact).filter(Objects::nonNull) + .collect(Collectors.toMap(ArtifactDataDefinition::getUniqueId, + artifactDefinition -> artifactDefinition, (a1, a2) -> a1)); if (MapUtils.isNotEmpty(interfaceArtifacts)) { Set artifactNameSet = new HashSet<>(); for (Map.Entry interfaceArtifactEntry : interfaceArtifacts.entrySet()) { @@ -120,11 +124,12 @@ public class OperationArtifactUtil { continue; } distinctInterfaceArtifactsByName.put(interfaceArtifactEntry.getKey(), - interfaceArtifactEntry.getValue()); + interfaceArtifactEntry.getValue()); artifactNameSet.add(artifactName); } } return distinctInterfaceArtifactsByName; } + } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java index 58d93fbfb8..b497253118 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java @@ -410,7 +410,7 @@ public class ResourceImportManagerTest { assertEquals(1, operations.size()); OperationDataDefinition operation = operations.get("configure"); - assertEquals("\"camunda/vnfConfigure\"", operation.getImplementation().getArtifactName()); + assertEquals("'camunda/vnfConfigure'", operation.getImplementation().getArtifactName()); } -- cgit 1.2.3-korg