aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.aai/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-05-29 16:32:57 -0400
committerJim Hahn <jrh3@att.com>2020-05-29 16:51:29 -0400
commit45e3d3ae1cc5a4c29526da4f4cb6096e1b6d7d4f (patch)
tree02b5f1fa7f150ef86846d37143b008e292ce9eaa /models-interactions/model-actors/actor.aai/src
parent6d5459569af6a9c70abf5a8bbb54917decd37b38 (diff)
Use "coder" to serialize Actor requests
Modified the Actors to use the "coder" to serialize requests instead of defaulting to the HttpClient serialization provider. Decided to just pretty-print the requests since that can be used for both logging and transmission, which avoids serializing the request twice. Issue-ID: POLICY-2601 Change-Id: I190ed19dd852a1aa66156b358cbc97c3b121af1f Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.aai/src')
-rw-r--r--models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java5
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java13
2 files changed, 8 insertions, 10 deletions
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
index 2cc2a69f4..718047cfc 100644
--- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
@@ -117,9 +117,10 @@ public class AaiCustomQueryOperation extends HttpOperation<String> {
String url = str.toString();
- logMessage(EventType.OUT, CommInfrastructure.REST, url, request);
+ String strRequest = prettyPrint(request);
+ logMessage(EventType.OUT, CommInfrastructure.REST, url, strRequest);
- Entity<Map<String, String>> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
+ Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
return handleResponse(outcome, url, callback -> webldr.async().put(entity, callback));
}
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
index ca6cfb2f8..386eb219a 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
@@ -38,14 +38,11 @@ import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
-import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
import org.mockito.Mock;
import org.onap.policy.aai.AaiConstants;
import org.onap.policy.aai.AaiCqResponse;
@@ -70,9 +67,6 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
private static final String MY_VSERVER = "my-vserver-name";
private static final String SIM_VSERVER = "OzVServer";
- @Captor
- private ArgumentCaptor<Entity<Map<String, String>>> entityCaptor;
-
@Mock
private Actor tenantActor;
@@ -215,10 +209,13 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
oper.start();
executor.runAll(100);
- verify(webAsync).put(entityCaptor.capture(), any(InvocationCallback.class));
+ verify(webAsync).put(requestCaptor.capture(), any(InvocationCallback.class));
+
+ String reqText = requestCaptor.getValue().getEntity();
+ Map<String,String> reqMap = coder.decode(reqText, Map.class);
// sort the request fields so they match the order in cq.json
- Map<String, String> request = new TreeMap<>(entityCaptor.getValue().getEntity());
+ Map<String, String> request = new TreeMap<>(reqMap);
verifyRequest("cq.json", request);
}