diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-04-16 17:21:23 -0400 |
---|---|---|
committer | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2019-04-20 07:49:40 +0000 |
commit | dc6dfca6c22fce3ad0c10cffd3dc2698a101b40f (patch) | |
tree | c75389117149268124625ee1f970b0eb9818c095 /adapters/mso-adapters-rest-interface/src/test | |
parent | 2886fcd111a2127400f588d3ee949c1c6c1b1dbc (diff) |
always convert values toString for xml marshalling
always convert values toString for xml marshalling
added in null check and object mapper call
Change-Id: Ie91c313dce110d53586e6773e2223d63be799a54
Issue-ID: SO-1786
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-adapters-rest-interface/src/test')
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> |