summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org
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-be/src/test/java/org
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-be/src/test/java/org')
-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
3 files changed, 48 insertions, 11 deletions
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);