From b2c0528da052b5c73e3fc1f7f98d22578acd91f0 Mon Sep 17 00:00:00 2001 From: xuegao Date: Fri, 19 Mar 2021 14:04:17 +0100 Subject: Improve test coverage Add unit tests to improve test coverage. Issue-ID: SDC-3428 Change-Id: I29a8f1d49f1dfd6bca79f3d873d1e1ff7adc4fb2 Signed-off-by: xuegao --- .../datatypes/model/HeatResourcesTypesTest.java | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypesTest.java (limited to 'openecomp-be/lib/openecomp-heat-lib/src/test') diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypesTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypesTest.java new file mode 100644 index 0000000000..1298681b70 --- /dev/null +++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatResourcesTypesTest.java @@ -0,0 +1,64 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 AT&T Intellectual Property. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.heat.datatypes.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Map; + +public class HeatResourcesTypesTest { + + @Test + public void findByHeatResourceTest() { + assertEquals(HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE, + HeatResourcesTypes.findByHeatResource("OS::Nova::ServerGroup")); + } + + @Test + public void isResourceExpectedToBeExposedTest() { + assertEquals(true, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Nova::ServerGroup")); + assertEquals(true, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Contrail::VirtualNetwork")); + assertEquals(true, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Neutron::Net")); + assertEquals(true, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Cinder::Volume")); + assertEquals(true, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Neutron::SecurityGroup")); + assertEquals(false, HeatResourcesTypes.isResourceExpectedToBeExposed("OS::Nova::Server")); + } + + @Test + public void isResourceTypeValidTest() { + assertEquals(true, HeatResourcesTypes.isResourceTypeValid("OS::Neutron::SecurityGroup")); + assertEquals(false, HeatResourcesTypes.isResourceTypeValid("OS::Neutron::test")); + } + + @Test + public void getListForResourceTypeTest() { + Map> res = HeatResourcesTypes.getListForResourceType( + HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE, HeatResourcesTypes.HEAT_CLOUD_CONFIG_TYPE); + + assertNotNull(res.get(HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE)); + assertNotNull(res.get(HeatResourcesTypes.HEAT_CLOUD_CONFIG_TYPE)); + assertNull(res.get(HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE)); + } + +} -- cgit 1.2.3-korg