summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.test/src/main
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2020-03-03 19:41:16 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-03 19:41:16 +0000
commit3f06effedc552c31e2608f5b8871301ba5b23033 (patch)
tree893ed3ba8150da12a8518931e7f283d0e26d0967 /models-interactions/model-actors/actor.test/src/main
parent106c7fdc3e64431e64d66a7546033f6c21f9bfb4 (diff)
parent9bd821d6a2b49dacb7286d58f11d5cd1cc7e0aa2 (diff)
Merge "Fix path issues"
Diffstat (limited to 'models-interactions/model-actors/actor.test/src/main')
-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);
};