summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2022-07-07 13:57:03 +0100
committerMichael Morris <michael.morris@est.tech>2022-07-13 11:23:36 +0000
commit2b1ecc236c86ba71ea749f1c127e29a9abe8cabe (patch)
tree1dec6cf08aa9f45d54e8860fad8d8a6cd982f615
parent578e7acb26fe807e593cbbdb9bbad51a0ffff277 (diff)
Service Import - Input appearing as a property
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I33fa543e3a1c40b7590334a6396634abbd5b536f Issue-ID: SDC-4079
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java75
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java223
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java197
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInputDefinition.java30
5 files changed, 181 insertions, 346 deletions
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 b689959572..e373f5d480 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
@@ -86,7 +86,7 @@ public class InterfacesOperationsConverter {
* @param component to work on
* @return the added element
*/
- public static Map<String, Object> addInterfaceTypeElement(Component component, List<String> allInterfaceTypes) {
+ public Map<String, Object> addInterfaceTypeElement(Component component, List<String> allInterfaceTypes) {
if (component instanceof Product) {
return null;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 91d2bd5336..069e4f366e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -22,15 +22,15 @@ package org.openecomp.sdc.be.tosca;
import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
import static org.apache.commons.collections.MapUtils.isNotEmpty;
import static org.openecomp.sdc.be.components.utils.PropertiesUtils.resolvePropertyValueFromInput;
-import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.addInterfaceTypeElement;
import static org.openecomp.sdc.tosca.datatypes.ToscaFunctions.GET_ATTRIBUTE;
import static org.openecomp.sdc.tosca.datatypes.ToscaFunctions.GET_INPUT;
import static org.openecomp.sdc.tosca.datatypes.ToscaFunctions.GET_PROPERTY;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.JsonParser;
+import com.google.common.primitives.Ints;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import com.google.gson.stream.JsonReader;
import fj.data.Either;
import java.io.StringReader;
@@ -52,7 +52,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
-import com.google.common.primitives.Ints;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.io.FilenameUtils;
@@ -234,7 +233,8 @@ public class ToscaExportHandler {
if (component.getDerivedFromGenericType() != null && !component.getDerivedFromGenericType()
.startsWith("org.openecomp.resource.abstract.nodes.")) {
final Either<Component, StorageOperationStatus> baseType = toscaOperationFacade
- .getByToscaResourceNameAndVersion(component.getDerivedFromGenericType(), component.getDerivedFromGenericVersion(), component.getModel());
+ .getByToscaResourceNameAndVersion(component.getDerivedFromGenericType(), component.getDerivedFromGenericVersion(),
+ component.getModel());
if (baseType.isLeft() && baseType.left().value() != null) {
addDependencies(imports, dependencies, baseType.left().value());
} else {
@@ -260,7 +260,7 @@ public class ToscaExportHandler {
return Either.left(toscaRepresentation);
}
- public ToscaRepresentation createToscaRepresentation(ToscaTemplate toscaTemplate) {
+ private ToscaRepresentation createToscaRepresentation(ToscaTemplate toscaTemplate) {
CustomRepresenter representer = new CustomRepresenter();
DumperOptions options = new DumperOptions();
options.setAllowReadOnlyProperties(false);
@@ -311,11 +311,11 @@ public class ToscaExportHandler {
}
}
- public List<Map<String, Map<String, String>>> getDefaultToscaImports(final String modelId) {
+ private List<Map<String, Map<String, String>>> getDefaultToscaImports(final String modelId) {
if (modelId == null) {
return getDefaultToscaImportConfig();
}
-
+
final List<ToscaImportByModel> allModelImports = modelOperation.findAllModelImports(modelId, true);
final List<Map<String, Map<String, String>>> importList = new ArrayList<>();
final Set<Path> addedPathList = new HashSet<>();
@@ -458,17 +458,17 @@ public class ToscaExportHandler {
throw new ToscaExportException("Could not convert substitution mapping requirements", requirements.right().value());
}
final Map<String, String[]> requirementMap = requirements.left().value();
- if (!requirementMap.isEmpty()) {
+ if (MapUtils.isNotEmpty(requirementMap)) {
substitutionMapping.setRequirements(requirementMap);
}
final Map<String, String[]> propertyMappingMap = buildSubstitutionMappingPropertyMapping(component);
- if (!propertyMappingMap.isEmpty()) {
+ if (MapUtils.isNotEmpty(propertyMappingMap)) {
substitutionMapping.setProperties(propertyMappingMap);
}
final Map<String, String[]> attributesMappingMap = buildSubstitutionMappingAttributesMapping(component);
- if (!attributesMappingMap.isEmpty()) {
+ if (MapUtils.isNotEmpty(attributesMappingMap)) {
substitutionMapping.setAttributes(attributesMappingMap);
}
@@ -782,23 +782,21 @@ public class ToscaExportHandler {
if (lifecycleTypeEither.isLeft()) {
List<String> allGlobalInterfaceTypes = lifecycleTypeEither.left().value().values().stream().map(InterfaceDataDefinition::getType)
.collect(Collectors.toList());
- toscaNode.setInterface_types(addInterfaceTypeElement(component, allGlobalInterfaceTypes));
+ toscaNode.setInterface_types(interfacesOperationsConverter.addInterfaceTypeElement(component, allGlobalInterfaceTypes));
}
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(component.getModel());
+ final var dataTypesEither = applicationDataTypeCache.getAll(component.getModel());
if (dataTypesEither.isRight()) {
log.debug("Failed to fetch all data types :", dataTypesEither.right().value());
return Either.right(ToscaError.GENERAL_ERROR);
}
Map<String, DataTypeDefinition> dataTypes = dataTypesEither.left().value();
List<InputDefinition> inputDef = component.getInputs();
- Map<String, ToscaProperty> mergedProperties = new HashMap<>();
interfacesOperationsConverter.addInterfaceDefinitionElement(component, toscaNodeType, dataTypes, isAssociatedComponent);
- addInputsToProperties(dataTypes, inputDef, mergedProperties);
- final Map<String, ToscaAttribute> toscaAttributeMap;
- toscaAttributeMap = convertToToscaAttributes(component.getAttributes(), dataTypes);
+ final var toscaAttributeMap = convertToToscaAttributes(component.getAttributes(), dataTypes);
if (!toscaAttributeMap.isEmpty()) {
toscaNodeType.setAttributes(toscaAttributeMap);
}
+ final var mergedProperties = convertInputsToProperties(dataTypes, inputDef, component.getUniqueId());
if (CollectionUtils.isNotEmpty(component.getProperties())) {
List<PropertyDefinition> properties = component.getProperties();
Map<String, ToscaProperty> convertedProperties = properties.stream()
@@ -827,7 +825,8 @@ public class ToscaExportHandler {
.collect(Collectors.toMap(
PropertyDataDefinition::getName,
s -> propertyConvertor.convertProperty(dataTypes, s, PropertyType.PROPERTY),
- (toscaPropertyTobeValidated, toscaProperty) -> validateToscaProperty(privateDataTypes, toscaPropertyTobeValidated, toscaProperty)
+ (toscaPropertyTobeValidated, toscaProperty) -> validateToscaProperty(privateDataTypes, toscaPropertyTobeValidated,
+ toscaProperty)
)));
}
toscaDataTypeMap.put(dataType.getName(), toscaDataType);
@@ -922,16 +921,16 @@ public class ToscaExportHandler {
if (MapUtils.isNotEmpty(componentInstance.getToscaArtifacts())) {
nodeTemplate.setArtifacts(convertToNodeTemplateArtifacts(componentInstance.getToscaArtifacts()));
}
- if (componentInstance.getMinOccurrences() != null && componentInstance.getMaxOccurrences()!= null){
+ if (componentInstance.getMinOccurrences() != null && componentInstance.getMaxOccurrences() != null) {
List<Object> occur = new ArrayList<>();
occur.add(parseToIntIfPossible(componentInstance.getMinOccurrences()));
occur.add(parseToIntIfPossible(componentInstance.getMaxOccurrences()));
nodeTemplate.setOccurrences(occur);
}
- if (componentInstance.getInstanceCount() != null){
+ if (componentInstance.getInstanceCount() != null) {
ObjectMapper objectMapper = new ObjectMapper();
Object obj = convertToToscaObject(componentInstance.getInstanceCount());
- if(obj != null) {
+ if (obj != null) {
Map<String, String> map = objectMapper.convertValue(obj, Map.class);
nodeTemplate.setInstance_count(map);
}
@@ -1040,7 +1039,7 @@ public class ToscaExportHandler {
return convertNodeTemplatesRes;
}
- public Object convertToToscaObject(String value) {
+ private Object convertToToscaObject(String value) {
try {
ToscaMapValueConverter mapConverterInst = ToscaMapValueConverter.getInstance();
JsonParser jsonParser = new JsonParser();
@@ -1105,7 +1104,8 @@ public class ToscaExportHandler {
List<ComponentInstanceInput> instanceInputsList = componentInstancesInputs.get(instanceUniqueId);
if (instanceInputsList != null) {
instanceInputsList.forEach(input -> {
- Supplier<String> supplier = () -> input.getValue() != null && !Objects.isNull(input.getValue()) ? input.getValue() : input.getDefaultValue();
+ Supplier<String> supplier = () -> input.getValue() != null && !Objects.isNull(input.getValue()) ? input.getValue()
+ : input.getDefaultValue();
propertyConvertor.convertAndAddValue(dataTypes, props, input, supplier);
});
}
@@ -1217,7 +1217,7 @@ public class ToscaExportHandler {
.map(InterfaceDataDefinition::getType)
.collect(Collectors.toList());
//Add interface types for local interfaces in the original service component for proxy
- Map<String, Object> localInterfaceTypes = addInterfaceTypeElement(serviceComponent,
+ Map<String, Object> localInterfaceTypes = interfacesOperationsConverter.addInterfaceTypeElement(serviceComponent,
allGlobalInterfaceTypes);
if (MapUtils.isNotEmpty(localInterfaceTypes)) {
proxyInterfaceTypes.putAll(localInterfaceTypes);
@@ -1312,7 +1312,8 @@ public class ToscaExportHandler {
String derivedFrom = ((Resource) origComponent).getToscaResourceName();
toscaNodeType.setDerived_from(derivedFrom);
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(origComponent.getModel());
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(
+ origComponent.getModel());
if (dataTypesEither.isRight()) {
log.debug("Failed to retrieve all data types {}", dataTypesEither.right().value());
}
@@ -1359,7 +1360,8 @@ public class ToscaExportHandler {
relations);
if (isNotEmpty(requirementDefinitionList)) {
try {
- final List<Map<String, ToscaTemplateRequirement>> toscaRequirements = buildRequirements(component, componentInstance, requirementDefinitionList, originComponent, componentCache);
+ final List<Map<String, ToscaTemplateRequirement>> toscaRequirements = buildRequirements(component, componentInstance,
+ requirementDefinitionList, originComponent, componentCache);
if (!toscaRequirements.isEmpty()) {
nodeTypeTemplate.setRequirements(toscaRequirements);
}
@@ -1528,7 +1530,7 @@ public class ToscaExportHandler {
String fromInstanceId) {
for (List<RequirementDefinition> reqList : reqMap.values()) {
Optional<RequirementDefinition> reqOpt = reqList.stream().filter(
- r -> isRequirementBelongToRelation(fromOriginComponent, reqAndRelationshipPair, r, fromInstanceId))
+ r -> isRequirementBelongToRelation(fromOriginComponent, reqAndRelationshipPair, r, fromInstanceId))
.findFirst();
if (reqOpt.isPresent()) {
return reqOpt;
@@ -1751,33 +1753,30 @@ public class ToscaExportHandler {
.collect(Collectors.toMap(outputName -> outputName, outputName -> new String[]{outputName}, (outputName1, outputName2) -> outputName1));
}
- Optional<Map<String, ToscaProperty>> getProxyNodeTypeProperties(Component proxyComponent, Map<String, DataTypeDefinition> dataTypes) {
+ private Optional<Map<String, ToscaProperty>> getProxyNodeTypeProperties(Component proxyComponent, Map<String, DataTypeDefinition> dataTypes) {
if (Objects.isNull(proxyComponent)) {
return Optional.empty();
}
- Map<String, ToscaProperty> proxyProperties = new HashMap<>();
- addInputsToProperties(dataTypes, proxyComponent.getInputs(), proxyProperties);
+ final var proxyProperties = convertInputsToProperties(dataTypes, proxyComponent.getInputs(), proxyComponent.getUniqueId());
if (CollectionUtils.isNotEmpty(proxyComponent.getProperties())) {
proxyProperties.putAll(proxyComponent.getProperties().stream()
.map(propertyDefinition -> resolvePropertyValueFromInput(propertyDefinition, proxyComponent.getInputs())).collect(Collectors
.toMap(PropertyDataDefinition::getName,
- property -> propertyConvertor.convertProperty(dataTypes, property, PropertyConvertor.PropertyType.PROPERTY))));
+ property -> propertyConvertor.convertProperty(dataTypes, property, PropertyType.PROPERTY))));
}
return MapUtils.isNotEmpty(proxyProperties) ? Optional.of(proxyProperties) : Optional.empty();
}
- void addInputsToProperties(Map<String, DataTypeDefinition> dataTypes, List<InputDefinition> componentInputs,
- Map<String, ToscaProperty> mergedProperties) {
+ private Map<String, ToscaProperty> convertInputsToProperties(Map<String, DataTypeDefinition> dataTypes, List<InputDefinition> componentInputs,
+ String componentUniqueId) {
if (CollectionUtils.isEmpty(componentInputs)) {
- return;
- }
- for (InputDefinition input : componentInputs) {
- ToscaProperty property = propertyConvertor.convertProperty(dataTypes, input, PropertyConvertor.PropertyType.INPUT);
- mergedProperties.put(input.getName(), property);
+ return new HashMap<>();
}
+ return componentInputs.stream().filter(input -> componentUniqueId.equals(input.getInstanceUniqueId()))
+ .collect(Collectors.toMap(InputDefinition::getName, i -> propertyConvertor.convertProperty(dataTypes, i, PropertyType.INPUT)));
}
- Optional<Map<String, Object>> getProxyNodeTypeInterfaces(Component proxyComponent, Map<String, DataTypeDefinition> dataTypes) {
+ private Optional<Map<String, Object>> getProxyNodeTypeInterfaces(Component proxyComponent, Map<String, DataTypeDefinition> dataTypes) {
if (Objects.isNull(proxyComponent) || MapUtils.isEmpty(proxyComponent.getInterfaces())) {
return Optional.empty();
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java
index e3e4590d0f..caae11bdee 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java
@@ -20,19 +20,15 @@
package org.openecomp.sdc.be.tosca;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.SELF;
-import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.addInterfaceTypeElement;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DEFAULT;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DESCRIPTION;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.INPUTS;
@@ -78,7 +74,6 @@ import org.openecomp.sdc.be.model.ServiceMetadataDefinition;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.tosca.model.ToscaInterfaceDefinition;
import org.openecomp.sdc.be.tosca.model.ToscaNodeType;
-import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
import org.openecomp.sdc.common.util.YamlToObjectConverter;
import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.yaml.snakeyaml.Yaml;
@@ -105,8 +100,7 @@ class InterfacesOperationsConverterTest {
@BeforeEach
public void setUpBeforeTest() {
- interfacesOperationsConverter =
- new InterfacesOperationsConverter(new PropertyConvertor());
+ interfacesOperationsConverter = new InterfacesOperationsConverter(new PropertyConvertor());
}
@Test
@@ -122,19 +116,14 @@ class InterfacesOperationsConverterTest {
final String interfaceType = "normalizedComponentName-interface";
component.setInterfaces(new HashMap<>());
component.getInterfaces().put(interfaceType, addedInterface);
- final Map<String, Object> interfaceTypeElement =
- addInterfaceTypeElement(component, new ArrayList<>());
+ final Map<String, Object> interfaceTypeElement = interfacesOperationsConverter.addInterfaceTypeElement(component, new ArrayList<>());
+ assertNotNull(interfaceTypeElement);
+ assertTrue(interfaceTypeElement.containsKey("org.openecomp.interfaces.node.lifecycle.NodeTypeName"));
+ Object o = interfaceTypeElement.get("org.openecomp.interfaces.node.lifecycle.NodeTypeName");
+ assertNotNull(o);
+ assertTrue(o instanceof Map);
+ assertEquals(7, ((Map) o).size());
- ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
- interfacesOperationsConverter, null);
- ToscaTemplate template = new ToscaTemplate("test");
- template.setInterface_types(interfaceTypeElement);
- final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
-
- assertTrue(all(
- containsAll("NodeTypeName"),
- containsNone("operations")
- ).apply(new String(toscaRepresentation.getMainYaml())));
}
@Test
@@ -150,19 +139,14 @@ class InterfacesOperationsConverterTest {
final String interfaceType = "normalizedServiceComponentName-interface";
component.setInterfaces(new HashMap<>());
component.getInterfaces().put(interfaceType, addedInterface);
- final Map<String, Object> interfaceTypeElement =
- addInterfaceTypeElement(component, new ArrayList<>());
-
- ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
- interfacesOperationsConverter, null);
- ToscaTemplate template = new ToscaTemplate("testService");
- template.setInterface_types(interfaceTypeElement);
- final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
+ final Map<String, Object> interfaceTypeElement = interfacesOperationsConverter.addInterfaceTypeElement(component, new ArrayList<>());
+ assertNotNull(interfaceTypeElement);
+ assertTrue(interfaceTypeElement.containsKey("org.openecomp.interfaces.node.lifecycle.NodeTypeName"));
+ Object o = interfaceTypeElement.get("org.openecomp.interfaces.node.lifecycle.NodeTypeName");
+ assertNotNull(o);
+ assertTrue(o instanceof Map);
+ assertEquals(7, ((Map) o).size());
- assertTrue(all(
- containsAll("NodeTypeName"),
- containsNone("operations")
- ).apply(new String(toscaRepresentation.getMainYaml())));
}
@Test
@@ -178,22 +162,15 @@ class InterfacesOperationsConverterTest {
component.getInterfaces().put(interfaceType, addedInterface);
ToscaNodeType nodeType = new ToscaNodeType();
interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, dataTypes, false);
+ Map<String, Object> interfaces = nodeType.getInterfaces();
+ assertNotNull(interfaces);
+ assertEquals(1, interfaces.size());
+ assertTrue(interfaces.containsKey("resourceName"));
+ Object resourceName = interfaces.get("resourceName");
+ assertNotNull(resourceName);
+ assertTrue(resourceName instanceof Map);
+ assertEquals(4, ((Map) resourceName).size());
- ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
- interfacesOperationsConverter, null);
- ToscaTemplate template = new ToscaTemplate(NODE_TYPE_NAME);
- Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- nodeTypes.put(NODE_TYPE_NAME, nodeType);
- template.setNode_types(nodeTypes);
- final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
-
- String mainYaml = new String(toscaRepresentation.getMainYaml());
- assertTrue(all(
- containsAll("resourceName:", "inputs:", "has description", MAPPED_PROPERTY_NAME, "com.some.resource.or.other.resourceName"),
- containsNone("operations", "defaultp")
- ).apply(mainYaml));
-
- validateOperationInputs(mainYaml, 2, null);
}
@Test
@@ -208,19 +185,15 @@ class InterfacesOperationsConverterTest {
component.getInterfaces().put(interfaceType, addedInterface);
ToscaNodeType nodeType = new ToscaNodeType();
interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, dataTypes, false);
+ Map<String, Object> interfaces = nodeType.getInterfaces();
+ assertNotNull(interfaces);
+ assertEquals(1, interfaces.size());
+ assertTrue(interfaces.containsKey("serviceName"));
+ Object resourceName = interfaces.get("serviceName");
+ assertNotNull(resourceName);
+ assertTrue(resourceName instanceof Map);
+ assertEquals(4, ((Map) resourceName).size());
- ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null, null, null);
- ToscaTemplate template = new ToscaTemplate("testService");
- Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- nodeTypes.put(NODE_TYPE_NAME, nodeType);
- template.setNode_types(nodeTypes);
- final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
- String mainYaml = new String(toscaRepresentation.getMainYaml());
- assertTrue(all(
- containsAll("serviceName", "inputs:", "has description", MAPPED_PROPERTY_NAME, "com.some.service.or.other.serviceName"),
- containsNone("operations", "defaultp")
- ).apply(mainYaml));
- validateOperationInputs(mainYaml, 2, null);
}
@@ -235,23 +208,15 @@ class InterfacesOperationsConverterTest {
final String interfaceType = "normalizedComponentName-interface";
component.setInterfaces(new HashMap<>());
component.getInterfaces().put(interfaceType, addedInterface);
- Map<String, Object> interfacesMap = interfacesOperationsConverter
- .getInterfacesMap(component, null, component.getInterfaces(), null, false, true);
- ToscaNodeType nodeType = new ToscaNodeType();
- nodeType.setInterfaces(interfacesMap);
- ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null, null, null);
- ToscaTemplate template = new ToscaTemplate(NODE_TYPE_NAME);
- Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- nodeTypes.put(NODE_TYPE_NAME, nodeType);
- template.setNode_types(nodeTypes);
- final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
-
- String mainYaml = new String(toscaRepresentation.getMainYaml());
- assertTrue(all(
- containsAll("resourceName:", "inputs:", "has description", MAPPED_PROPERTY_NAME, "com.some.resource.or.other.resourceName"),
- containsNone("operations", "defaultp")
- ).apply(mainYaml));
- validateServiceProxyOperationInputs(mainYaml);
+ final var interfacesMap = interfacesOperationsConverter.getInterfacesMap(component, null, component.getInterfaces(), null, false, true);
+ assertNotNull(interfacesMap);
+ assertEquals(1, interfacesMap.size());
+ assertTrue(interfacesMap.containsKey("resourceName"));
+ Object resourceName = interfacesMap.get("resourceName");
+ assertNotNull(resourceName);
+ assertTrue(resourceName instanceof Map);
+ assertEquals(4, ((Map) resourceName).size());
+
}
@Test
@@ -266,19 +231,15 @@ class InterfacesOperationsConverterTest {
component.getInterfaces().put(interfaceType, addedInterface);
ToscaNodeType nodeType = new ToscaNodeType();
interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, null, false);
+ Map<String, Object> interfaces = nodeType.getInterfaces();
+ assertNotNull(interfaces);
+ assertEquals(1, interfaces.size());
+ assertTrue(interfaces.containsKey("resourceNameNoInputs"));
+ Object resourceName = interfaces.get("resourceNameNoInputs");
+ assertNotNull(resourceName);
+ assertTrue(resourceName instanceof Map);
+ assertEquals(4, ((Map) resourceName).size());
- ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
- interfacesOperationsConverter, null);
- ToscaTemplate template = new ToscaTemplate("test");
- Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- nodeTypes.put("test", nodeType);
- template.setNode_types(nodeTypes);
- final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
-
- assertTrue(all(
- containsAll("resourceNameNoInputs", "has description", "com.some.resource.or.other.resourceName"),
- containsNone("operations", INPUT_NAME_PREFIX, "defaultp")
- ).apply(new String(toscaRepresentation.getMainYaml())));
}
@Test
@@ -300,20 +261,15 @@ class InterfacesOperationsConverterTest {
component.getInterfaces().put(addedInterfaceType, addedInterface);
ToscaNodeType nodeType = new ToscaNodeType();
interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, dataTypes, false);
+ Map<String, Object> interfaces = nodeType.getInterfaces();
+ assertNotNull(interfaces);
+ assertEquals(1, interfaces.size());
+ assertTrue(interfaces.containsKey("resourceNameInputMappedToOutput"));
+ Object resourceName = interfaces.get("resourceNameInputMappedToOutput");
+ assertNotNull(resourceName);
+ assertTrue(resourceName instanceof Map);
+ assertEquals(3, ((Map) resourceName).size());
- ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
- interfacesOperationsConverter, null);
- ToscaTemplate template = new ToscaTemplate("test");
- Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- nodeTypes.put("test", nodeType);
- template.setNode_types(nodeTypes);
- final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
- String mainYaml = new String(toscaRepresentation.getMainYaml());
- assertTrue(all(
- containsAll("resourceNameInputMappedToOutput:", "inputs:"),
- containsNone("operations")
- ).apply(mainYaml));
- validateOperationInputs(mainYaml, 2, "name_for_op_1");
}
@Test
@@ -323,6 +279,7 @@ class InterfacesOperationsConverterTest {
component.setNormalizedName("normalizedComponentName");
InterfaceDefinition addedInterface = new InterfaceDefinition();
addedInterface.setType(addedInterfaceType);
+ addedInterface.setToscaResourceName("com.some.resource.or.other.resourceName");
addOperationsToInterface(component, addedInterface, 2, 2, true, true);
addedInterface.getOperationsMap().values().stream()
.filter(operationInputDefinition -> operationInputDefinition.getName().equalsIgnoreCase(
@@ -335,6 +292,7 @@ class InterfacesOperationsConverterTest {
String secondInterfaceType = "org.test.lifecycle.standard.interfaceType.second";
InterfaceDefinition secondInterface = new InterfaceDefinition();
secondInterface.setType(secondInterfaceType);
+ secondInterface.setToscaResourceName("com.some.resource.or.other.resourceName");
addOperationsToInterface(component, secondInterface, 2, 2, true, true);
secondInterface.getOperationsMap().values().stream()
.filter(operationInputDefinition -> operationInputDefinition.getName().equalsIgnoreCase(
@@ -349,21 +307,21 @@ class InterfacesOperationsConverterTest {
ToscaNodeType nodeType = new ToscaNodeType();
interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, dataTypes, false);
+ Map<String, Object> interfaces = nodeType.getInterfaces();
+ assertNotNull(interfaces);
+ assertEquals(2, interfaces.size());
+ assertTrue(interfaces.containsKey("resourceNameInputMappedToOutput"));
+ Object resourceName = interfaces.get("resourceNameInputMappedToOutput");
+ assertNotNull(resourceName);
+ assertTrue(resourceName instanceof Map);
+ assertEquals(3, ((Map) resourceName).size());
- ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
- interfacesOperationsConverter, null);
- ToscaTemplate template = new ToscaTemplate("test");
- Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- nodeTypes.put("test", nodeType);
- template.setNode_types(nodeTypes);
- final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
+ assertTrue(interfaces.containsKey("second"));
+ resourceName = interfaces.get("second");
+ assertNotNull(resourceName);
+ assertTrue(resourceName instanceof Map);
+ assertEquals(3, ((Map) resourceName).size());
- String mainYaml = new String(toscaRepresentation.getMainYaml());
- assertTrue(all(
- containsAll("resourceNameInputMappedToOutput:", "inputs:"),
- containsNone("operations")
- ).apply(mainYaml));
- validateOperationInputs(mainYaml, 2, "name_for_op_1");
}
@Test
@@ -385,17 +343,15 @@ class InterfacesOperationsConverterTest {
component.getInterfaces().put(interfaceName, anInterfaceWithInput);
final ToscaNodeType nodeType = new ToscaNodeType();
interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, dataTypes, false);
- final ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null, null, null,
- interfacesOperationsConverter, null);
- final ToscaTemplate template = new ToscaTemplate("testService");
- final Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- nodeTypes.put(NODE_TYPE_NAME, nodeType);
- template.setNode_types(nodeTypes);
- final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
- final String toscaTemplateYaml = new String(toscaRepresentation.getMainYaml());
- assertThat(toscaTemplateYaml,
- allOf(containsString(INPUTS.getElementName() + ":"), containsString(input1Name), containsString(interfaceName)));
- validateInterfaceInputs(toscaTemplateYaml, interfaceName, inputMap);
+ Map<String, Object> interfaces = nodeType.getInterfaces();
+ assertNotNull(interfaces);
+ assertEquals(1, interfaces.size());
+ assertTrue(interfaces.containsKey("myInterfaceName"));
+ Object resourceName = interfaces.get("myInterfaceName");
+ assertNotNull(resourceName);
+ assertTrue(resourceName instanceof Map);
+ assertEquals(2, ((Map) resourceName).size());
+
}
@Test
@@ -442,12 +398,12 @@ class InterfacesOperationsConverterTest {
final Map<String, Object> actualArtifactImplementationMap = (Map<String, Object>) actualImplementationMap.get("primary");
assertTrue(actualArtifactImplementationMap.containsKey("properties"));
final Map<String, Object> actualArtifactPropertiesMap = (Map<String, Object>) actualArtifactImplementationMap.get("properties");
- assertEquals(actualArtifactPropertiesMap.keySet().size(), 1);
+ assertEquals(1, actualArtifactPropertiesMap.keySet().size());
assertTrue(actualArtifactPropertiesMap.containsKey(listOfStringProperty.getName()));
final Object expectedListObject = actualArtifactPropertiesMap.get(listOfStringProperty.getName());
assertTrue(expectedListObject instanceof List);
final List<String> expectedListOfStringPropValue = (List<String>) expectedListObject;
- assertEquals(expectedListOfStringPropValue.size(), 3);
+ assertEquals(3, expectedListOfStringPropValue.size());
assertTrue(expectedListOfStringPropValue.contains("value1"));
assertTrue(expectedListOfStringPropValue.contains("value2"));
assertTrue(expectedListOfStringPropValue.contains("value3"));
@@ -494,7 +450,9 @@ class InterfacesOperationsConverterTest {
}
@FunctionalInterface
- interface MainYamlAssertion extends Function<String, Boolean> {}
+ interface MainYamlAssertion extends Function<String, Boolean> {
+
+ }
private static Function<String, Boolean> all(MainYamlAssertion... fs) {
return s -> io.vavr.collection.List.of(fs).map(f -> f.apply(s)).fold(true, (l, r) -> l && r);
@@ -706,7 +664,7 @@ class InterfacesOperationsConverterTest {
service.getComponentMetadataDefinition().getMetadataDataDefinition().setSystemName("LocalInterface");
service.setInterfaces(Collections.singletonMap("Local", new InterfaceDefinition("Local", null, new HashMap<>())));
- Map<String, Object> resultMap = InterfacesOperationsConverter.addInterfaceTypeElement(service,
+ Map<String, Object> resultMap = interfacesOperationsConverter.addInterfaceTypeElement(service,
Collections.singletonList("org.openecomp.interfaces.node.lifecycle.Standard"));
assertTrue(MapUtils.isNotEmpty(resultMap)
@@ -732,14 +690,15 @@ class InterfacesOperationsConverterTest {
void testRemoveInterfacesWithoutOperationsEmptyMap() {
final Map<String, Object> interfaceMap = new HashMap<>();
interfacesOperationsConverter.removeInterfacesWithoutOperations(interfaceMap);
- assertThat(interfaceMap, is(anEmptyMap()));
+ assertNotNull(interfaceMap);
+ assertTrue(interfaceMap.isEmpty());
}
@Test
void testRemoveInterfacesWithoutOperationsNullParameter() {
final Map<String, Object> interfaceMap = null;
interfacesOperationsConverter.removeInterfacesWithoutOperations(interfaceMap);
- assertThat(interfaceMap, is(nullValue()));
+ assertNull(interfaceMap);
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
index 6a3810f102..040907b3f0 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
@@ -49,7 +49,6 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
import java.util.stream.Collectors;
import mockit.Deencapsulation;
import org.apache.commons.collections.MapUtils;
@@ -63,8 +62,6 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.components.utils.PropertyDataDefinitionBuilder;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition;
@@ -87,6 +84,7 @@ import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.GroupInstance;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RelationshipInfo;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
@@ -117,10 +115,12 @@ class ToscaExportHandlerTest extends BaseConfDependent {
private static final String COMPONENT_PROPERTY_NAME = "prop1";
private static final String COMPONENT_PROPERTY_TYPE = "string";
private static final String COMPONENT_INPUT_NAME = "input1";
+ private static final String COMPONENT_OUTPUT_NAME = "output1";
private static final String COMPONENT_INPUT_TYPE = "integer";
+ private static final String COMPONENT_OUTPUT_TYPE = "integer";
private static final String RESOURCE_NAME = "resource";
private static final String TOSCA_VERSION = "tosca_simple_yaml_1_1";
- private static final Map<String, DataTypeDefinition> DATA_TYPES = new HashMap<>();
+ private static final String LOCAL_INTERFACE_TYPE = "Local";
@InjectMocks
private ToscaExportHandler testSubject;
@@ -178,6 +178,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
private Resource getNewResource() {
Resource resource = new Resource();
+ resource.setUniqueId("resourceUniqueId");
List<CategoryDefinition> categories = new ArrayList<>();
CategoryDefinition category = new CategoryDefinition();
List<SubCategoryDefinition> subcategories = new ArrayList<>();
@@ -203,6 +204,13 @@ class ToscaExportHandlerTest extends BaseConfDependent {
category.setSubcategories(subcategories);
categories.add(category);
+ final List<PropertyDefinition> properties = new ArrayList<>();
+ properties.add(new PropertyDefinition());
+ resource.setProperties(properties);
+ Map<String, InterfaceDefinition> proxyInterfaces = new HashMap<>();
+ proxyInterfaces.put("Local", new InterfaceDefinition("Local", "desc", new HashMap<>()));
+ resource.setInterfaces(proxyInterfaces);
+
resource.setCategories(categories);
resource.setVersion("version");
resource.setVendorName("vendorName");
@@ -307,32 +315,24 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(capabilityRequirementConverter.convertRequirements(anyMap(), any(Resource.class),
any(ToscaNodeType.class))).thenAnswer(i -> Either.left(i.getArgument(2)));
- Either<ToscaTemplate, ToscaError> result = (Either<ToscaTemplate, ToscaError>) Deencapsulation
- .invoke(testSubject, "convertInterfaceNodeType", new HashMap<String, Component>(), component,
- new ToscaTemplate(TOSCA_VERSION), new HashMap<String, ToscaNodeType>(), false);
+ final var result = testSubject.convertInterfaceNodeType(new HashMap<String, Component>(), component,
+ new ToscaTemplate(TOSCA_VERSION), new HashMap<String, ToscaNodeType>(), false);
assertNotNull(result);
assertTrue(result.isLeft());
Map<String, ToscaNodeType> nodeTypeMap = result.left().value().getNode_types();
- assertEquals(1,nodeTypeMap.size());
+ assertNotNull(nodeTypeMap);
+ assertEquals(1, nodeTypeMap.size());
ToscaNodeType toscaNodeType = nodeTypeMap.values().iterator().next();
+ assertNotNull(toscaNodeType);
Map<String, ToscaProperty> propertyMap = toscaNodeType.getProperties();
// Check if inputs and properties in component are merged properly
- assertEquals(2, propertyMap.size());
- assertTrue(propertyMap.containsKey(COMPONENT_INPUT_NAME));
+ assertNotNull(propertyMap);
+ assertEquals(1, propertyMap.size());
+ assertFalse(propertyMap.containsKey(COMPONENT_INPUT_NAME));
assertTrue(propertyMap.containsKey(COMPONENT_PROPERTY_NAME));
}
@Test
- void testCreateToscaRepresentation() {
- ToscaTemplate toscaTemplate = new ToscaTemplate("");
- ToscaRepresentation result;
-
- // default test
- result = testSubject.createToscaRepresentation(toscaTemplate);
- assertNotNull(result);
- }
-
- @Test
void testGetDependencies() {
Component component = new Resource();
@@ -411,7 +411,6 @@ class ToscaExportHandlerTest extends BaseConfDependent {
void testConvertToscaTemplateWhenComponentContainsGroup() throws ToscaConversionException {
Component component = getNewResource();
ToscaTemplate toscaNode = new ToscaTemplate("");
- Either<ToscaTemplate, ToscaError> result;
component.setComponentInstances(new ArrayList<>());
List<GroupDefinition> groups = new ArrayList<>();
@@ -423,6 +422,16 @@ class ToscaExportHandlerTest extends BaseConfDependent {
groups.add(group);
component.setGroups(groups);
+ final var input = new InputDefinition();
+ input.setName(COMPONENT_INPUT_NAME);
+ input.setType(COMPONENT_INPUT_TYPE);
+ component.setInputs(Collections.singletonList(input));
+
+ final var output = new OutputDefinition();
+ output.setName(COMPONENT_OUTPUT_NAME);
+ output.setType(COMPONENT_OUTPUT_TYPE);
+ component.setOutputs(Collections.singletonList(output));
+
Map<String, String[]> substitutionMappingMap = new HashMap<>();
String[] array = {"value1", "value2"};
substitutionMappingMap.put("key", array);
@@ -444,7 +453,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
doReturn(map).when(outputConverter).convert(any(), any());
// test component contains group
- result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
+ final var result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode);
assertNotNull(result);
}
@@ -738,7 +747,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(toscaOperationFacade.getToscaFullElement("uid")).thenReturn(Either.left(component));
when(toscaOperationFacade.getToscaFullElement("sourceModelUid")).thenReturn(Either.left(component));
when(toscaOperationFacade.getLatestByName("serviceProxy", null)).thenReturn(Either.left(new Resource()));
- when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(new Resource()));
+ when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(getNewResource()));
final Map<String, String[]> substitutionMappingMap = new HashMap<>();
final String[] array = {"value1", "value2"};
@@ -862,7 +871,14 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(toscaOperationFacade.getToscaFullElement("uid")).thenReturn(Either.left(component));
when(toscaOperationFacade.getToscaFullElement("sourceModelUid")).thenReturn(Either.left(component));
when(toscaOperationFacade.getLatestByName("serviceProxy", null)).thenReturn(Either.left(new Resource()));
- when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(new Resource()));
+
+ Resource newResource = getNewResource();
+ InputDefinition input = new InputDefinition();
+ input.setName(COMPONENT_INPUT_NAME);
+ input.setType(COMPONENT_INPUT_TYPE);
+ newResource.setInputs(Collections.singletonList(input));
+
+ when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(newResource));
final Map<String, String[]> substitutionMappingMap = new HashMap<>();
final String[] array = {"value1", "value2"};
@@ -875,7 +891,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
.thenReturn(Either.left(Collections.emptyMap()));
// default test
- final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(component);
+ final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(newResource);
assertNotNull(toscaRepresentationToscaErrorEither);
}
@@ -1107,16 +1123,15 @@ class ToscaExportHandlerTest extends BaseConfDependent {
componentInstances.add(instance);
container.setComponentInstances(componentInstances);
- when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
- .thenReturn(Either.left(Collections.emptyMap()));
+ when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
Component proxyResource = new Resource();
Map<String, InterfaceDefinition> proxyInterfaces = new HashMap<>();
proxyInterfaces.put("Local", new InterfaceDefinition("Local", "desc", new HashMap<>()));
proxyResource.setInterfaces(proxyInterfaces);
- when(toscaOperationFacade.getToscaElement(any(String.class),
- any(ComponentParametersView.class)))
- .thenReturn(Either.left(proxyResource));
+ when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class))).thenReturn(Either.left(proxyResource));
+ when(interfacesOperationsConverter.addInterfaceTypeElement(any(Component.class), anyList()))
+ .thenReturn(Collections.singletonMap(LOCAL_INTERFACE_TYPE, new HashMap<>()));
result = Deencapsulation.invoke(testSubject, "createProxyInterfaceTypes", container);
assertNotNull(result);
@@ -1562,7 +1577,7 @@ class ToscaExportHandlerTest extends BaseConfDependent {
when(capabilityRequirementConverter.buildSubstitutedName(anyMap(), eq(fromOriginComponent), anyList(), eq("cap"), any(), any()))
.thenReturn(Either.left(builtCapabilityOrRequirementName));
when(capabilityRequirementConverter.buildSubstitutedName(anyMap(), eq(toOriginComponent), anyList(), eq("req"), any(), any()))
- .thenReturn(Either.left(builtCapabilityOrRequirementName));
+ .thenReturn(Either.left(builtCapabilityOrRequirementName));
final Map<String, ToscaTemplateRequirement> requirementMap = Deencapsulation
.invoke(testSubject, "buildRequirement", fromOriginComponent, toOriginComponent, capability, requirement,
@@ -1683,127 +1698,9 @@ class ToscaExportHandlerTest extends BaseConfDependent {
assertEquals("test_type", result.get("test_art").getType());
}
- @Test
- void testGetProxyNodeTypeInterfacesNoInterfaces() {
- Component service = new Service();
- Optional<Map<String, Object>> proxyNodeTypeInterfaces =
- testSubject.getProxyNodeTypeInterfaces(service, DATA_TYPES);
- assertFalse(proxyNodeTypeInterfaces.isPresent());
- }
-
- @Test
- void testGetProxyNodeTypeInterfaces() {
- Component service = getTestComponent();
- Optional<Map<String, Object>> proxyNodeTypeInterfaces =
- testSubject.getProxyNodeTypeInterfaces(service, DATA_TYPES);
- assertTrue(proxyNodeTypeInterfaces.isPresent());
- Map<String, Object> componentInterfaces = proxyNodeTypeInterfaces.get();
- assertNotNull(componentInterfaces);
- }
-
-
- @Test
- void testGetProxyNodeTypePropertiesComponentNull() {
- Optional<Map<String, ToscaProperty>> proxyNodeTypeProperties =
- testSubject.getProxyNodeTypeProperties(null, DATA_TYPES);
- assertFalse(proxyNodeTypeProperties.isPresent());
- }
-
- @Test
- void testGetProxyNodeTypePropertiesNoProperties() {
- Component service = new Service();
- Optional<Map<String, ToscaProperty>> proxyNodeTypeProperties =
- testSubject.getProxyNodeTypeProperties(service, DATA_TYPES);
- assertFalse(proxyNodeTypeProperties.isPresent());
- }
-
- @Test
- void testGetProxyNodeTypeProperties() {
- Component service = getTestComponent();
- service.setProperties(Arrays.asList(createMockProperty("componentPropStr", "Default String Prop"),
- createMockProperty("componentPropInt", null)));
- Optional<Map<String, ToscaProperty>> proxyNodeTypeProperties =
- testSubject.getProxyNodeTypeProperties(service, DATA_TYPES);
- assertTrue(proxyNodeTypeProperties.isPresent());
- Map<String, ToscaProperty> componentProperties = proxyNodeTypeProperties.get();
- assertNotNull(componentProperties);
- assertEquals(2, componentProperties.size());
- }
-
- @Test
- void testAddInputsToPropertiesNoInputs() {
- Component service = getTestComponent();
- service.setProperties(Arrays.asList(createMockProperty("componentPropStr", "Default String Prop"),
- createMockProperty("componentPropInt", null)));
- Optional<Map<String, ToscaProperty>> proxyNodeTypePropertiesResult =
- testSubject.getProxyNodeTypeProperties(service, DATA_TYPES);
-
- assertTrue(proxyNodeTypePropertiesResult.isPresent());
- Map<String, ToscaProperty> proxyNodeTypeProperties = proxyNodeTypePropertiesResult.get();
- testSubject.addInputsToProperties(DATA_TYPES, null, proxyNodeTypeProperties);
- assertNotNull(proxyNodeTypeProperties);
- assertEquals(2, proxyNodeTypeProperties.size());
- testSubject.addInputsToProperties(DATA_TYPES, new ArrayList<>(), proxyNodeTypeProperties);
- assertEquals(2, proxyNodeTypeProperties.size());
- }
-
- @Test
- void testAddInputsToPropertiesWithInputs() {
- Component service = getTestComponent();
- service.setProperties(Arrays.asList(createMockProperty("componentPropStr", "Default String Prop"),
- createMockProperty("componentPropInt", null)));
- service.setInputs(Arrays.asList(createMockInput("componentInputStr1",
- "Default String Input1"), createMockInput("componentInputStr2", "Default String Input2")));
- Optional<Map<String, ToscaProperty>> proxyNodeTypePropertiesResult =
- testSubject.getProxyNodeTypeProperties(service, DATA_TYPES);
-
- assertTrue(proxyNodeTypePropertiesResult.isPresent());
- Map<String, ToscaProperty> proxyNodeTypeProperties = proxyNodeTypePropertiesResult.get();
- testSubject.addInputsToProperties(DATA_TYPES, service.getInputs(), proxyNodeTypeProperties);
- assertNotNull(proxyNodeTypeProperties);
- assertEquals(4, proxyNodeTypeProperties.size());
- }
-
- @Test
- void testAddInputsToPropertiesOnlyInputs() {
- Component service = getTestComponent();
- service.setInputs(Arrays.asList(createMockInput("componentInputStr1",
- "Default String Input1"), createMockInput("componentInputStr2", "Default String Input2")));
- Optional<Map<String, ToscaProperty>> proxyNodeTypePropertiesResult =
- testSubject.getProxyNodeTypeProperties(service, DATA_TYPES);
-
- assertTrue(proxyNodeTypePropertiesResult.isPresent());
- Map<String, ToscaProperty> proxyNodeTypeProperties = proxyNodeTypePropertiesResult.get();
- testSubject.addInputsToProperties(DATA_TYPES, service.getInputs(), proxyNodeTypeProperties);
- assertNotNull(proxyNodeTypeProperties);
- assertEquals(2, proxyNodeTypeProperties.size());
- }
-
- @Test
- void testOperationImplementationInProxyNodeTypeNotPresent() {
- Component service = getTestComponent();
- InterfaceDefinition interfaceDefinition =
- service.getInterfaces().get("normalizedServiceComponentName-interface");
- interfaceDefinition.setOperations(new HashMap<>());
- final OperationDataDefinition operation = new OperationDataDefinition();
- operation.setName("start");
- operation.setDescription("op description");
- final ArtifactDataDefinition implementation = new ArtifactDataDefinition();
- implementation.setArtifactName("createBPMN.bpmn");
- operation.setImplementation(implementation);
- interfaceDefinition.getOperations().put(operation.getName(), operation);
- service.getInterfaces().put("normalizedServiceComponentName-interface", interfaceDefinition);
- service.setInputs(Arrays.asList(createMockInput("componentInputStr1",
- "Default String Input1"), createMockInput("componentInputStr2", "Default String Input2")));
- Optional<Map<String, Object>> proxyNodeTypeInterfaces =
- testSubject.getProxyNodeTypeInterfaces(service, DATA_TYPES);
- assertTrue(proxyNodeTypeInterfaces.isPresent());
- Map<String, Object> componentInterfaces = proxyNodeTypeInterfaces.get();
- assertNotNull(componentInterfaces);
- }
-
private Component getTestComponent() {
Component component = new Service();
+ component.setUniqueId("serviceUniqueId");
component.setNormalizedName("normalizedServiceComponentName");
InterfaceDefinition addedInterface = new InterfaceDefinition();
addedInterface.setType("com.some.service.or.other.serviceName");
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInputDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInputDefinition.java
index 0fcdd9ce36..62587ef94a 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInputDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationInputDefinition.java
@@ -15,12 +15,15 @@
*/
package org.openecomp.sdc.be.datatypes.elements;
-
import com.fasterxml.jackson.annotation.JsonCreator;
+import lombok.Getter;
+import lombok.Setter;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
-
+@Getter
+@Setter
public class OperationInputDefinition extends InputDataDefinition {
+
private String source;
private String sourceProperty;
private String toscaDefaultValue;
@@ -60,27 +63,4 @@ public class OperationInputDefinition extends InputDataDefinition {
setToscaPresentationValue(JsonPresentationFields.ARTIFACT_LABEL, name);
}
- public String getSource() {
- return source;
- }
-
- public void setSource(String source) {
- this.source = source;
- }
-
- public String getSourceProperty() {
- return sourceProperty;
- }
-
- public void setSourceProperty(String sourceProperty) {
- this.sourceProperty = sourceProperty;
- }
-
- public String getToscaDefaultValue() {
- return toscaDefaultValue;
- }
-
- public void setToscaDefaultValue(String toscaDefaultValue) {
- this.toscaDefaultValue = toscaDefaultValue;
- }
}