From ada9f9d10b5e6640bef6d020e89582256f2a1fa5 Mon Sep 17 00:00:00 2001 From: "m.kowalski3" Date: Fri, 24 May 2019 14:26:18 +0200 Subject: Add unit tests for DataModelNormalizeUtil Issue-ID: SDC-2327 Signed-off-by: Marcin Kowalski Change-Id: I31dbd12b2d897da83327c17af2f2d83bd4459f1d --- .../tosca/services/DataModelNormalizeUtilTest.java | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/DataModelNormalizeUtilTest.java 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> capabilities = new ArrayList<>(); + List> returnedCapabilities; + //when + returnedCapabilities = DataModelNormalizeUtil.getNormalizeCapabilitiesFilter(capabilities); + //then + Assert.assertEquals(returnedCapabilities, capabilities); + + //given + Map outerMap = new HashMap<>(); + Map> innerMap = new HashMap<>(); + CapabilityFilter filterProperties = new CapabilityFilter(); + Constraint constraint = new Constraint(); + Map propertyMap = new HashMap<>(); + propertyMap.put("key", "siteName" + UUID.randomUUID().getMostSignificantBits()); + constraint.setEqual(propertyMap); + List constraints = new ArrayList<>(); + constraints.add(constraint); + innerMap.put("queue_model", constraints); + List>> 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>> properties = new ArrayList<>(); + List>> returnedProperties; + //when + returnedProperties = DataModelNormalizeUtil.getNormalizePropertiesFilter(properties); + //then + Assert.assertEquals(returnedProperties, properties); + + //given + Map> innerMap = new HashMap<>(); + Constraint constraint = new Constraint(); + Map propertyMap = new HashMap<>(); + propertyMap.put("key", "siteName" + UUID.randomUUID().getMostSignificantBits()); + constraint.setEqual(propertyMap); + List constraints = new ArrayList<>(); + constraints.add(constraint); + innerMap.put("queue_model", constraints); + properties.add(innerMap); + //when + returnedProperties = DataModelNormalizeUtil.getNormalizePropertiesFilter(properties); + //then + Assert.assertNotEquals(properties, returnedProperties); + } +} -- cgit 1.2.3-korg