summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm.kowalski3 <m.kowalski3@partner.samsung.com>2019-05-24 14:26:18 +0200
committerOren Kleks <orenkle@amdocs.com>2019-05-27 13:37:59 +0000
commitada9f9d10b5e6640bef6d020e89582256f2a1fa5 (patch)
tree19903215b92bca1fb14f8d127a93330a67f0a661
parentf3a1aa08a8339ce312013154550c8e8b637f0fc3 (diff)
Add unit tests for DataModelNormalizeUtil
Issue-ID: SDC-2327 Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com> Change-Id: I31dbd12b2d897da83327c17af2f2d83bd4459f1d
-rw-r--r--common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/DataModelNormalizeUtilTest.java90
1 files changed, 90 insertions, 0 deletions
diff --git a/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/DataModelNormalizeUtilTest.java b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/DataModelNormalizeUtilTest.java
new file mode 100644
index 0000000000..19cb890839
--- /dev/null
+++ b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/DataModelNormalizeUtilTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP SDC
+ * ================================================================================
+ * Copyright (C) 2019 Samsung. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.sdc.tosca.services;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.sdc.tosca.datatypes.model.CapabilityFilter;
+import org.onap.sdc.tosca.datatypes.model.Constraint;
+import java.util.*;
+
+public class DataModelNormalizeUtilTest {
+
+ @Test
+ public void getNormalizeCapabilitiesFilterTest() {
+ //given
+ List<Map<String, CapabilityFilter>> capabilities = new ArrayList<>();
+ List<Map<String, CapabilityFilter>> returnedCapabilities;
+ //when
+ returnedCapabilities = DataModelNormalizeUtil.getNormalizeCapabilitiesFilter(capabilities);
+ //then
+ Assert.assertEquals(returnedCapabilities, capabilities);
+
+ //given
+ Map<String, CapabilityFilter> outerMap = new HashMap<>();
+ Map<String, List<Constraint>> innerMap = new HashMap<>();
+ CapabilityFilter filterProperties = new CapabilityFilter();
+ Constraint constraint = new Constraint();
+ Map<String, String> propertyMap = new HashMap<>();
+ propertyMap.put("key", "siteName" + UUID.randomUUID().getMostSignificantBits());
+ constraint.setEqual(propertyMap);
+ List<Constraint> constraints = new ArrayList<>();
+ constraints.add(constraint);
+ innerMap.put("queue_model", constraints);
+ List<Map<String, List<Constraint>>> innerList = new ArrayList<>();
+ innerList.add(innerMap);
+ filterProperties.setProperties(innerList);
+ outerMap.put("diffserv", filterProperties);
+ capabilities.add(outerMap);
+ //when
+ returnedCapabilities = DataModelNormalizeUtil.getNormalizeCapabilitiesFilter(capabilities);
+ //then
+ Assert.assertNotEquals(capabilities, returnedCapabilities);
+ }
+
+ @Test
+ public void getNormalizePropertiesFilterTest() {
+ //given
+ List<Map<String, List<Constraint>>> properties = new ArrayList<>();
+ List<Map<String, List<Constraint>>> returnedProperties;
+ //when
+ returnedProperties = DataModelNormalizeUtil.getNormalizePropertiesFilter(properties);
+ //then
+ Assert.assertEquals(returnedProperties, properties);
+
+ //given
+ Map<String, List<Constraint>> innerMap = new HashMap<>();
+ Constraint constraint = new Constraint();
+ Map<String, String> propertyMap = new HashMap<>();
+ propertyMap.put("key", "siteName" + UUID.randomUUID().getMostSignificantBits());
+ constraint.setEqual(propertyMap);
+ List<Constraint> constraints = new ArrayList<>();
+ constraints.add(constraint);
+ innerMap.put("queue_model", constraints);
+ properties.add(innerMap);
+ //when
+ returnedProperties = DataModelNormalizeUtil.getNormalizePropertiesFilter(properties);
+ //then
+ Assert.assertNotEquals(properties, returnedProperties);
+ }
+}