summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java49
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java22
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java16
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java40
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverterTest.java3
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java3
-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
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationDataDefinition.java9
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationOutputDefinition.java46
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java3
-rw-r--r--openecomp-bdd/features/InterfaceOperation/TestInterfaceOperation.feature18
-rw-r--r--openecomp-bdd/resources/json/operation/createOperation.json8
-rw-r--r--openecomp-bdd/stepDefinitions/InterfaceOperationSteps.js17
15 files changed, 249 insertions, 20 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java
index aa58c14227..e57c7b9496 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java
@@ -89,6 +89,13 @@ public class InterfaceOperationValidation {
if(inputParametersResponse.isRight()) {
return Either.right(inputParametersResponse.right().value());
}
+
+ Either<Boolean, ResponseFormat> outputParametersResponse = validateOutputParameters(interfaceOperation,
+ responseFormatManager);
+ if(outputParametersResponse.isRight()) {
+ return Either.right(outputParametersResponse.right().value());
+ }
+
return Either.left(Boolean.TRUE);
}
@@ -223,6 +230,28 @@ public class InterfaceOperationValidation {
return Either.left(Boolean.TRUE);
}
+
+ private Either<Boolean, ResponseFormat> validateOutputParameters(Operation interfaceOperation,
+ ResponseFormatManager responseFormatManager) {
+ if (isOutputParameterNameEmpty(interfaceOperation)) {
+ LOGGER.error("Interface operation output parameter name can't be empty");
+ ResponseFormat inputResponse = responseFormatManager.getResponseFormat(ActionStatus
+ .INTERFACE_OPERATION_OUTPUT_NAME_MANDATORY);
+ return Either.right(inputResponse);
+ }
+
+ Either<Boolean, Set<String>> validateOutputParametersUniqueResponse = isOutputParametersUnique(interfaceOperation);
+ if(validateOutputParametersUniqueResponse.isRight()) {
+ LOGGER.error("Interface operation output parameter names {} already in use",
+ validateOutputParametersUniqueResponse.right().value().toString());
+ ResponseFormat inputResponse = responseFormatManager.getResponseFormat(ActionStatus
+ .INTERFACE_OPERATION_OUTPUT_NAME_ALREADY_IN_USE, validateOutputParametersUniqueResponse.right().value().toString());
+ return Either.right(inputResponse);
+ }
+ return Either.left(Boolean.TRUE);
+ }
+
+
private Either<Boolean, Set<String>> isInputParametersUnique(Operation operationDataDefinition) {
Set<String> inputParamNamesSet = new HashSet<>();
Set<String> duplicateParamNamesToReturn = new HashSet<>();
@@ -238,11 +267,29 @@ public class InterfaceOperationValidation {
return Either.left(Boolean.TRUE);
}
+ private Either<Boolean, Set<String>> isOutputParametersUnique(Operation operationDataDefinition) {
+ Set<String> outputParamNamesSet = new HashSet<>();
+ Set<String> duplicateParamNamesToReturn = new HashSet<>();
+ operationDataDefinition.getOutputs().getListToscaDataDefinition()
+ .forEach(outputParam -> {
+ if(!outputParamNamesSet.add(outputParam.getName().trim())) {
+ duplicateParamNamesToReturn.add(outputParam.getName().trim());
+ }
+ });
+ if(!duplicateParamNamesToReturn.isEmpty()) {
+ return Either.right(duplicateParamNamesToReturn);
+ }
+ return Either.left(Boolean.TRUE);
+ }
+
private Boolean isInputParameterNameEmpty(Operation operationDataDefinition) {
return operationDataDefinition.getInputs().getListToscaDataDefinition().stream()
.anyMatch(inputParam -> inputParam.getName() == null || inputParam.getName().trim().equals(StringUtils.EMPTY));
}
-
+ private Boolean isOutputParameterNameEmpty(Operation operationDataDefinition) {
+ return operationDataDefinition.getInputs().getListToscaDataDefinition().stream()
+ .anyMatch(inputParam -> inputParam.getName() == null || inputParam.getName().trim().equals(StringUtils.EMPTY));
+ }
private boolean validateOperationTypeUniqueForUpdate(Operation interfaceOperation,
Map<String, String> operationTypes) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java
index 78b2354615..2db551643c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java
@@ -23,6 +23,7 @@ import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationParamDataDefinition;
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.Operation;
public class InterfaceUIDataConverter {
@@ -40,11 +41,21 @@ public class InterfaceUIDataConverter {
interfaceOperationParamDataDefinition.getParamId())).collect(Collectors.toList());
inputList.forEach(inputs::add);
}
+ ListDataDefinition<InterfaceOperationParamDataDefinition> outputParams = interfaceOperation.getOutputParams();
+ ListDataDefinition<OperationOutputDefinition> outputs = new ListDataDefinition<>();
+ if(outputParams != null) {
+ List<OperationOutputDefinition> outputList = outputParams.getListToscaDataDefinition().stream()
+ .map(interfaceOperationParamDataDefinition -> new OperationOutputDefinition(interfaceOperationParamDataDefinition.getParamName(),
+ interfaceOperationParamDataDefinition.getParamId())).collect(Collectors.toList());
+ outputList.forEach(outputs::add);
+ }
+
Operation operationData = new Operation();
operationData.setDescription(interfaceOperation.getDescription());
operationData.setName(interfaceOperation.getOperationType());
operationData.setUniqueId(interfaceOperation.getUniqueId());
operationData.setInputs(inputs);
+ operationData.setOutputs(outputs);
return operationData;
}
@@ -53,16 +64,25 @@ public class InterfaceUIDataConverter {
ListDataDefinition<OperationInputDefinition> inputs = operationData.getInputs();
List<InterfaceOperationParamDataDefinition> inputParamList = inputs.getListToscaDataDefinition().stream()
- .map(a -> new InterfaceOperationParamDataDefinition(a.getName(), a.getInputId())).collect(
+ .map(operationInputDefinition -> new InterfaceOperationParamDataDefinition(operationInputDefinition.getName(),
+ operationInputDefinition.getInputId())).collect(
Collectors.toList());
ListDataDefinition<InterfaceOperationParamDataDefinition> inputParams = new ListDataDefinition<>();
inputParamList.forEach(inputParams::add);
+ ListDataDefinition<OperationOutputDefinition> outputs = operationData.getOutputs();
+ List<InterfaceOperationParamDataDefinition> outputParamList = outputs.getListToscaDataDefinition()
+ .stream().map(operationOutputDefinition -> new InterfaceOperationParamDataDefinition(operationOutputDefinition.getName(),
+ operationOutputDefinition.getInputId())).collect(Collectors.toList());
+ ListDataDefinition<InterfaceOperationParamDataDefinition> outputParams = new ListDataDefinition<>();
+ outputParamList.forEach(outputParams::add);
+
InterfaceOperationDataDefinition interfaceOperationDataDefinition = new InterfaceOperationDataDefinition();
interfaceOperationDataDefinition.setUniqueId(operationData.getUniqueId());
interfaceOperationDataDefinition.setOperationType(operationData.getName());
interfaceOperationDataDefinition.setDescription(operationData.getDescription());
interfaceOperationDataDefinition.setInputParams(inputParams);
+ interfaceOperationDataDefinition.setOutputParams(outputParams);
interfaceOperationDataDefinition.setArtifactUUID(operationData.getImplementation().getArtifactUUID());
return interfaceOperationDataDefinition;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java
index f38848c1be..cf3d5d5bdc 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/InterfaceOperationTestUtils.java
@@ -21,6 +21,7 @@ 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;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Operation;
@@ -46,13 +47,15 @@ public interface InterfaceOperationTestUtils {
default Operation createInterfaceOperation(String uniqueID, String description, ArtifactDefinition artifactDefinition,
- ListDataDefinition<OperationInputDefinition> inputs, String name) {
+ ListDataDefinition<OperationInputDefinition> inputs,
+ ListDataDefinition<OperationOutputDefinition> outputs, String name) {
Operation operation = new Operation();
operation.setUniqueId(uniqueID);
operation.setDescription(description);
operation.setImplementation(artifactDefinition);
operation.setInputs(inputs);
+ operation.setOutputs(outputs);
operation.setName(name);
return operation;
@@ -65,6 +68,10 @@ public interface InterfaceOperationTestUtils {
operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
operation.setInputs(operationInputDefinitionList);
+ ListDataDefinition<OperationOutputDefinition> operationOutputDefList = new ListDataDefinition<>();
+ operationOutputDefList.add(createMockOperationOutputDefinition("op1"));
+ operation.setOutputs(operationOutputDefList);
+
operation.setDefinition(false);
operation.setName("CREATE");
operation.setUniqueId("uniqueId1");
@@ -85,6 +92,13 @@ public interface InterfaceOperationTestUtils {
return operationInputDefinition;
}
+ default OperationOutputDefinition createMockOperationOutputDefinition(String name) {
+ OperationOutputDefinition operationOutputDefinition = new OperationOutputDefinition();
+ operationOutputDefinition.setName(name);
+ operationOutputDefinition.setUniqueId("uniqueId1");
+ return operationOutputDefinition;
+ }
+
default Map<String, InterfaceDefinition> createMockInterfaceDefinition(String resourceName) {
Map<String, Operation> operationMap = createMockOperationMap();
Map<String, InterfaceDefinition> interfaceDefinitionMap = new HashMap<>();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java
index a8686c179a..02c212d7e6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java
@@ -35,6 +35,7 @@ import org.openecomp.sdc.be.components.InterfaceOperationTestUtils;
import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
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.ArtifactDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentParametersView;
@@ -61,6 +62,7 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
InterfaceOperationValidationUtilTest interfaceOperationValidationUtilTest = new InterfaceOperationValidationUtilTest();
private static final String RESOURCE_ID = "resource1";
ListDataDefinition<OperationInputDefinition> operationInputDefinitionList = new ListDataDefinition<>();
+ ListDataDefinition<OperationOutputDefinition> operationOutputDefinitionList = new ListDataDefinition<>();
@Before
public void init() {
MockitoAnnotations.initMocks(this);
@@ -75,8 +77,10 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testValidInterfaceOperation() {
operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
- "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,"upgrade");
+ "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
+ operationOutputDefinitionList,"upgrade");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
.validateInterfaceOperations(operations, RESOURCE_ID, false);
Assert.assertTrue(booleanResponseFormatEither.isLeft());
@@ -85,11 +89,12 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationDescriptionLength() {
operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
"interface operation2 - The Spring Initializer provides a project generator to make you " +
"productive with the certain technology stack from the beginning. You can create a skeleton project" +
"with web, data access (relational and NoSQL datastores), cloud, or messaging support",
- new ArtifactDefinition(), operationInputDefinitionList,"update");
+ new ArtifactDefinition(), operationInputDefinitionList, operationOutputDefinitionList,"update");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
.validateInterfaceOperations(operations, RESOURCE_ID, false);
Assert.assertTrue(booleanResponseFormatEither.isRight());
@@ -100,8 +105,10 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationForEmptyType() {
operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
- "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,"");
+ "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
+ operationOutputDefinitionList, "");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
.validateInterfaceOperations(operations, RESOURCE_ID, false);
Assert.assertTrue(booleanResponseFormatEither.isRight());
@@ -110,8 +117,10 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationForEmptyInputParam() {
operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
- "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,"input2");
+ "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
+ operationOutputDefinitionList,"input2");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
.validateInterfaceOperations(operations, RESOURCE_ID, false);
Assert.assertTrue(booleanResponseFormatEither.isRight());
@@ -120,8 +129,10 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationForNonUniqueType() {
operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
- "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,"CREATE");
+ "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
+ operationOutputDefinitionList,"CREATE");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
.validateInterfaceOperations(operations, RESOURCE_ID, false);
Assert.assertTrue(booleanResponseFormatEither.isRight());
@@ -130,8 +141,10 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
@Test
public void testInterfaceOperationTypeLength() {
operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
+ operationOutputDefinitionList,
"interface operation2 - The Spring Initializer provides a project generator to make you " +
"productive with the certain technology stack from the beginning. You can create a skeleton project" +
"with web, data access (relational and NoSQL datastores), cloud, or messaging support");
@@ -147,8 +160,10 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
operationInputDefinitionList.add(createMockOperationInputDefinition("label2"));
operationInputDefinitionList.add(createMockOperationInputDefinition("label2"));
+ operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
- "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,"create");
+ "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
+ operationOutputDefinitionList,"create");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
.validateInterfaceOperations(operations, RESOURCE_ID, false);
@@ -159,8 +174,10 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
public void testInterfaceOperationUniqueInputParamNameValid() {
operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
operationInputDefinitionList.add(createMockOperationInputDefinition("label2"));
+ operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
- "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,"update");
+ "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
+ operationOutputDefinitionList,"update");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
@@ -172,8 +189,10 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
public void testInterfaceOperationeInputParamNameEmpty() {
operationInputDefinitionList.add(createMockOperationInputDefinition(" "));
operationInputDefinitionList.add(createMockOperationInputDefinition("label1"));
+ operationOutputDefinitionList.add(createMockOperationOutputDefinition("label1"));
Collection<Operation> operations = createInterfaceOperationData("op2",
- "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,"update");
+ "interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
+ operationOutputDefinitionList,"update");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
@@ -182,8 +201,9 @@ public class InterfaceOperationValidationTest implements InterfaceOperationTestU
}
private Set<Operation> createInterfaceOperationData( String uniqueID, String description, ArtifactDefinition artifactDefinition,
- ListDataDefinition<OperationInputDefinition> inputs, String name) {
- return Sets.newHashSet(createInterfaceOperation(uniqueID, description, artifactDefinition, inputs, name));
+ ListDataDefinition<OperationInputDefinition> inputs,
+ ListDataDefinition<OperationOutputDefinition> outputs, String name) {
+ return Sets.newHashSet(createInterfaceOperation(uniqueID, description, artifactDefinition, inputs, outputs, name));
}
private <T extends Component> Either<T, StorageOperationStatus> getToscaFullElement() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverterTest.java
index 5ed11a553e..b158ddf5da 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverterTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverterTest.java
@@ -9,6 +9,7 @@ import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationDataDefinition;
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.Operation;
public class InterfaceUIDataConverterTest {
@@ -27,7 +28,9 @@ public class InterfaceUIDataConverterTest {
Operation operationData = new Operation();
InterfaceOperationDataDefinition result;
ListDataDefinition<OperationInputDefinition> inputs = new ListDataDefinition<>();
+ ListDataDefinition<OperationOutputDefinition> outputs = new ListDataDefinition<>();
operationData.setInputs(inputs);
+ operationData.setOutputs(outputs);
operationData.setImplementation(new ArtifactDataDefinition());
// default test
result = InterfaceUIDataConverter.convertOperationDataToInterfaceData(operationData);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
index 80c22022a1..e90621515d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
@@ -110,7 +110,8 @@ public enum ActionStatus {
//InterfaceOperation
INTERFACE_OPERATION_NOT_FOUND, INTERFACE_OPERATION_TYPE_ALREADY_IN_USE, INTERFACE_OPERATION_TYPE_MANDATORY, INTERFACE_OPERATION_TYPE_INVALID,
- INTERFACE_OPERATION_DESCRIPTION_MAX_LENGTH, INTERFACE_OPERATION_INPUT_NAME_ALREADY_IN_USE, INTERFACE_OPERATION_NOT_DELETED, INTERFACE_OPERATION_INPUT_NAME_MANDATORY
+ INTERFACE_OPERATION_DESCRIPTION_MAX_LENGTH, INTERFACE_OPERATION_INPUT_NAME_ALREADY_IN_USE, INTERFACE_OPERATION_OUTPUT_NAME_ALREADY_IN_USE,INTERFACE_OPERATION_NOT_DELETED, INTERFACE_OPERATION_INPUT_NAME_MANDATORY,
+ INTERFACE_OPERATION_OUTPUT_NAME_MANDATORY
;
}
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
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationDataDefinition.java
index 40b1f31eda..dc99b7c320 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationDataDefinition.java
@@ -42,6 +42,7 @@ public class OperationDataDefinition extends ToscaDataDefinition implements Seri
setDescription(p.getDescription());
setImplementation(p.getImplementation());
setInputs(p.getInputs());
+ setOutputs(p.getOutputs());
setName(p.getName());
setUniqueId(p.getUniqueId());
}
@@ -97,6 +98,14 @@ public class OperationDataDefinition extends ToscaDataDefinition implements Seri
setToscaPresentationValue(JsonPresentationFields.OPERATION_INPUT,inputs);
}
+ public ListDataDefinition<OperationOutputDefinition> getOutputs() {
+ return (ListDataDefinition<OperationOutputDefinition>)
+ getToscaPresentationValue(JsonPresentationFields.OPERATION_OUTPUT);
+ }
+
+ public void setOutputs(ListDataDefinition<OperationOutputDefinition> outputs) {
+ setToscaPresentationValue(JsonPresentationFields.OPERATION_OUTPUT, outputs);
+ }
public String getName() {
return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationOutputDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationOutputDefinition.java
new file mode 100644
index 0000000000..af046eaa17
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationOutputDefinition.java
@@ -0,0 +1,46 @@
+/*
+ * 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.datatypes.elements;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+
+public class OperationOutputDefinition extends InputDataDefinition {
+
+ @JsonCreator
+ public OperationOutputDefinition() {
+ super();
+ }
+
+ public OperationOutputDefinition(String name, InputDataDefinition definition) {
+ super(definition);
+ setName(name);
+ }
+ public OperationOutputDefinition(String paramName, String paramId) {
+ super();
+ setName(paramName);
+ setInputId(paramId);
+ }
+ public String getLabel() {
+ return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_LABEL);
+ }
+
+ public void setLabel(String name) {
+ setToscaPresentationValue(JsonPresentationFields.ARTIFACT_LABEL, name);
+ }
+
+}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
index a08354146b..6d14078301 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
@@ -209,7 +209,8 @@ public enum JsonPresentationFields {
INTERFACE ("interface", null),
INTERFACE_OPERATION ("operation", null),
OPERATION_IMPLEMENTATION("operationImplementation",null),
- OPERATION_INPUT("operationInput",null)
+ OPERATION_INPUT("operationInput",null),
+ OPERATION_OUTPUT("operationOutput", null)
;
diff --git a/openecomp-bdd/features/InterfaceOperation/TestInterfaceOperation.feature b/openecomp-bdd/features/InterfaceOperation/TestInterfaceOperation.feature
index dfd754f74e..fa3647e5c6 100644
--- a/openecomp-bdd/features/InterfaceOperation/TestInterfaceOperation.feature
+++ b/openecomp-bdd/features/InterfaceOperation/TestInterfaceOperation.feature
@@ -93,4 +93,20 @@ Feature: Interface Operation Feature
#Submit
Then I want to submit this VF
- And I want to check property "lifecycleState" for value "READY_FOR_CERTIFICATION" \ No newline at end of file
+ And I want to check property "lifecycleState" for value "READY_FOR_CERTIFICATION"
+
+ Scenario: Test InterfaceOperation CREATE with output parameters
+ #Create Operations
+ When I want to create an Operation with outputParameter
+ Then I want to check property "uniqueId" exists
+
+ #List All Operations
+ When I want to list Operations
+
+#Checkin
+ When I want to checkin this VF
+ Then I want to check property "lifecycleState" for value "NOT_CERTIFIED_CHECKIN"
+
+#Submit
+ Then I want to submit this VF
+ And I want to check property "lifecycleState" for value "READY_FOR_CERTIFICATION"
diff --git a/openecomp-bdd/resources/json/operation/createOperation.json b/openecomp-bdd/resources/json/operation/createOperation.json
index 87c12f265f..394be36187 100644
--- a/openecomp-bdd/resources/json/operation/createOperation.json
+++ b/openecomp-bdd/resources/json/operation/createOperation.json
@@ -10,6 +10,14 @@
}
]
},
+ "outputParams": {
+ "listToscaDataDefinition": [
+ {
+ "paramName": "op1",
+ "paramId": "68443b9d-9405-458e-811f-b62dd4975fcb.nf_naming"
+ }
+ ]
+ },
"operationType": "create"
}
}
diff --git a/openecomp-bdd/stepDefinitions/InterfaceOperationSteps.js b/openecomp-bdd/stepDefinitions/InterfaceOperationSteps.js
index 4c00debc38..14c5610626 100644
--- a/openecomp-bdd/stepDefinitions/InterfaceOperationSteps.js
+++ b/openecomp-bdd/stepDefinitions/InterfaceOperationSteps.js
@@ -57,6 +57,23 @@ When('I want to create an Operation', function() {
});
+When('I want to create an Operation with outputParameter', function() {
+ let inputData = util.getJSONFromFile('resources/json/operation/createOperation.json');
+ //let path = '/catalog/resources/f3dc81bb-85e9-4dfd-bd1b-37f5dc5e5534/interfaceOperations';
+ let path = '/catalog/resources/' + this.context.vf.uniqueId +'/interfaceOperations';
+
+ inputData.interfaceOperations.create.operationType = makeType();
+ inputData.interfaceOperations.create.inputParams.listToscaDataDefinition[0].paramName = util.random();
+ inputData.interfaceOperations.create.inputParams.listToscaDataDefinition[0].paramId = this.context.vf.id;
+ inputData.interfaceOperations.create.outputParams.listToscaDataDefinition[0].paramName = util.random();
+ inputData.interfaceOperations.create.outputParams.listToscaDataDefinition[0].paramId = this.context.vf.id;
+
+ return util.request(this.context, 'POST', path, inputData, false, 'vf').then(result => {
+ this.context.item = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
+ this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
+});
+});
+
When('I want to list Operations', function () {
let path = '/catalog/resources/' + this.context.vf.uniqueId + '/filteredDataByParams?include=interfaces';