summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java53
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/test/utils/InterfaceOperationTestUtils.java5
2 files changed, 54 insertions, 4 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java
index 36dd5d9796..156d280a6e 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtilTest.java
@@ -24,13 +24,11 @@ import static org.openecomp.sdc.be.tosca.utils.InterfacesOperationsToscaUtil.add
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -236,6 +234,54 @@ public class InterfacesOperationsToscaUtilTest {
validateOperationInputs(mainYaml, 2, "name_for_op_1");
}
+ @Test
+ public void addInterfaceDefinitionElementInputMappedToOtherOperationOutputFromOtherInterface() {
+ String addedInterfaceType = "com.some.resource.or.other.resourceNameInputMappedToOutput";
+ Component component = new Resource();
+ component.setNormalizedName("normalizedComponentName");
+ InterfaceDefinition addedInterface = new InterfaceDefinition();
+ addedInterface.setType(addedInterfaceType);
+ addOperationsToInterface(component, addedInterface, 2, 2, true, true);
+ addedInterface.getOperationsMap().values().stream()
+ .filter(operationInputDefinition -> operationInputDefinition.getName().equalsIgnoreCase(
+ "name_for_op_0"))
+ .forEach(operation -> operation.getInputs().getListToscaDataDefinition().stream()
+ .filter(opInputDef -> opInputDef.getName().contains("integer"))
+ .forEach(opInputDef -> opInputDef.setInputId(
+ addedInterfaceType +".name_for_op_1.output_integer_1")));
+ //Mapping to operation from another interface
+ String secondInterfaceType = "org.test.lifecycle.standard.interfaceType.second";
+ InterfaceDefinition secondInterface = new InterfaceDefinition();
+ secondInterface.setType(secondInterfaceType);
+ addOperationsToInterface(component, secondInterface, 2, 2, true, true);
+ secondInterface.getOperationsMap().values().stream()
+ .filter(operationInputDefinition -> operationInputDefinition.getName().equalsIgnoreCase(
+ "name_for_op_0"))
+ .forEach(operation -> operation.getInputs().getListToscaDataDefinition().stream()
+ .filter(opInputDef -> opInputDef.getName().contains("integer"))
+ .forEach(opInputDef -> opInputDef.setInputId(
+ addedInterfaceType +".name_for_op_1.output_integer_1")));
+ component.setInterfaces(new HashMap<>());
+ component.getInterfaces().put(addedInterfaceType, addedInterface);
+ component.getInterfaces().put(secondInterfaceType, secondInterface);
+
+ ToscaNodeType nodeType = new ToscaNodeType();
+ addInterfaceDefinitionElement(component, nodeType, false);
+
+ ToscaExportHandler handler = new ToscaExportHandler(null,null,null,null,null,null, 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 = toscaRepresentation.getMainYaml();
+ Assert.assertFalse(mainYaml.contains("operations"));
+ Assert.assertTrue(mainYaml.contains("resourceNameInputMappedToOutput:"));
+ Assert.assertTrue(mainYaml.contains("inputs:"));
+ validateOperationInputs(mainYaml, 2, "name_for_op_1");
+ }
+
private void addOperationsToInterface(Component component, InterfaceDefinition addedInterface, int numOfOps,
int numOfInputsPerOp, boolean hasInputs, boolean hasOutputs) {
@@ -319,7 +365,8 @@ public class InterfacesOperationsToscaUtilTest {
for (Map.Entry<String, Object> operationEntry : interfaceDefinition.entrySet()) {
Object operationVal = operationEntry.getValue();
if (operationVal instanceof Map) {
- validateOperationInputDefinition((String) interfaceDefinition.get("type"), mappedOperationName,
+ //Since the inputs are mapped to output operations from only first interface so using that name
+ validateOperationInputDefinition(interfaces.keySet().iterator().next(), mappedOperationName,
operationVal);
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/test/utils/InterfaceOperationTestUtils.java b/catalog-be/src/test/java/org/openecomp/sdc/test/utils/InterfaceOperationTestUtils.java
index c614c6e6e9..1cc5b56ca9 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/test/utils/InterfaceOperationTestUtils.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/test/utils/InterfaceOperationTestUtils.java
@@ -18,7 +18,6 @@ package org.openecomp.sdc.test.utils;
import java.util.HashMap;
import java.util.Map;
-
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition;
@@ -87,6 +86,8 @@ public class InterfaceOperationTestUtils {
operationInputDefinition.setInputId("ComponentInput" + num + "_uniqueId");
operationInputDefinition.setValue(inputName + "_value");
operationInputDefinition.setDefaultValue(inputName + "_defaultValue");
+ operationInputDefinition.setType("string");
+ operationInputDefinition.setRequired(true);
return operationInputDefinition;
}
@@ -96,6 +97,8 @@ public class InterfaceOperationTestUtils {
operationOutputDefinition.setUniqueId(outputName + "_uniqueId");
operationOutputDefinition.setValue(outputName + "_value");
operationOutputDefinition.setDefaultValue(outputName + "_defaultValue");
+ operationOutputDefinition.setType("string");
+ operationOutputDefinition.setRequired(true);
return operationOutputDefinition;
}