summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
authorimamSidero <imam.hussain@est.tech>2022-08-05 10:43:18 +0100
committerMichael Morris <michael.morris@est.tech>2022-08-11 14:10:16 +0000
commit7e49c060458ff13b72bc997ffff9ea668e934676 (patch)
tree6e00b4c19d3a78624fe222c2a67d006fbaf5c250 /catalog-be/src/test/java
parent33538725267c361efe813f1a4e6eff8b69c09c9f (diff)
Empty node filter is removed when no filter is added
Null and empty check is added before adding a node filter object Signed-off-by: Imam hussain <imam.hussain@est.tech> Issue-ID: SDC-4124 Change-Id: I1e1e992881cd51dff209bac0111a472793dd41d1
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/NodeFilterTest.java62
1 files changed, 54 insertions, 8 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/NodeFilterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/NodeFilterTest.java
index 72fcf5f2dc..84732e2cdf 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/NodeFilterTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/NodeFilterTest.java
@@ -20,20 +20,66 @@
package org.openecomp.sdc.be.tosca.model;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
-import static org.hamcrest.MatcherAssert.assertThat;
+import org.junit.jupiter.api.Test;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class NodeFilterTest {
+
+ private void createCapabilities(NodeFilter nodeFilter) {
+ List<Map<String, CapabilityFilter>> capabilitiesCopy = new ArrayList<>();
+ Map<String, CapabilityFilter> capabilityDataMap = new HashMap<>();
+ CapabilityFilter capabilityFilter = new CapabilityFilter();
+ capabilityDataMap.put("test", capabilityFilter);
+ capabilitiesCopy.add(capabilityDataMap);
+ nodeFilter.setCapabilities(capabilitiesCopy);
+ }
+
+ private void createProperties(NodeFilter nodeFilter) {
+ List<Map<String, List<Object>>> propertiesCopy = new ArrayList<>();
+ Map<String, List<Object>> propertyDataMap = new HashMap<>();
+ List<Object> dataObjectList = new ArrayList<>();
+ Object object = new Object();
+ dataObjectList.add(object);
+ propertyDataMap.put("test", dataObjectList);
+ propertiesCopy.add(propertyDataMap);
+ nodeFilter.setProperties(propertiesCopy);
+ }
+
+ @Test
+ public void testHasDataTrue() {
+ NodeFilter nodeFilter = new NodeFilter();
+ createCapabilities(nodeFilter);
+ createProperties(nodeFilter);
+ boolean result = nodeFilter.hasData();
+ assertTrue(result);
+ }
+
+ @Test
+ public void testHasDataCapabilityTrue() {
+ NodeFilter nodeFilter = new NodeFilter();
+ createCapabilities(nodeFilter);
+ boolean result = nodeFilter.hasData();
+ assertTrue(result);
+ }
+
@Test
- public void testDefaultCtor() {
- assertThat(NodeFilter.class, hasValidBeanConstructor());
+ public void testHasDataPropertiesTrue() {
+ NodeFilter nodeFilter = new NodeFilter();
+ createProperties(nodeFilter);
+ boolean result = nodeFilter.hasData();
+ assertTrue(result);
}
@Test
- public void testGettersSetters() {
- assertThat(NodeFilter.class, hasValidGettersAndSetters());
+ public void testHasDataFalse() {
+ NodeFilter nodeFilter = new NodeFilter();
+ boolean result = nodeFilter.hasData();
+ assertFalse(result);
}
} \ No newline at end of file