Fix sonar bugs
Fix the bugs indicated by Sonar in YamlUtilTest.
Issue-ID: SDC-3428
Change-Id: Ic0a4b9e4ee45d047414bb14929abcd5d390466d4
Signed-off-by: xuegao <xue.gao@intl.att.com>
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 562b208..063680f 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 @@
InputStream is = yamlUtil.loadYamlFileIs("/yamlMap.yaml");
Map<String, LinkedHashMap<String, Object>> 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<List<Object>> 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<List<Object>> 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 d4a07a8..4fa455c 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