From 114b2affd49c0c5a77f65267d53fc417d79d29f7 Mon Sep 17 00:00:00 2001 From: xuegao Date: Mon, 1 Mar 2021 09:19:39 +0100 Subject: Fix sonar bugs Fix the bugs indicated by Sonar in YamlUtilTest. Issue-ID: SDC-3428 Change-Id: Ic0a4b9e4ee45d047414bb14929abcd5d390466d4 Signed-off-by: xuegao --- .../test/java/org/onap/sdc/tosca/services/YamlUtilTest.java | 12 ++++++------ common/onap-tosca-datatype/src/test/resources/yamlMap.yaml | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/YamlUtilTest.java b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/YamlUtilTest.java index 562b208bde..063680f9ed 100644 --- a/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/YamlUtilTest.java +++ b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/services/YamlUtilTest.java @@ -42,18 +42,18 @@ public class YamlUtilTest { InputStream is = yamlUtil.loadYamlFileIs("/yamlMap.yaml"); Map> res = yamlUtil.yamlToMap(is); assertNotNull(res); - assertEquals(res.size(), 3); - assertEquals(res.get("parameter1"), "value1"); - assertEquals(res.get("parameter2"), "value2"); - assertEquals(res.get("parameter3"), "value3"); + assertEquals(1, res.size()); + assertEquals("value1", (String)res.get("complex-mapping").get("parameter1")); + assertEquals("value2", (String)res.get("complex-mapping").get("parameter2")); + assertEquals("value3", (String)res.get("complex-mapping").get("parameter3")); } @Test public void testYamlToList() { InputStream is = yamlUtil.loadYamlFileIs("/yamlList.yaml"); Optional> res = yamlUtil.yamlToList(is); - assertEquals(res.get().size(), 3); - assertEquals(res.get().get(0), "value1"); + assertEquals(3, res.get().size()); + assertEquals("value1", res.get().get(0)); InputStream is2 = yamlUtil.loadYamlFileIs("/yamlListError.yaml"); Optional> res2 = yamlUtil.yamlToList(is2); diff --git a/common/onap-tosca-datatype/src/test/resources/yamlMap.yaml b/common/onap-tosca-datatype/src/test/resources/yamlMap.yaml index d4a07a82a5..4fa455c452 100644 --- a/common/onap-tosca-datatype/src/test/resources/yamlMap.yaml +++ b/common/onap-tosca-datatype/src/test/resources/yamlMap.yaml @@ -1,3 +1,4 @@ -parameter1: value1 -parameter2: value2 -parameter3: value3 \ No newline at end of file +complex-mapping: + parameter1: value1 + parameter2: value2 + parameter3: value3 \ No newline at end of file -- cgit 1.2.3-korg