summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.aai/src/test
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.aai/src/test
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.aai/src/test')
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java17
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java9
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/resources/service.yaml2
3 files changed, 18 insertions, 10 deletions
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 78ffc50e0..c24e45db7 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,6 +38,7 @@ 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.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -109,11 +110,12 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
}
@Test
+ @SuppressWarnings("unchecked")
public void testStartOperationAsync_testStartPreprocessorAsync_testMakeRequest_testPostProcess() throws Exception {
// need two responses
when(rawResponse.readEntity(String.class)).thenReturn(makeTenantReply()).thenReturn(makeCqReply());
- when(client.get(any(), any(), any())).thenAnswer(provideResponse(rawResponse));
- when(client.put(any(), any(), any(), any())).thenAnswer(provideResponse(rawResponse));
+ when(webAsync.get(any(InvocationCallback.class))).thenAnswer(provideResponse(rawResponse));
+ when(webAsync.put(any(), any(InvocationCallback.class))).thenAnswer(provideResponse(rawResponse, 1));
CompletableFuture<OperationOutcome> future2 = oper.start();
@@ -131,13 +133,14 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
* Tests when preprocessor step is not needed.
*/
@Test
+ @SuppressWarnings("unchecked")
public void testStartOperationAsync_testStartPreprocessorAsyncNotNeeded() throws Exception {
// pre-load the tenant data
final StandardCoderObject data = preloadTenantData();
// only need one response
when(rawResponse.readEntity(String.class)).thenReturn(makeCqReply());
- when(client.put(any(), any(), any(), any())).thenAnswer(provideResponse(rawResponse));
+ when(webAsync.put(any(), any(InvocationCallback.class))).thenAnswer(provideResponse(rawResponse, 1));
CompletableFuture<OperationOutcome> future2 = oper.start();
@@ -157,17 +160,18 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
}
@Test
+ @SuppressWarnings("unchecked")
public void testMakeRequest() throws Exception {
// preload
preloadTenantData();
when(rawResponse.readEntity(String.class)).thenReturn(makeCqReply());
- when(client.put(any(), any(), any(), any())).thenAnswer(provideResponse(rawResponse));
+ when(webAsync.put(any(), any(InvocationCallback.class))).thenAnswer(provideResponse(rawResponse, 1));
oper.start();
executor.runAll(100);
- verify(client).put(any(), any(), entityCaptor.capture(), any());
+ verify(webAsync).put(entityCaptor.capture(), any(InvocationCallback.class));
// sort the request fields so they match the order in cq.json
Map<String, String> request = new TreeMap<>(entityCaptor.getValue().getEntity());
@@ -176,12 +180,13 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
}
@Test
+ @SuppressWarnings("unchecked")
public void testMakeRequestNoResourceLink() throws Exception {
// pre-load EMPTY tenant data
preloadTenantData(new StandardCoderObject());
when(rawResponse.readEntity(String.class)).thenReturn(makeCqReply());
- when(client.put(any(), any(), any(), any())).thenAnswer(provideResponse(rawResponse));
+ when(webAsync.put(any(), any(InvocationCallback.class))).thenAnswer(provideResponse(rawResponse, 1));
CompletableFuture<OperationOutcome> future2 = oper.start();
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java
index 4681d9ef4..13560ccf3 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
+import javax.ws.rs.client.InvocationCallback;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.aai.AaiConstants;
@@ -69,13 +70,14 @@ public class AaiGetOperationTest extends BasicAaiOperation<Void> {
}
@Test
+ @SuppressWarnings("unchecked")
public void testStartOperationAsync_testStartQueryAsync_testPostProcessResponse() throws Exception {
// return a map in the reply
Map<String, String> reply = Map.of(INPUT_FIELD, TEXT);
when(rawResponse.readEntity(String.class)).thenReturn(new StandardCoder().encode(reply));
- when(client.get(any(), any(), any())).thenAnswer(provideResponse(rawResponse));
+ when(webAsync.get(any(InvocationCallback.class))).thenAnswer(provideResponse(rawResponse));
CompletableFuture<OperationOutcome> future2 = oper.startOperationAsync(1, outcome);
assertFalse(future2.isDone());
@@ -95,12 +97,13 @@ public class AaiGetOperationTest extends BasicAaiOperation<Void> {
* Tests startOperationAsync() when there's a failure.
*/
@Test
+ @SuppressWarnings("unchecked")
public void testStartOperationAsyncFailure() throws Exception {
when(rawResponse.getStatus()).thenReturn(500);
when(rawResponse.readEntity(String.class)).thenReturn("");
- when(client.get(any(), any(), any())).thenAnswer(provideResponse(rawResponse));
+ when(webAsync.get(any(InvocationCallback.class))).thenAnswer(provideResponse(rawResponse));
CompletableFuture<OperationOutcome> future2 = oper.startOperationAsync(1, outcome);
assertFalse(future2.isDone());
@@ -121,7 +124,7 @@ public class AaiGetOperationTest extends BasicAaiOperation<Void> {
@Test
public void testMakePath() {
- assertEquals(PATH + "/" + TARGET_ENTITY, oper.makePath());
+ assertEquals(PATH + TARGET_ENTITY, oper.makePath());
}
@Test
diff --git a/models-interactions/model-actors/actor.aai/src/test/resources/service.yaml b/models-interactions/model-actors/actor.aai/src/test/resources/service.yaml
index 9f6561de0..d0c11be7b 100644
--- a/models-interactions/model-actors/actor.aai/src/test/resources/service.yaml
+++ b/models-interactions/model-actors/actor.aai/src/test/resources/service.yaml
@@ -21,7 +21,7 @@ httpClients:
- clientName: my-client
hostname: localhost
port: 80
- basePath: base-url
+ basePath: base-url/
managed: true
actors:
AAI: