summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-11 15:05:27 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-11 15:05:43 -0500
commit673e7d4958c6f4a86a3997a9bcd778937b42499e (patch)
tree4d4d16ae4ff5fb487de8a6c5a8eaefeca5810b50
parentb80f29cbbeb5ec218b0278deef872f7b5350e292 (diff)
Fix unmarshalling errors
add data assertion to network update unit test Fix unmarshalling errors on updateNetworkResp and err Change-Id: Iddc13514198b3c89718b1b953a06cec6db190269 Issue-ID: SO-1494 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java11
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java19
2 files changed, 30 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java
index 18230c4d07..fec7e8456f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java
@@ -35,6 +35,9 @@ import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.adapters.nwrest.DeleteNetworkError;
import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
import org.onap.so.adapters.nwrest.DeleteNetworkResponse;
+import org.onap.so.adapters.nwrest.UpdateNetworkError;
+import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
+import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.NetworkAdapterResources;
import org.slf4j.Logger;
@@ -115,6 +118,14 @@ public class NetworkAdapterRestV1 {
DeleteNetworkResponse deleteNetworkResponse = (DeleteNetworkResponse) unmarshalXml(callback, DeleteNetworkResponse.class);
execution.setVariable("deleteNetworkResponse", deleteNetworkResponse);
}
+ } else if (networkAdapterRequest instanceof UpdateNetworkRequest) {
+ if (callback.contains("updateNetworkError")) {
+ UpdateNetworkError updateNetworkError = (UpdateNetworkError) unmarshalXml(callback, UpdateNetworkError.class);
+ throw new Exception(updateNetworkError.getMessage());
+ } else {
+ UpdateNetworkResponse updateNetworkResponse = (UpdateNetworkResponse) unmarshalXml(callback, UpdateNetworkResponse.class);
+ execution.setVariable("updateNetworkResponse", updateNetworkResponse);
+ }
}
}
} catch (Exception e) {
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
index 278afc733a..516c9480ad 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
@@ -20,12 +20,18 @@
package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertThat;
+
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import javax.xml.bind.JAXBException;
import org.junit.Test;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
+import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
public class NetworkAdapterRestV1Test {
@@ -36,4 +42,17 @@ public class NetworkAdapterRestV1Test {
String returnedXml = response.toXmlString();
System.out.println(returnedXml);
}
+
+ @Test
+ public void testUnmarshalXmlUpdate() throws IOException, JAXBException {
+ UpdateNetworkResponse expectedResponse = new UpdateNetworkResponse();
+ expectedResponse.setMessageId("ec100bcc-2659-4aa4-b4d8-3255715c2a51");
+ expectedResponse.setNetworkId("80de31e3-cc78-4111-a9d3-5b92bf0a39eb");
+ Map<String,String>subnetMap = new HashMap<String,String>();
+ subnetMap.put("95cd8437-25f1-4238-8720-cbfe7fa81476", "d8d16606-5d01-4822-b160-9a0d257303e0");
+ expectedResponse.setSubnetMap(subnetMap);
+ String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><updateNetworkResponse><messageId>ec100bcc-2659-4aa4-b4d8-3255715c2a51</messageId><networkId>80de31e3-cc78-4111-a9d3-5b92bf0a39eb</networkId><subnetMap><entry><key>95cd8437-25f1-4238-8720-cbfe7fa81476</key><value>d8d16606-5d01-4822-b160-9a0d257303e0</value></entry></subnetMap></updateNetworkResponse>";
+ UpdateNetworkResponse response = (UpdateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, UpdateNetworkResponse.class);
+ assertThat(expectedResponse, sameBeanAs(response));
+ }
}