summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapters-rest-interface
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-adapters-rest-interface')
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/HostRoute.java6
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapAdapter.java10
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java8
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapEntry.java19
-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
6 files changed, 56 insertions, 14 deletions
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/HostRoute.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/HostRoute.java
index 431870ba9e..afe9d71e92 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/HostRoute.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/HostRoute.java
@@ -20,16 +20,16 @@
package org.onap.so.openstack.beans;
-
-
+import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {"prefix", "nextHop"})
-public class HostRoute {
+public class HostRoute implements Serializable {
+ private static final long serialVersionUID = 2468793257174064133L;
private String prefix;
private String nextHop;
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapAdapter.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapAdapter.java
index ef5d4316d7..90b8024c18 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapAdapter.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapAdapter.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
@@ -36,8 +38,8 @@ public class MapAdapter extends XmlAdapter<MapEntry, Map<String, Object>> {
MapEntry map = new MapEntry();
- for (String key : v.keySet()) {
- map.addEntry(key, v.get(key));
+ for (Map.Entry<String, Object> entry : v.entrySet()) {
+ map.addEntry(entry.getKey(), entry.getValue());
}
return map;
@@ -49,9 +51,9 @@ public class MapAdapter extends XmlAdapter<MapEntry, Map<String, Object>> {
return null;
}
- Map<String, Object> map = new HashMap<>(v.entry.size());
+ Map<String, Object> map = new HashMap<>(v.getEntry().size());
- for (MapElements entry : v.entry) {
+ for (MapElements entry : v.getEntry()) {
if (entry.value instanceof Element) {
map.put(entry.key, ((Element) entry.value).getTextContent());
} else {
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java
index 0327fd67a3..3dd339dc68 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.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
@@ -35,7 +37,9 @@ public class MapElements {
@XmlElement
public Object value;
- public MapElements() {} // Required by JAXB
+ public MapElements() {
+ // Required by JAXB
+ }
public MapElements(String key, Object value) {
this.key = key;
@@ -46,7 +50,7 @@ public class MapElements {
try {
this.value = new ObjectMapper().writeValueAsString(value);
} catch (JsonProcessingException e) {
- logger.warn("could not marshal value to json, calling toString");
+ logger.warn("could not marshal value to json, calling toString", e);
this.value = value.toString();
}
} else {
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapEntry.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapEntry.java
index 489e11e111..b6b121c820 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapEntry.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapEntry.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
@@ -25,12 +27,23 @@ import java.util.List;
public class MapEntry {
- public List<MapElements> entry = new ArrayList<>();
+ private List<MapElements> entry = new ArrayList<>();
- public MapEntry() {} // Required by JAXB
+ public MapEntry() {
+ // Required by JAXB
+ }
- public void addEntry(String key, Object value) {
+ void addEntry(String key, Object value) {
entry.add(new MapElements(key, value));
}
+ public List<MapElements> getEntry() {
+ // Required by JAXB
+ return entry;
+ }
+
+ public void setEntry(List<MapElements> entry) {
+ // Required by JAXB
+ this.entry = entry;
+ }
}
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>