From 36582b71676428a30810f206729d9a21cbd87f1a Mon Sep 17 00:00:00 2001 From: vasraz Date: Mon, 7 Nov 2022 22:10:37 +0000 Subject: [PATCH] Interface is formatted using extended notation when no implementation added at VFC level Signed-off-by: Vasyl Razinkov Change-Id: I4e6e6d61b851fe2efaa47c9f8fad0cb546f2fcb7 Issue-ID: SDC-4255 --- .../be/components/impl/ArtifactsBusinessLogic.java | 7 +-- .../java/org/openecomp/sdc/be/tosca/CsarUtils.java | 46 +++++----------- .../be/tosca/InterfacesOperationsConverter.java | 64 ++++++++++++---------- .../openecomp/sdc/be/tosca/ToscaExportHandler.java | 28 ++++------ .../tosca/InterfacesOperationsConverterTest.java | 8 +-- .../sdc/be/tosca/ToscaExportHandlerTest.java | 3 +- .../java/org/openecomp/sdc/be/model/Operation.java | 2 - .../openecomp/sdc/be/model/OperationInstance.java | 63 --------------------- .../sdc/be/model/OperationInstanceTest.java | 34 ------------ .../elements/OperationImplementation.java | 37 +------------ .../be/datatypes/elements/OperationInstance.java | 41 ++------------ 11 files changed, 71 insertions(+), 262 deletions(-) delete mode 100644 catalog-model/src/main/java/org/openecomp/sdc/be/model/OperationInstance.java delete mode 100644 catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInstanceTest.java diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index a978154224..9f5436d152 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java @@ -704,11 +704,10 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { new ArtifactOperationInfo(false, false, ArtifactOperationEnum.DOWNLOAD), artifactId, null, null, null, null, null, parentId, containerComponentType); ArtifactDefinition artifactDefinition; - Either insideValue = result; - if (insideValue.isLeft()) { - artifactDefinition = insideValue.left().value(); + if (result.isLeft()) { + artifactDefinition = result.left().value(); } else { - artifactDefinition = insideValue.right().value().getImplementationArtifact(); + artifactDefinition = result.right().value().getImplementationArtifact(); } // for tosca artifacts and heat env on VF level generated on download without saving if (artifactDefinition.getPayloadData() != null) { 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 81d9e5d077..6bfceb44fa 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 @@ -19,6 +19,8 @@ */ package org.openecomp.sdc.be.tosca; +import static org.openecomp.sdc.be.dao.api.ActionStatus.ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION; +import static org.openecomp.sdc.be.dao.api.ActionStatus.ERROR_DURING_CSAR_CREATION; import static org.openecomp.sdc.be.tosca.ComponentCache.MergeStrategy.overwriteIfSameVersions; import static org.openecomp.sdc.be.tosca.FJToVavrHelper.Try0.fromEither; @@ -116,9 +118,6 @@ import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; import org.yaml.snakeyaml.Yaml; -/** - * @author tg851x - */ @org.springframework.stereotype.Component("csar-utils") public class CsarUtils { @@ -195,7 +194,6 @@ public class CsarUtils { return matcher.group(0); } - private static F> iff(Predicate p, Function> ifTrue) { return l -> p.test(l) ? ifTrue.apply(l) : Either.left(l); } @@ -635,7 +633,7 @@ public class CsarUtils { String cassandraId = d.getMiddle(); Component childComponent = d.getRight(); Either entryData = getEntryData(cassandraId, childComponent).right() - .map(x -> componentsUtils.getResponseFormat(x)); + .map(componentsUtils::getResponseFormat); if (entryData.isRight()) { return Either.right(entryData.right().value()); } @@ -835,7 +833,7 @@ public class CsarUtils { } private Either getLatestSchemaFilesFromCassandra() { - String fto = getVersionFirstThreeOctets(); + String fto = versionFirstThreeOctets; return sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(fto, CONFORMANCE_LEVEL).right().map(schemaFilesFetchDBError(fto)).left() .bind(iff(List::isEmpty, () -> schemaFileFetchError(fto), s -> Either.left(s.iterator().next().getPayloadAsArray()))); } @@ -880,9 +878,9 @@ public class CsarUtils { return Either.right(componentsUtils.getResponseFormat(ActionStatus.TOSCA_SCHEMA_FILES_NOT_FOUND, firstThreeOctets, CONFORMANCE_LEVEL)); } - private Either getFromCassandra(String cassandraId) { + private Either getFromCassandra(String cassandraId) { return artifactCassandraDao.getArtifact(cassandraId).right().map(operationstatus -> { - log.info("Failed to fetch artifact from Cassandra by id {} error {}.", cassandraId, operationstatus); + log.info("Failed to fetch artifact from Cassandra by id {} error {}.", cassandraId, operationstatus); StorageOperationStatus storageStatus = DaoStatusConverter.convertCassandraStatusToStorageStatus(operationstatus); return componentsUtils.convertFromStorageResponse(storageStatus); }).left().map(DAOArtifactData::getDataAsArray); @@ -900,7 +898,6 @@ public class CsarUtils { private String createNsMfBlock0(String serviceName, String createdBy, String serviceVersion, String releaseTime, String serviceType, String description, String serviceTemplate, String hash) { final String block0template = "metadata??\n" + "ns_product_name: %s\n" + "ns_provider_id: %s\n" + "ns_package_version: %s\n" + - //"ns_create_date_time: %s\n" + "ns_release_data_time: %s\n" + "ns_type: %s\n" + "ns_package_description: %s\n\n" + "Source: %s\n" + "Algorithm: MD5\n" + "Hash: %s\n\n"; return String.format(block0template, serviceName, createdBy, serviceVersion, releaseTime, serviceType, description, serviceTemplate, hash); } @@ -921,9 +918,8 @@ public class CsarUtils { return Either.right(writeComponentArtifactsToSpecifiedPath.right().value()); } Map componentInstancesArtifacts = mainTypeAndCIArtifacts.getComponentInstancesArtifacts(); - Set keySet = componentInstancesArtifacts.keySet(); String currentPath = ARTIFACTS_PATH + RESOURCES_PATH; - for (String keyAssetName : keySet) { + for (String keyAssetName : componentInstancesArtifacts.keySet()) { ArtifactsInfo artifactsInfo = componentInstancesArtifacts.get(keyAssetName); String pathWithAssetName = currentPath + keyAssetName + PATH_DELIMITER; writeComponentArtifactsToSpecifiedPath = writeArtifactsInfoToSpecifiedPath(mainComponent, artifactsInfo, zipstream, pathWithAssetName, @@ -943,8 +939,7 @@ public class CsarUtils { if (checkComponentBeforeOperation(component)) { return Either.left(zipstream); } - final Map interfaces = ((Resource) component).getInterfaces(); - for (Map.Entry interfaceEntry : interfaces.entrySet()) { + for (Map.Entry interfaceEntry : ((Resource) component).getInterfaces().entrySet()) { for (OperationDataDefinition operation : interfaceEntry.getValue().getOperations().values()) { try { if (checkComponentBeforeWrite(component, interfaceEntry, operation)) { @@ -959,19 +954,16 @@ public class CsarUtils { if (artifactFromCassandra.isRight()) { log.error(ARTIFACT_NAME_UNIQUE_ID, artifactName, artifactUUID); log.error("Failed to get {} payload from DB reason: {}", artifactName, artifactFromCassandra.right().value()); - return Either.right(componentsUtils - .getResponseFormat(ActionStatus.ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION, "Resource", component.getUniqueId(), - artifactName, artifactUUID)); + return Either.right(componentsUtils.getResponseFormat( + 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))); - zipstream.write(payloadData); + zipstream.write(artifactFromCassandra.left().value()); } catch (IOException e) { log.error("Component Name {}, Interface Name {}, Operation Name {}", component.getNormalizedName(), 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())); + log.error("Error while writing the operation's artifacts to the CSAR", e); + return Either.right(componentsUtils.getResponseFormat(ERROR_DURING_CSAR_CREATION, "Resource", component.getUniqueId())); } } } @@ -1191,9 +1183,7 @@ public class CsarUtils { return result.toString(); } - private ComponentTypeArtifacts collectComponentTypeArtifacts( - Component fetchedComponent - ) { + private ComponentTypeArtifacts collectComponentTypeArtifacts(Component fetchedComponent) { ArtifactsInfo componentArtifacts = collectComponentArtifacts(fetchedComponent); ComponentTypeArtifacts componentArtifactsInfo = new ComponentTypeArtifacts(); if (componentArtifacts.isNotEmpty()) { @@ -1269,10 +1259,6 @@ public class CsarUtils { return Either.left(true); } - public String getVersionFirstThreeOctets() { - return versionFirstThreeOctets; - } - private Map> getComponentInstanceSpecificArtifacts(Map componentArtifacts, Map>> componentTypeArtifacts, ArtifactGroupTypeEnum artifactGroupTypeEnum) { @@ -1306,10 +1292,6 @@ public class CsarUtils { Map> informationalArtifactsByType = collectGroupArtifacts(informationalArtifacts); Map deploymentArtifacts = component.getDeploymentArtifacts(); Map> deploymentArtifactsByType = collectGroupArtifacts(deploymentArtifacts); - Map interfaceOperationArtifacts = - OperationArtifactUtil.getDistinctInterfaceOperationArtifactsByName(component); - Map> interfaceOperationArtifactsByType = collectGroupArtifacts( - interfaceOperationArtifacts); ArtifactsInfo artifactsInfo = new ArtifactsInfo(); if (!informationalArtifactsByType.isEmpty()) { artifactsInfo.addArtifactsToGroup(ArtifactGroupTypeEnum.INFORMATIONAL, informationalArtifactsByType); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java index ce5038771b..54e61da41a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java @@ -36,6 +36,7 @@ import org.apache.commons.collections.MapUtils; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; +import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.InputDataDefinition; import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition; import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition; @@ -151,12 +152,13 @@ public class InterfacesOperationsConverter { return toscaResourceName.substring(toscaResourceName.lastIndexOf(DOT) + 1); } - private static boolean isArtifactPresent(final OperationDataDefinition operationDataDefinition) { - return operationDataDefinition.getImplementation() != null && operationDataDefinition.getImplementation().getArtifactName() != null; + private boolean isArtifactPresent(final OperationDataDefinition operationDataDefinition) { + return operationDataDefinition.getImplementation() != null + && StringUtils.isNotEmpty(operationDataDefinition.getImplementation().getArtifactName()); } private static String getInputValue(final OperationInputDefinition input) { - String inputValue = input.getValue() == null ? input.getToscaDefaultValue(): input.getValue(); + String inputValue = input.getValue() == null ? input.getToscaDefaultValue() : input.getValue(); if (inputValue != null && inputValue.contains(ToscaFunctions.GET_OPERATION_OUTPUT.getFunctionName())) { Gson gson = new Gson(); Map> consumptionValue = gson.fromJson(inputValue, Map.class); @@ -223,18 +225,18 @@ public class InterfacesOperationsConverter { } private Map getInterfacesMap(Component component, Map dataTypes, boolean isAssociatedComponent) { - return getInterfacesMap(component, null, component.getInterfaces(), dataTypes, isAssociatedComponent, false); + return getInterfacesMap(component, null, component.getInterfaces(), dataTypes, isAssociatedComponent); } public Map getInterfacesMap(final Component component, final ComponentInstance componentInstance, final Map interfaces, final Map dataTypes, - final boolean isAssociatedComponent, final boolean isServiceProxyInterface) { + final boolean isAssociatedComponent) { if (MapUtils.isEmpty(interfaces)) { return null; } final Map toscaInterfaceDefinitions = new HashMap<>(); for (InterfaceDefinition interfaceDefinition : interfaces.values()) { - handleInterfaceOperations(component, componentInstance, dataTypes, isAssociatedComponent, isServiceProxyInterface, + handleInterfaceOperations(component, componentInstance, dataTypes, isAssociatedComponent, toscaInterfaceDefinitions, interfaceDefinition); } return toscaInterfaceDefinitions; @@ -242,13 +244,13 @@ public class InterfacesOperationsConverter { public Map getInterfacesMapFromComponentInstance(final Component component, final ComponentInstance componentInstance, final Map dataTypes, - final boolean isAssociatedComponent, final boolean isServiceProxyInterface) { + final boolean isAssociatedComponent) { final Map toscaInterfaceDefinitions = new HashMap<>(); final ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); for (final Map.Entry interfaceEntry : componentInstance.getInterfaces().entrySet()) { final InterfaceDefinition interfaceDefinition = objectMapper.convertValue(interfaceEntry.getValue(), InterfaceDefinition.class); - handleInterfaceOperations(component, componentInstance, dataTypes, isAssociatedComponent, isServiceProxyInterface, + handleInterfaceOperations(component, componentInstance, dataTypes, isAssociatedComponent, toscaInterfaceDefinitions, interfaceDefinition); } return toscaInterfaceDefinitions; @@ -256,7 +258,7 @@ public class InterfacesOperationsConverter { private void handleInterfaceOperations(final Component component, final ComponentInstance componentInstance, final Map dataTypes, final boolean isAssociatedComponent, - final boolean isServiceProxyInterface, final Map toscaInterfaceDefinitions, + final Map toscaInterfaceDefinitions, final InterfaceDefinition interfaceDefinition) { final String interfaceType; if (componentInstance != null && LOCAL_INTERFACE_TYPE.equals(interfaceDefinition.getType())) { @@ -280,7 +282,7 @@ public class InterfacesOperationsConverter { } toscaInterfaceDefinition.setOperations(toscaOperationMap); final Map interfaceInputMap = createInterfaceInputMap(interfaceDefinition, dataTypes); - if (!interfaceInputMap.isEmpty()) { + if (MapUtils.isNotEmpty(interfaceInputMap)) { toscaInterfaceDefinition.setInputs(interfaceInputMap); } final Map interfaceDefinitionAsMap = getObjectAsMap(toscaInterfaceDefinition); @@ -298,29 +300,31 @@ public class InterfacesOperationsConverter { final OperationDataDefinition operationDataDefinition, final ToscaLifecycleOperationDefinition toscaOperation, final Map dataTypes) { - if (operationDataDefinition.getImplementation() == null) { + final ArtifactDataDefinition implementation = operationDataDefinition.getImplementation(); + if (implementation == null) { return; } - final String operationArtifactPath; - final ToscaInterfaceOperationImplementation toscaInterfaceOperationImplementation = new ToscaInterfaceOperationImplementation(); - toscaInterfaceOperationImplementation.setPrimary(new ToscaArtifactDefinition()); - final ToscaArtifactDefinition toscaArtifactDefinition = toscaInterfaceOperationImplementation.getPrimary(); - if (isArtifactPresent(operationDataDefinition) && StringUtils.isNotEmpty(operationDataDefinition.getImplementation().getArtifactName())) { - operationArtifactPath = OperationArtifactUtil - .createOperationArtifactPath(component, componentInstance, operationDataDefinition, isAssociatedComponent); - toscaArtifactDefinition.setFile(operationArtifactPath); - toscaArtifactDefinition.setArtifact_version(!operationDataDefinition.getImplementation().getArtifactVersion() - .equals(NumberUtils.INTEGER_ZERO.toString()) ? operationDataDefinition.getImplementation().getArtifactVersion() : null); - toscaArtifactDefinition.setType(operationDataDefinition.getImplementation().getArtifactType()); - final Map propertiesMap = handleImplementationProperties(operationDataDefinition, dataTypes); - if (!propertiesMap.isEmpty()) { - toscaArtifactDefinition.setProperties(propertiesMap); + + if (isArtifactPresent(operationDataDefinition)) { + final String operationArtifactPath = + OperationArtifactUtil.createOperationArtifactPath(component, componentInstance, operationDataDefinition, isAssociatedComponent); + if (implementation.getArtifactType() != null) { + final ToscaArtifactDefinition toscaArtifactDefinition = new ToscaArtifactDefinition(); + toscaArtifactDefinition.setFile(operationArtifactPath); + final String artifactVersion = implementation.getArtifactVersion(); + toscaArtifactDefinition.setArtifact_version(!artifactVersion.equals(NumberUtils.INTEGER_ZERO.toString()) ? artifactVersion : null); + toscaArtifactDefinition.setType(implementation.getArtifactType()); + final Map propertiesMap = handleImplementationProperties(operationDataDefinition, dataTypes); + if (MapUtils.isNotEmpty(propertiesMap)) { + toscaArtifactDefinition.setProperties(propertiesMap); + } + final ToscaInterfaceOperationImplementation toscaInterfaceOperationImplementation = new ToscaInterfaceOperationImplementation(); + toscaInterfaceOperationImplementation.setPrimary(toscaArtifactDefinition); + toscaOperation.setImplementation(toscaInterfaceOperationImplementation); + } else { + toscaOperation.setImplementation( + StringUtils.isBlank(operationArtifactPath) || "null".equals(operationArtifactPath) ? null : operationArtifactPath); } - toscaOperation.setImplementation( - toscaArtifactDefinition.getType() != null ? toscaInterfaceOperationImplementation : operationArtifactPath); - } else { - toscaArtifactDefinition.setFile(operationDataDefinition.getImplementation().getArtifactName()); - toscaOperation.setImplementation(toscaInterfaceOperationImplementation); } } 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 5f21f52960..ff6d015d62 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 @@ -1071,28 +1071,22 @@ public class ToscaExportHandler { return intValue == null ? value : intValue; } - private void handleInstanceInterfaces( - Map> componentInstanceInterfaces, - ComponentInstance componentInstance, Map dataTypes, ToscaNodeTemplate nodeTemplate, - String instanceUniqueId, - Component parentComponent) { - - if (MapUtils.isEmpty(componentInstanceInterfaces) - || !componentInstanceInterfaces.containsKey(instanceUniqueId)) { + private void handleInstanceInterfaces(Map> componentInstanceInterfaces, + ComponentInstance componentInstance, Map dataTypes, + ToscaNodeTemplate nodeTemplate, String instanceUniqueId, Component parentComponent) { + + if (MapUtils.isEmpty(componentInstanceInterfaces) || !componentInstanceInterfaces.containsKey(instanceUniqueId)) { nodeTemplate.setInterfaces(null); return; } - final List currServiceInterfaces = - componentInstanceInterfaces.get(instanceUniqueId); + final List currServiceInterfaces = componentInstanceInterfaces.get(instanceUniqueId); final Map tmpInterfaces = new HashMap<>(); - currServiceInterfaces.forEach(instInterface -> tmpInterfaces.put(instInterface - .getUniqueId(), instInterface)); + currServiceInterfaces.forEach(instInterface -> tmpInterfaces.put(instInterface.getUniqueId(), instInterface)); final Map interfaceMap = interfacesOperationsConverter - .getInterfacesMap(parentComponent, componentInstance, tmpInterfaces, dataTypes, isComponentOfTypeServiceProxy(componentInstance), - isComponentOfTypeServiceProxy(componentInstance)); + .getInterfacesMap(parentComponent, componentInstance, tmpInterfaces, dataTypes, isComponentOfTypeServiceProxy(componentInstance)); interfacesOperationsConverter.removeInterfacesWithoutOperations(interfaceMap); nodeTemplate.setInterfaces(MapUtils.isEmpty(interfaceMap) ? null : interfaceMap); @@ -1342,8 +1336,7 @@ public class ToscaExportHandler { interfaceMap = proxyInterfaces.get(); } } else { - interfaceMap = interfacesOperationsConverter - .getInterfacesMapFromComponentInstance(proxyComponent, componentInstance, dataTypes, false, false); + interfaceMap = interfacesOperationsConverter.getInterfacesMapFromComponentInstance(proxyComponent, componentInstance, dataTypes, false); } interfacesOperationsConverter.removeInterfacesWithoutOperations(interfaceMap); @@ -1775,8 +1768,7 @@ public class ToscaExportHandler { // always available in the proxy node template removeOperationImplementationForProxyNodeType(proxyComponentInterfaces); - return Optional - .ofNullable(interfacesOperationsConverter.getInterfacesMap(proxyComponent, null, proxyComponentInterfaces, dataTypes, false, false)); + return Optional.ofNullable(interfacesOperationsConverter.getInterfacesMap(proxyComponent, null, proxyComponentInterfaces, dataTypes, false)); } private static class CustomRepresenter extends Representer { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java index caae11bdee..b3470561f2 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java @@ -208,7 +208,7 @@ class InterfacesOperationsConverterTest { final String interfaceType = "normalizedComponentName-interface"; component.setInterfaces(new HashMap<>()); component.getInterfaces().put(interfaceType, addedInterface); - final var interfacesMap = interfacesOperationsConverter.getInterfacesMap(component, null, component.getInterfaces(), null, false, true); + final var interfacesMap = interfacesOperationsConverter.getInterfacesMap(component, null, component.getInterfaces(), null, false); assertNotNull(interfacesMap); assertEquals(1, interfacesMap.size()); assertTrue(interfacesMap.containsKey("resourceName")); @@ -385,8 +385,7 @@ class InterfacesOperationsConverterTest { component.setInterfaces(new HashMap<>()); component.getInterfaces().put(interfaceName, interfaceDefinition); //when - Map interfacesMap = interfacesOperationsConverter - .getInterfacesMap(component, null, component.getInterfaces(), null, false, true); + Map interfacesMap = interfacesOperationsConverter.getInterfacesMap(component, null, component.getInterfaces(), null, false); //then assertTrue(interfacesMap.containsKey(interfaceName)); final Map actualInterfaceMap = (Map) interfacesMap.get(interfaceName); @@ -679,8 +678,7 @@ class InterfacesOperationsConverterTest { service.setInterfaces(Collections.singletonMap("NotLocal", new InterfaceDefinition("NotLocal", null, new HashMap<>()))); - Map resultMap = interfacesOperationsConverter.getInterfacesMap(service, null, - service.getInterfaces(), null, false, false); + Map resultMap = interfacesOperationsConverter.getInterfacesMap(service, null, service.getInterfaces(), null, false); assertTrue(MapUtils.isNotEmpty(resultMap) && resultMap.containsKey("NotLocal")); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java index 040907b3f0..736fcbcd7f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java @@ -172,8 +172,7 @@ class ToscaExportHandlerTest extends BaseConfDependent { void setUpMock() { MockitoAnnotations.openMocks(this); doReturn(new ToscaProperty()).when(propertyConvertor).convertProperty(any(), any(), eq(PROPERTY)); - doReturn(new HashMap()).when(interfacesOperationsConverter) - .getInterfacesMap(any(), isNull(), anyMap(), anyMap(), anyBoolean(), anyBoolean()); + doReturn(new HashMap()).when(interfacesOperationsConverter).getInterfacesMap(any(), isNull(), anyMap(), anyMap(), anyBoolean()); } private Resource getNewResource() { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Operation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Operation.java index 180f82cfff..92c7c5972d 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Operation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Operation.java @@ -38,8 +38,6 @@ public class Operation extends OperationDataDefinition implements IOperationPara *

* Jackson DeSerialization workaround constructor to create an operation with no arguments. *

- * - * @param emptyString The empty string provided by jackson. */ public Operation() { super(); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/OperationInstance.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/OperationInstance.java deleted file mode 100644 index 8a3f83f3ee..0000000000 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/OperationInstance.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright © 2016-2018 European Support Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openecomp.sdc.be.model; - -import java.util.Map; -import java.util.Objects; -import org.openecomp.sdc.be.datatypes.elements.OperationImplementation; - -public class OperationInstance/* extends Operation*/ { - - private OperationImplementation implementation; - private Map inputs; - - - public OperationImplementation getImplementation() { - return implementation; - } - - public void setImplementation(OperationImplementation implementation) { - this.implementation = implementation; - } - - public Map getInputs() { - return inputs; - } - - public void setInputs(Map inputs) { - this.inputs = inputs; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof OperationInstance)) { - return false; - } - OperationInstance that = (OperationInstance) o; - return Objects.equals(implementation, that.implementation) && - Objects.equals(inputs, that.inputs); - } - - @Override - public int hashCode() { - - return Objects.hash(implementation, inputs); - } -} - diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInstanceTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInstanceTest.java deleted file mode 100644 index 199f26500a..0000000000 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInstanceTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.sdc.be.model; - -import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEquals; -import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - -public class OperationInstanceTest { - @Test - public void shouldHaveValidGettersAndSetters() { - assertThat(OperationInstance.class, hasValidGettersAndSetters()); - assertThat(OperationInstance.class, hasValidBeanEquals()); - } -} \ No newline at end of file diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationImplementation.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationImplementation.java index 2364ff4e3b..6ce1c4d762 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationImplementation.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationImplementation.java @@ -16,46 +16,13 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.util.HashSet; import java.util.List; -import java.util.Objects; +import lombok.Data; +@Data public class OperationImplementation { private String primary; private List dependencies; - public String getPrimary() { - return primary; - } - - public void setPrimary(String primary) { - this.primary = primary; - } - - public List getDependencies() { - return dependencies; - } - - public void setDependencies(List dependencies) { - this.dependencies = dependencies; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof OperationImplementation)) { - return false; - } - OperationImplementation that = (OperationImplementation) o; - return Objects.equals(primary, that.primary) - && Objects.equals(new HashSet<>(dependencies), new HashSet<>(that.dependencies)); - } - - @Override - public int hashCode() { - return Objects.hash(primary, dependencies); - } } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInstance.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInstance.java index 80c86d8d78..1da482936b 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInstance.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInstance.java @@ -17,45 +17,12 @@ package org.openecomp.sdc.be.datatypes.elements; import java.util.Map; -import java.util.Objects; +import lombok.Data; + +@Data +public class OperationInstance { -public class OperationInstance/* extends Operation*/ { private OperationImplementation implementation; private Map inputs; - - public OperationImplementation getImplementation() { - return implementation; - } - - public void setImplementation(OperationImplementation implementation) { - this.implementation = implementation; - } - - public Map getInputs() { - return inputs; - } - - public void setInputs(Map inputs) { - this.inputs = inputs; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof OperationInstance)) { - return false; - } - OperationInstance that = (OperationInstance) o; - return Objects.equals(implementation, that.implementation) - && Objects.equals(inputs, that.inputs); - } - - @Override - public int hashCode() { - - return Objects.hash(implementation, inputs); - } } -- 2.16.6