aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java4
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java24
-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
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java1
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java4
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java2
-rw-r--r--common/src/main/java/org/onap/so/client/BaseClient.java (renamed from bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java)3
12 files changed, 72 insertions, 14 deletions
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java
index 23bbbb3f43..7a2d4ec3e1 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/VfResponseCommon.java
@@ -24,6 +24,8 @@ package org.onap.so.adapters.vnfrest;
import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -71,7 +73,7 @@ public abstract class VfResponseCommon {
public String toXmlString() {
try {
ByteArrayOutputStream bs = new ByteArrayOutputStream();
- JAXBContext context = JAXBContext.newInstance(this.getClass());
+ JAXBContext context = JAXBContext.newInstance(this.getClass(), ArrayList.class, HashMap.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); // pretty print XML
marshaller.marshal(this, bs);
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 d20d2b7758..0327fd67a3 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
@@ -20,9 +20,16 @@
package org.onap.so.openstack.mappers;
+import java.util.List;
+import java.util.Map;
import javax.xml.bind.annotation.XmlElement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class MapElements {
+ private static final Logger logger = LoggerFactory.getLogger(MapElements.class);
@XmlElement
public String key;
@XmlElement
@@ -32,6 +39,21 @@ public class MapElements {
public MapElements(String key, Object value) {
this.key = key;
- this.value = value;
+ // this is required to handle marshalling raw json
+ // always write values as strings for XML
+ if (value != null) {
+ if (value instanceof List || value instanceof Map) {
+ try {
+ this.value = new ObjectMapper().writeValueAsString(value);
+ } catch (JsonProcessingException e) {
+ logger.warn("could not marshal value to json, calling toString");
+ this.value = value.toString();
+ }
+ } else {
+ this.value = value;
+ }
+ } else {
+ this.value = value;
+ }
}
}
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>
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java
index ee2c10ca4b..05af5f71f8 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java
@@ -29,6 +29,7 @@ import java.util.Map;
import javax.ws.rs.core.UriBuilder;
import org.junit.Test;
import org.onap.so.BaseTest;
+import org.onap.so.client.BaseClient;
import org.springframework.core.ParameterizedTypeReference;
import wiremock.org.apache.http.entity.ContentType;
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java
index a8e974d63a..2163e0b7a8 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java
@@ -7,9 +7,9 @@
* 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
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java
index b6faf1b806..c5ddd56880 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java
@@ -7,9 +7,9 @@
* 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
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java
index e31285f044..e8a7fef1bd 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java
@@ -22,8 +22,8 @@ package org.onap.so.client.oof;
import org.camunda.bpm.engine.delegate.BpmnError;
-import org.onap.so.bpmn.common.baseclient.BaseClient;
import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.client.BaseClient;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.oof.beans.OofProperties;
import org.onap.so.client.oof.beans.OofRequest;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java
index 732bba8489..f02d5e48ee 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java
@@ -24,7 +24,7 @@ package org.onap.so.client.sdnc;
import java.util.LinkedHashMap;
import javax.ws.rs.core.UriBuilder;
-import org.onap.so.bpmn.common.baseclient.BaseClient;
+import org.onap.so.client.BaseClient;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.beans.SDNCProperties;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java
index f7aad558b2..21c0b971b8 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java
@@ -24,8 +24,8 @@ package org.onap.so.client.sniro;
import java.util.LinkedHashMap;
import org.camunda.bpm.engine.delegate.BpmnError;
-import org.onap.so.bpmn.common.baseclient.BaseClient;
import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.client.BaseClient;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.sniro.beans.ManagerProperties;
import org.onap.so.client.sniro.beans.SniroConductorRequest;
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java b/common/src/main/java/org/onap/so/client/BaseClient.java
index 73047cf961..d939a33358 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java
+++ b/common/src/main/java/org/onap/so/client/BaseClient.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.common.baseclient;
+package org.onap.so.client;
import java.util.ArrayList;
import java.util.List;
@@ -34,7 +34,6 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
-// TODO move to common location
public class BaseClient<I, O> {
private HttpHeaders httpHeader;