From 4f7d736f2e4997d13727bffabc982abf1a2522d8 Mon Sep 17 00:00:00 2001 From: Joanna Jeremicz Date: Fri, 2 Oct 2020 14:56:55 +0200 Subject: Improve code quality in ResourceConfig - Add unit test - Refactor ResourceConfig class (break the public method into smaller private methods, remove code duplications) Issue-ID: DCAEGEN2-2460 Signed-off-by: Joanna Jeremicz Change-Id: Ibfbac2b6d6ea4705a2139dee7d1bb801395790c9 --- .../models/blueprint/ResourceConfigTest.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java (limited to 'mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java') diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java new file mode 100644 index 0000000..cf12da1 --- /dev/null +++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java @@ -0,0 +1,38 @@ +/*============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2020 Nokia. 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.blueprintgenerator.models.blueprint; + +import static org.junit.Assert.assertEquals; + +import java.util.LinkedHashMap; +import java.util.TreeMap; +import org.junit.Test; + +public class ResourceConfigTest { + + @Test + public void createResourceConfig() { + TreeMap> result = new ResourceConfig() + .createResourceConfig(new TreeMap<>(), "demo"); + + String expectedResult = "{demo_cpu_limit={type=string, default=250m}, demo_cpu_request={type=string, default=250m}, demo_memory_limit={type=string, default=128Mi}, demo_memory_request={type=string, default=128Mi}}"; + assertEquals(expectedResult, result.toString()); + } +} -- cgit 1.2.3-korg