aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.aai
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-02-18 15:28:39 -0500
committerJim Hahn <jrh3@att.com>2020-02-18 16:39:14 -0500
commit4ccc26577b51545b4b4db6823c6d926bc0ffc5a4 (patch)
tree81e84b3579d4ac7af81dcc25649db5e3d926c8e5 /models-interactions/model-actors/actor.aai
parentca409ee108f3f653d66be804e8a9f95f794e26d4 (diff)
Validate request content of various actors
Created common junit superclass, BasicOperation, containing verifyRequest() method, among others. Issue-ID: POLICY-2363 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I7ff4428e94bfd301ff4194e1766ef61906714dcf
Diffstat (limited to 'models-interactions/model-actors/actor.aai')
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java27
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/resources/cq.json4
2 files changed, 31 insertions, 0 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 a93508757..05b07fb07 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
@@ -25,16 +25,21 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+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 org.junit.Before;
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;
@@ -55,6 +60,9 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
private static final String MY_LINK = "my-link";
+ @Captor
+ private ArgumentCaptor<Entity<Map<String, String>>> entityCaptor;
+
@Mock
private Actor tenantActor;
@@ -134,6 +142,25 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
}
@Test
+ public void testMakeRequest() throws Exception {
+ // preload
+ preloadTenantData();
+
+ when(rawResponse.readEntity(String.class)).thenReturn(makeCqReply());
+ when(client.put(any(), any(), any(), any())).thenAnswer(provideResponse(rawResponse));
+
+ oper.start();
+ executor.runAll(100);
+
+ verify(client).put(any(), any(), entityCaptor.capture(), any());
+
+ // sort the request fields so they match the order in cq.json
+ Map<String, String> request = new TreeMap<>(entityCaptor.getValue().getEntity());
+
+ verifyRequest("cq.json", request);
+ }
+
+ @Test
public void testMakeRequestNoResourceLink() throws Exception {
// pre-load EMPTY tenant data
preloadTenantData(new StandardCoderObject());
diff --git a/models-interactions/model-actors/actor.aai/src/test/resources/cq.json b/models-interactions/model-actors/actor.aai/src/test/resources/cq.json
new file mode 100644
index 000000000..0b8fcb9f0
--- /dev/null
+++ b/models-interactions/model-actors/actor.aai/src/test/resources/cq.json
@@ -0,0 +1,4 @@
+{
+ "query": "query/closed-loop",
+ "start": "my-link"
+}