aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapters-rest-interface/src/test
diff options
context:
space:
mode:
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.java18
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml15
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/resources/createVfModuleRequest-with-params.xml7
3 files changed, 37 insertions, 3 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 8d27e54892..189d4cca3e 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
@@ -24,17 +24,19 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.Arrays;
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 {
@Test
- public void xmlMarshalTest() throws IOException, JAXBException {
+ public void xmlUnMarshalTest() throws IOException, JAXBException {
JAXBContext context = JAXBContext.newInstance(CreateVfModuleRequest.class);
CreateVfModuleRequest request = (CreateVfModuleRequest) context.createUnmarshaller().unmarshal(
@@ -43,6 +45,20 @@ public class JAXBMarshallingTest {
assertEquals("ubuntu-16-04-cloud-amd64", request.getVfModuleParams().get("vcpe_image_name"));
assertEquals("10.2.0.0/24", request.getVfModuleParams().get("cpe_public_net_cidr"));
assertEquals("", request.getVfModuleParams().get("workload_context"));
+ assertEquals("[\"a\",\"b\",\"c\"]", request.getVfModuleParams().get("raw-json-param"));
+ }
+
+ @Test
+ public void xmlMarshalTest() throws IOException, JAXBException {
+
+ CreateVfModuleRequest request = new CreateVfModuleRequest();
+ request.getVfModuleParams().put("test-null", null);
+ request.getVfModuleParams().put("test array", Arrays.asList("a", "b", "c"));
+
+ assertEquals("documents are 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
new file mode 100644
index 0000000000..ce175127df
--- /dev/null
+++ b/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<createVfModuleRequest>
+ <failIfExists>false</failIfExists>
+ <backout>true</backout>
+ <vfModuleParams>
+ <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-null</key>
+ </entry>
+ </vfModuleParams>
+ <msoRequest/>
+</createVfModuleRequest>
diff --git a/adapters/mso-adapters-rest-interface/src/test/resources/createVfModuleRequest-with-params.xml b/adapters/mso-adapters-rest-interface/src/test/resources/createVfModuleRequest-with-params.xml
index 1ff24a50f6..2718f1df61 100644
--- a/adapters/mso-adapters-rest-interface/src/test/resources/createVfModuleRequest-with-params.xml
+++ b/adapters/mso-adapters-rest-interface/src/test/resources/createVfModuleRequest-with-params.xml
@@ -1,4 +1,4 @@
-<createVfModuleRequest>
+ <createVfModuleRequest>
<cloudSiteId>RegionOne</cloudSiteId>
<cloudOwner>CloudOwner</cloudOwner>
<tenantId>09d8566ea45e43aa974cf447ed591d77</tenantId>
@@ -196,7 +196,10 @@
<key>vf_module_index</key>
<value>0</value>
</entry>
-
+ <entry>
+ <key>raw-json-param</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>
</vfModuleParams>
<msoRequest>
<requestId>11c8ec20-a1f8-4aa2-926f-e55d67a30f8b</requestId>