summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapters-rest-interface/src/test
diff options
context:
space:
mode:
authork.kazak <k.kazak@samsung.com>2019-05-27 15:00:15 +0200
committerk.kazak <k.kazak@samsung.com>2019-05-27 15:00:15 +0200
commitc1cd5ef428017bc26513395a3bfc00caf7209f8a (patch)
tree6001426422534e0d4cdf1e7ab0e2ddd2ecc1369e /adapters/mso-adapters-rest-interface/src/test
parenta7160456335b2ce3710efd00658711d431eac0b4 (diff)
Fix sonar for MapEntry
MapEntry bug: make entry private and provide accessors MapEntry codesmell: move comment 'Required by JAXB' into empty constructor MapElements codesmell: move explanatory comment inside empty constructor MapElements codesmell: log error stacktrace MapAdapter codesmell: use entry set instead of key set for iteration JAXBMarshallingTest: add test cases to cover 100% of MapElements & other cases Change-Id: If51f1f86b5ad44b3462424e4fd73cb0eff352124 Issue-ID: SO-1811 Signed-off-by: k.kazak <k.kazak@samsung.com>
Diffstat (limited to 'adapters/mso-adapters-rest-interface/src/test')
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java11
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml16
2 files changed, 25 insertions, 2 deletions
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java
index 189d4cca3e..19dbcad1a2 100644
--- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java
+++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -24,12 +26,13 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import org.junit.Test;
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
-import com.fasterxml.jackson.databind.ObjectMapper;
public class JAXBMarshallingTest {
@@ -53,9 +56,13 @@ public class JAXBMarshallingTest {
CreateVfModuleRequest request = new CreateVfModuleRequest();
request.getVfModuleParams().put("test-null", null);
+ request.getVfModuleParams().put("vcpe_image_name", "ubuntu-16-04-cloud-amd64");
+ request.getVfModuleParams().put("test-empty", "");
request.getVfModuleParams().put("test array", Arrays.asList("a", "b", "c"));
+ request.getVfModuleParams().put("test map", Collections.singletonMap("d", "e"));
+ request.getVfModuleParams().put("marshalling error", new ArrayList());
- assertEquals("documents are equal",
+ assertEquals("documents should be equal",
new String(Files
.readAllBytes(Paths.get("src/test/resources/VfRequest-marshalled-with-complex-object.xml"))),
request.toXmlString());
diff --git a/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml b/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml
index ce175127df..d4955f1b18 100644
--- a/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml
+++ b/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml
@@ -4,12 +4,28 @@
<backout>true</backout>
<vfModuleParams>
<entry>
+ <key>vcpe_image_name</key>
+ <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">ubuntu-16-04-cloud-amd64</value>
+ </entry>
+ <entry>
<key>test array</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">["a","b","c"]</value>
</entry>
<entry>
+ <key>test map</key>
+ <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">{"d":"e"}</value>
+ </entry>
+ <entry>
<key>test-null</key>
</entry>
+ <entry>
+ <key>marshalling error</key>
+ <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">[]</value>
+ </entry>
+ <entry>
+ <key>test-empty</key>
+ <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string"></value>
+ </entry>
</vfModuleParams>
<msoRequest/>
</createVfModuleRequest>