From 28ca4d196bb0e8c50ad64b5bfde117a93ace3e04 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 14 Feb 2020 14:22:48 -0500 Subject: Use BidirectionalTopicClient from policy-common Also modified "target" to sink in various places, and renamed various uses of "pair" to "bidirectional" (e.g., TopicPairParams => BidirectionalTopicParams). Also replaced MyExec with PseudoExecutor, from policy-common. As part of this, extracted the logRequest and logResponse methods from the Http and Topic classes, moving them into the common OperationPartial class. Modified A&AI, SDNC junit tests to use PseudoExecutor. Added support for incomplete responses on Topics, where multiple responses may be received for one request Fixed a duplicate entry in actor.aai pom. As the changes were already big enough, went ahead and also did the following to support the APPC Actor: - Reorganized parameter classes and content. - Modified anyOf, allOf to take functions instead of futures and handle exceptions thrown by any of the functions. Also added sequence() method. - Deleted doTask. - Modified ActorService.config to take a map of maps, not just a map. - Decided NOT to move anyOf, allOf, and sequence from OperationPartial to a utility class, because they depend on "params". Issue-ID: POLICY-2363 Signed-off-by: Jim Hahn Change-Id: I5a8bae05dfef22fe71c57c58f265b9dac20df5c5 --- .../onap/policy/controlloop/actor/sdnc/SdncOperation.java | 12 +++++++++++- .../policy/controlloop/actor/sdnc/BasicSdncOperator.java | 7 +++++-- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'models-interactions/model-actors/actor.sdnc') diff --git a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java index 9d42c49d9..406722ef5 100644 --- a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java +++ b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java @@ -25,6 +25,8 @@ import java.util.concurrent.CompletableFuture; import javax.ws.rs.client.Entity; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator; @@ -47,6 +49,14 @@ public abstract class SdncOperation extends HttpOperation { super(params, operator, SdncResponse.class); } + /** + * Starts the GUARD. + */ + @Override + protected CompletableFuture startPreprocessorAsync() { + return startGuardAsync(); + } + @Override protected CompletableFuture startOperationAsync(int attempt, OperationOutcome outcome) { @@ -59,7 +69,7 @@ public abstract class SdncOperation extends HttpOperation { headers.put("Accept", MediaType.APPLICATION_JSON); String url = makeUrl(); - logRestRequest(url, request); + logMessage(EventType.OUT, CommInfrastructure.REST, url, request); // @formatter:off return handleResponse(outcome, url, diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperator.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperator.java index d8c707cc3..deafc4e9d 100644 --- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperator.java +++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperator.java @@ -23,6 +23,7 @@ package org.onap.policy.controlloop.actor.sdnc; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -30,7 +31,6 @@ import static org.mockito.Mockito.when; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.BiFunction; import org.onap.policy.common.utils.coder.CoderException; @@ -100,7 +100,10 @@ public abstract class BasicSdncOperator extends BasicHttpOperation verify(client).post(callbackCaptor.capture(), any(), requestCaptor.capture(), any()); callbackCaptor.getValue().completed(rawResponse); - assertEquals(PolicyResult.SUCCESS, future2.get(5, TimeUnit.SECONDS).getResult()); + executor.runAll(100); + assertTrue(future2.isDone()); + + assertEquals(PolicyResult.SUCCESS, future2.get().getResult()); return requestCaptor.getValue().getEntity(); } -- cgit 1.2.3-korg