aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2018-06-22 16:37:52 +0530
committerOren Kleks <orenkle@amdocs.com>2018-06-26 11:27:30 +0000
commit4720f5aea7d548701a832b965a2b0e38dbc3bc4a (patch)
tree0a85184267f75ccdb1a211a06f503616894c6472 /catalog-model/src
parent82c94daf74c08f111f6ce31c832df3f5583b14f7 (diff)
Add output parameter support in Operation screen
Added code to support Output parameter, fixed UTs, Added flow test Change-Id: I4ff869d120cefd7645a407278caeea6ee695c73b Issue-ID: SDC-1440 Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
Diffstat (limited to 'catalog-model/src')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Operation.java5
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java28
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationTest.java2
3 files changed, 31 insertions, 4 deletions
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 066cd67fec..4455920d3d 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
@@ -24,6 +24,7 @@ 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.elements.OperationOutputDefinition;
/**
* Defines an operation available to manage particular aspects of the Node Type.
@@ -54,10 +55,12 @@ public class Operation extends OperationDataDefinition implements IOperationPara
}
public Operation(ArtifactDataDefinition implementation, String description,
- ListDataDefinition<OperationInputDefinition> inputs) {
+ ListDataDefinition<OperationInputDefinition> inputs,
+ ListDataDefinition<OperationOutputDefinition> outputs) {
super(description);
setImplementation(implementation);
setInputs(inputs);
+ setOutputs(outputs);
}
@Override
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java
index 6b22413d56..49f16946af 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java
@@ -29,6 +29,7 @@ import org.apache.commons.collections.MapUtils;
import org.openecomp.sdc.be.datatypes.elements.InputDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
+import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Operation;
@@ -82,12 +83,14 @@ public class InterfaceUtils {
}
InterfaceDefinition interfaceDefinition = optionalInterface.get();
interfaceDefinition.getOperationsMap().values().stream()
- .forEach(operation -> createInput(operation, resource.getInputs()));
+ .forEach(operation -> createInputOutput(operation, resource.getInputs()));
+
+
return interfaceDefinition.getOperationsMap();
}
- private static void createInput(Operation operation, List<InputDefinition> inputs) throws IllegalStateException {
+ private static void createInputOutput(Operation operation, List<InputDefinition> inputs) throws IllegalStateException {
ListDataDefinition<OperationInputDefinition> inputDefinitionListDataDefinition = operation.getInputs();
if (inputDefinitionListDataDefinition != null) {
return;
@@ -97,8 +100,20 @@ public class InterfaceUtils {
List<OperationInputDefinition> convertedInputs = listToscaDataDefinition.stream()
.map(input -> convertInput(input, inputs))
.collect(Collectors.toList());
+
+ ListDataDefinition<OperationOutputDefinition> outputDefinitionListDataDefinition = operation.getOutputs();
+ if (outputDefinitionListDataDefinition != null) {
+ return;
+ }
+ List<OperationOutputDefinition> outListToscaDefinition = outputDefinitionListDataDefinition
+ .getListToscaDataDefinition();
+ List<OperationOutputDefinition> convertedOutputs = outListToscaDefinition.stream()
+ .map(operationOutputDefinition -> convertOutput(operationOutputDefinition, inputs) )
+ .collect(Collectors.toList());
inputDefinitionListDataDefinition.getListToscaDataDefinition().clear();
inputDefinitionListDataDefinition.getListToscaDataDefinition().addAll(convertedInputs);
+ outputDefinitionListDataDefinition.getListToscaDataDefinition().clear();
+ outputDefinitionListDataDefinition.getListToscaDataDefinition().addAll(convertedOutputs);
}
private static OperationInputDefinition convertInput(OperationInputDefinition input,
@@ -111,6 +126,15 @@ public class InterfaceUtils {
throw new IllegalStateException("Could not find input :"+ input.getLabel());
}
+ private static OperationOutputDefinition convertOutput(OperationOutputDefinition output,
+ List<InputDefinition> outputs) throws IllegalStateException {
+ Optional<InputDefinition> anyOutputDefinition = outputs.stream()
+ .filter(inp -> inp.getUniqueId().equals(output.getUniqueId())).findAny();
+ if (anyOutputDefinition.isPresent()) {
+ return new OperationOutputDefinition(output.getLabel(),new InputDataDefinition(anyOutputDefinition.get()));
+ }
+ throw new IllegalStateException("Could not find output :"+ output.getLabel());
+ }
public static List<Operation> getOperationsFromInterface(Map<String, InterfaceDefinition> interfaces) {
List<Operation> operationData = new ArrayList<>();
if (!MapUtils.isEmpty(interfaces)) {
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationTest.java
index 8ff412960e..088a1f4d89 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationTest.java
@@ -14,7 +14,7 @@ public class OperationTest {
@Test
public void testCtor() throws Exception {
new Operation(new OperationDataDefinition());
- new Operation(new ArtifactDataDefinition(), "mock", new ListDataDefinition<>());
+ new Operation(new ArtifactDataDefinition(), "mock", new ListDataDefinition<>(), new ListDataDefinition<>());
}
@Test