summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.test/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-03-02 16:17:36 -0500
committerJim Hahn <jrh3@att.com>2020-03-03 01:12:53 +0000
commit9bd821d6a2b49dacb7286d58f11d5cd1cc7e0aa2 (patch)
treeed9218821be37c3f060eb3dc64b7f89327f70164 /models-interactions/model-actors/actor.test/src
parentd5fc0bddf4f1e02d47a95d070c000ff0a6557edd (diff)
Fix path issues
A&AI tenant query is prepending the target entity with "/", but it should not. Fixed it. Modified A&AI and SO actors to get path prefixes from parameters. Fixed a bug in an A&AI simulator response (extra "}" at the end. Issue-ID: POLICY-2349 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I71f8b1e5fb8a4bd29b4f616a7757d366c7d58127
Diffstat (limited to 'models-interactions/model-actors/actor.test/src')
-rw-r--r--models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicHttpOperation.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicHttpOperation.java b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicHttpOperation.java
index e803df8c9..6228756bd 100644
--- a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicHttpOperation.java
+++ b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicHttpOperation.java
@@ -20,12 +20,16 @@
package org.onap.policy.controlloop.actor.test;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
+import javax.ws.rs.client.AsyncInvoker;
import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.client.InvocationCallback;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
@@ -55,6 +59,12 @@ public class BasicHttpOperation<Q> extends BasicOperation {
@Mock
protected HttpConfig config;
@Mock
+ protected WebTarget webTarget;
+ @Mock
+ protected Builder webBuilder;
+ @Mock
+ protected AsyncInvoker webAsync;
+ @Mock
protected HttpClient client;
@Mock
protected HttpClientFactory factory;
@@ -90,6 +100,14 @@ public class BasicHttpOperation<Q> extends BasicOperation {
when(rawResponse.getStatus()).thenReturn(200);
+ when(webBuilder.async()).thenReturn(webAsync);
+
+ when(webTarget.request()).thenReturn(webBuilder);
+ when(webTarget.path(any())).thenReturn(webTarget);
+ when(webTarget.queryParam(any(), any())).thenReturn(webTarget);
+
+ when(client.getWebTarget()).thenReturn(webTarget);
+
when(client.getBaseUrl()).thenReturn(BASE_URI);
initConfig();
@@ -110,8 +128,19 @@ public class BasicHttpOperation<Q> extends BasicOperation {
* @return a function that provides the response to the call
*/
protected Answer<CompletableFuture<Response>> provideResponse(Response response) {
+ return provideResponse(response, 0);
+ }
+
+ /**
+ * Provides a response to an asynchronous HttpClient call.
+ *
+ * @param response response to be provided to the call
+ * @param index index of the callback within the arguments
+ * @return a function that provides the response to the call
+ */
+ protected Answer<CompletableFuture<Response>> provideResponse(Response response, int index) {
return args -> {
- InvocationCallback<Response> cb = args.getArgument(0);
+ InvocationCallback<Response> cb = args.getArgument(index);
cb.completed(response);
return CompletableFuture.completedFuture(response);
};