summaryrefslogtreecommitdiffstats
path: root/catalog-model/src
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-10-14 20:56:11 +0100
committerS�bastien Determe <sebastien.determe@intl.att.com>2020-12-07 14:51:59 +0000
commit95ad93091d5fa6e377e76f312d495151bddc9da8 (patch)
tree9923a98bd90b99cb960cf1f7ead2a57402aca1a8 /catalog-model/src
parenta9467feb90c33ad5b6b2ed80581c4adf75114046 (diff)
Support interface input during import VFC
Change-Id: I097ce258a7dadbedf1aff6ce53dd1286da074552 Issue-ID: SDC-3372 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-model/src')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceDefinition.java26
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/InterfaceDefinitionTest.java71
2 files changed, 44 insertions, 53 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceDefinition.java
index e3b5d08bc1..204d484937 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceDefinition.java
@@ -21,13 +21,12 @@
package org.openecomp.sdc.be.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.commons.collections.MapUtils;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
-import java.util.Map;
-import java.util.stream.Collectors;
-
/**
* Definition of the operations that can be performed on (instances of) a Node
* Type.
@@ -36,8 +35,6 @@ import java.util.stream.Collectors;
*/
public class InterfaceDefinition extends InterfaceDataDefinition implements IOperationParameter {
- private boolean definition;
-
public InterfaceDefinition() {
super();
}
@@ -56,10 +53,6 @@ public class InterfaceDefinition extends InterfaceDataDefinition implements IOpe
return false;
}
- public void setDefinition(boolean definition) {
- this.definition = definition;
- }
-
@JsonIgnore
public Map<String, Operation> getOperationsMap() {
return getOperations().entrySet()
@@ -79,9 +72,18 @@ public class InterfaceDefinition extends InterfaceDataDefinition implements IOpe
setOperations(convertedOperation);
}
- @Override
- public String toString() {
- return "InterfaceDefinition [definition=" + definition + "]";
+ /**
+ * Checks if the interface has the given operation
+ * @param operation the operation to check
+ * @return {@code true} if the operation exists, {@code false} otherwise
+ */
+ public boolean hasOperation(final String operation) {
+ final Map<String, OperationDataDefinition> operationMap = getOperations();
+ if (MapUtils.isEmpty(operationMap)) {
+ return false;
+ }
+ return operationMap.keySet().stream()
+ .anyMatch(operation1 -> operation1.equalsIgnoreCase(operation));
}
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/InterfaceDefinitionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/InterfaceDefinitionTest.java
index 992ae9bae8..43761b3369 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/InterfaceDefinitionTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/InterfaceDefinitionTest.java
@@ -20,64 +20,53 @@
package org.openecomp.sdc.be.model;
-import org.junit.Test;
-import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
-public class InterfaceDefinitionTest {
-
- private InterfaceDefinition createTestSubject() {
- return new InterfaceDefinition();
- }
+class InterfaceDefinitionTest {
@Test
- public void testCtor() throws Exception {
+ void testCtor() throws Exception {
new InterfaceDefinition(new InterfaceDataDefinition());
new InterfaceDefinition("mock", "mock", new HashMap<>());
}
@Test
- public void testIsDefinition() throws Exception {
- InterfaceDefinition testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isDefinition();
+ void testIsDefinition() {
+ final InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
+ assertFalse(interfaceDefinition.isDefinition());
}
@Test
- public void testSetDefinition() throws Exception {
- InterfaceDefinition testSubject;
- boolean definition = false;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDefinition(definition);
+ void testGetOperationsMap() {
+ final InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
+ assertNotNull(interfaceDefinition.getOperationsMap());
+ assertTrue(interfaceDefinition.getOperationsMap().isEmpty());
}
@Test
- public void testGetOperationsMap() throws Exception {
- InterfaceDefinition testSubject;
- Map<String, Operation> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationsMap();
- }
-
-
-
- @Test
- public void testToString() throws Exception {
- InterfaceDefinition testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
+ void testHasOperation() {
+ final InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
+ final Map<String, Operation> operationMap = new HashMap<>();
+ final Set<String> operationSet = new HashSet<>();
+ operationSet.add("operation1");
+ operationSet.add("operation2");
+ operationSet.add("operation3");
+ operationSet.forEach(operation -> operationMap.put(operation, new Operation()));
+ interfaceDefinition.setOperationsMap(operationMap);
+
+ operationSet.forEach(operation -> assertThat(String.format("Should contain operation: %s", operation),
+ interfaceDefinition.hasOperation(operation), is(true)));
}
}