diff options
Diffstat (limited to 'models-interactions/model-actors/actor.aai')
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" +} |