aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-actors')
-rw-r--r--models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java5
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java13
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java2
-rw-r--r--models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java1
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java6
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java6
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java7
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java2
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java27
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java13
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java6
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java33
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java3
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java37
-rw-r--r--models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicHttpOperation.java2
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java6
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java3
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java14
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java2
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java40
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java6
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java17
22 files changed, 85 insertions, 166 deletions
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
index 2cc2a69f4..718047cfc 100644
--- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
@@ -117,9 +117,10 @@ public class AaiCustomQueryOperation extends HttpOperation<String> {
String url = str.toString();
- logMessage(EventType.OUT, CommInfrastructure.REST, url, request);
+ String strRequest = prettyPrint(request);
+ logMessage(EventType.OUT, CommInfrastructure.REST, url, strRequest);
- Entity<Map<String, String>> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
+ Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
return handleResponse(outcome, url, callback -> webldr.async().put(entity, callback));
}
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 ca6cfb2f8..386eb219a 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,14 +38,11 @@ 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 javax.ws.rs.client.InvocationCallback;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
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;
@@ -70,9 +67,6 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
private static final String MY_VSERVER = "my-vserver-name";
private static final String SIM_VSERVER = "OzVServer";
- @Captor
- private ArgumentCaptor<Entity<Map<String, String>>> entityCaptor;
-
@Mock
private Actor tenantActor;
@@ -215,10 +209,13 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
oper.start();
executor.runAll(100);
- verify(webAsync).put(entityCaptor.capture(), any(InvocationCallback.class));
+ verify(webAsync).put(requestCaptor.capture(), any(InvocationCallback.class));
+
+ String reqText = requestCaptor.getValue().getEntity();
+ Map<String,String> reqMap = coder.decode(reqText, Map.class);
// sort the request fields so they match the order in cq.json
- Map<String, String> request = new TreeMap<>(entityCaptor.getValue().getEntity());
+ Map<String, String> request = new TreeMap<>(reqMap);
verifyRequest("cq.json", request);
}
diff --git a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
index 704c44da7..393ce0ccb 100644
--- a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
@@ -57,7 +57,7 @@ public class AppcLcmActorServiceProvider extends BidirectionalTopicActor<Bidirec
* future review it would be better to distinguish them as two separate actors in the yaml but it should be okay for
* now.
*/
- private static final String NAME = "APPC";
+ public static final String NAME = "APPC";
private static final Logger logger = LoggerFactory.getLogger(AppcLcmActorServiceProvider.class);
diff --git a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java
index 9e136f09e..45ef34495 100644
--- a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProvider.java
@@ -59,6 +59,7 @@ import org.slf4j.LoggerFactory;
* operation types. The action taken is always the same, only the operation name changes.
*/
public class CdsActorServiceProvider extends ActorImpl {
+ public static final String NAME = CdsActorConstants.CDS_ACTOR;
private static final Logger LOGGER = LoggerFactory.getLogger(CdsActorServiceProvider.class);
diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java
index da1f95603..a21886bf2 100644
--- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java
+++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java
@@ -106,14 +106,16 @@ public class GuardOperation extends HttpOperation<DecisionResponse> {
@Override
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
DecisionRequest request = makeRequest();
- Entity<DecisionRequest> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
Map<String, Object> headers = makeHeaders();
headers.put("Accept", MediaType.APPLICATION_JSON);
String url = getUrl();
- logMessage(EventType.OUT, CommInfrastructure.REST, url, request);
+ String strRequest = prettyPrint(request);
+ logMessage(EventType.OUT, CommInfrastructure.REST, url, strRequest);
+
+ Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
// @formatter:off
return handleResponse(outcome, url,
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 ca6d07b16..9b6394315 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
@@ -61,7 +61,6 @@ public abstract class SdncOperation extends HttpOperation<SdncResponse> {
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
SdncRequest request = makeRequest(attempt);
- Entity<SdncRequest> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
Map<String, Object> headers = makeHeaders();
@@ -69,7 +68,10 @@ public abstract class SdncOperation extends HttpOperation<SdncResponse> {
String path = getPath();
String url = getClient().getBaseUrl() + path;
- logMessage(EventType.OUT, CommInfrastructure.REST, url, request);
+ String strRequest = prettyPrint(request);
+ logMessage(EventType.OUT, CommInfrastructure.REST, url, strRequest);
+
+ Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
// @formatter:off
return handleResponse(outcome, url,
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
index 921694269..5cc09560f 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
@@ -36,6 +36,7 @@ import java.util.concurrent.TimeoutException;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
+import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.controlloop.actor.test.BasicHttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
@@ -114,7 +115,7 @@ public abstract class BasicSdncOperation extends BasicHttpOperation<SdncRequest>
* @return the request that was posted
*/
protected SdncRequest verifyOperation(SdncOperation operation)
- throws InterruptedException, ExecutionException, TimeoutException {
+ throws InterruptedException, ExecutionException, TimeoutException, CoderException {
CompletableFuture<OperationOutcome> future2 = operation.start();
executor.runAll(100);
@@ -132,7 +133,9 @@ public abstract class BasicSdncOperation extends BasicHttpOperation<SdncRequest>
assertNotNull(outcome.getSubRequestId());
- return requestCaptor.getValue().getEntity();
+ String reqText = requestCaptor.getValue().getEntity();
+
+ return coder.decode(reqText, SdncRequest.class);
}
/**
diff --git a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java
index 5cb7af6ee..a43dcf774 100644
--- a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java
@@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
*/
public class SdnrActorServiceProvider extends BidirectionalTopicActor<BidirectionalTopicActorParams> {
- private static final String NAME = "SDNR";
+ public static final String NAME = "SDNR";
// TODO old code: remove lines down to **HERE**
diff --git a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java
index d0bb38e43..6c8f45d94 100644
--- a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java
+++ b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java
@@ -22,7 +22,6 @@ package org.onap.policy.controlloop.actor.sdnr;
import java.util.List;
import java.util.concurrent.CompletableFuture;
-import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation;
@@ -121,45 +120,19 @@ public class SdnrOperation extends BidirectionalTopicOperation<PciMessage, PciMe
outcome.setResponse(responseWrapper);
if (responseWrapper.getBody() == null || responseWrapper.getBody().getOutput() == null) {
- outcome.setControlLoopResponse(makeControlLoopResponse(null));
return setOutcome(outcome, result);
}
PciResponse pciResponse = responseWrapper.getBody().getOutput();
if (pciResponse.getStatus() == null || pciResponse.getStatus().getValue() == null) {
- outcome.setControlLoopResponse(makeControlLoopResponse(pciResponse.getPayload()));
return setOutcome(outcome, result);
}
outcome.setResult(result);
outcome.setMessage(pciResponse.getStatus().getValue());
- outcome.setControlLoopResponse(makeControlLoopResponse(pciResponse.getPayload()));
return outcome;
}
- /**
- * Converts the SDNR response to a ControlLoopResponse.
- *
- * @param responsePayload payload from the response
- *
- * @return a new ControlLoopResponse
- */
- private ControlLoopResponse makeControlLoopResponse(String responsePayload) {
- VirtualControlLoopEvent event = params.getContext().getEvent();
-
- ControlLoopResponse clRsp = new ControlLoopResponse();
- clRsp.setPayload(responsePayload);
- clRsp.setFrom(params.getActor());
- clRsp.setTarget("DCAE");
- clRsp.setClosedLoopControlName(event.getClosedLoopControlName());
- clRsp.setPolicyName(event.getPolicyName());
- clRsp.setPolicyVersion(event.getPolicyVersion());
- clRsp.setRequestId(event.getRequestId());
- clRsp.setVersion(event.getVersion());
-
- return clRsp;
- }
-
@Override
protected PciMessage makeRequest(int attempt) {
VirtualControlLoopEvent onset = params.getContext().getEvent();
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
index 370d6768e..7e9d263ad 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
@@ -36,7 +36,6 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
@@ -136,18 +135,6 @@ public class SdnrOperationTest extends BasicSdnrOperation {
outcome = operation.start().get();
assertEquals(PolicyResult.SUCCESS, outcome.getResult());
assertTrue(outcome.getResponse() instanceof PciMessage);
-
- ControlLoopResponse clresp = outcome.getControlLoopResponse();
- assertNotNull(clresp);
-
- assertEquals(DEFAULT_ACTOR, clresp.getFrom());
- assertEquals("DCAE", clresp.getTarget());
- assertEquals(CL_NAME, clresp.getClosedLoopControlName());
- assertEquals(EVENT_POLICY_NAME, clresp.getPolicyName());
- assertEquals(EVENT_POLICY_VERSION, clresp.getPolicyVersion());
- assertEquals(EVENT_VERSION, clresp.getVersion());
- assertEquals(REQ_ID, clresp.getRequestId());
- assertNotNull(clresp.getPayload());
}
@Test
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
index 077c8578b..6a6c79279 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
@@ -107,10 +107,12 @@ public class VfModuleCreate extends SoOperation {
String path = getPath() + pair.getLeft();
SoRequest request = pair.getRight();
- Entity<SoRequest> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
String url = getClient().getBaseUrl() + path;
- logMessage(EventType.OUT, CommInfrastructure.REST, url, request);
+ String strRequest = prettyPrint(request);
+ logMessage(EventType.OUT, CommInfrastructure.REST, url, strRequest);
+
+ Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
Map<String, Object> headers = createSimpleHeaders();
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
index 5134d58da..04f0287b7 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
@@ -45,7 +45,6 @@ import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
-import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
@@ -118,13 +117,14 @@ public class VfModuleDelete extends SoOperation {
SoRequest request = pair.getRight();
String url = getPath() + pair.getLeft();
- logMessage(EventType.OUT, CommInfrastructure.REST, url, request);
+ String strRequest = prettyPrint(request);
+ logMessage(EventType.OUT, CommInfrastructure.REST, url, strRequest);
Map<String, Object> headers = createSimpleHeaders();
// @formatter:off
return handleResponse(outcome, url,
- callback -> delete(url, headers, MediaType.APPLICATION_JSON, request, callback));
+ callback -> delete(url, headers, MediaType.APPLICATION_JSON, strRequest, callback));
// @formatter:on
}
@@ -143,12 +143,9 @@ public class VfModuleDelete extends SoOperation {
* future will actually cancel the underlying HTTP request
*/
protected <Q> CompletableFuture<Response> delete(String uri, Map<String, Object> headers, String contentType,
- Q request, InvocationCallback<Response> callback) {
+ String request, InvocationCallback<Response> callback) {
// TODO move to HttpOperation
- // make sure we can encode it before going any further
- final String body = encodeRequest(request);
-
final String url = getClient().getBaseUrl() + uri;
Builder builder = HttpRequest.newBuilder(URI.create(url));
@@ -161,7 +158,7 @@ public class VfModuleDelete extends SoOperation {
PipelineControllerFuture<Response> controller = new PipelineControllerFuture<>();
- HttpRequest req = builder.method("DELETE", BodyPublishers.ofString(body)).build();
+ HttpRequest req = builder.method("DELETE", BodyPublishers.ofString(request)).build();
CompletableFuture<HttpResponse<String>> future = makeHttpClient().sendAsync(req, BodyHandlers.ofString());
@@ -183,26 +180,6 @@ public class VfModuleDelete extends SoOperation {
}
/**
- * Encodes a request.
- *
- * @param <Q> request type
- * @param request request to be encoded
- * @return the encoded request
- */
- protected <Q> String encodeRequest(Q request) {
- // TODO move to HttpOperation
- try {
- if (request instanceof String) {
- return request.toString();
- } else {
- return makeCoder().encode(request);
- }
- } catch (CoderException e) {
- throw new IllegalArgumentException("cannot encode request", e);
- }
- }
-
- /**
* Adds the authorization header to the HTTP request, if configured.
*
* @param builder request builder to which the header should be added
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
index aaecb46a8..11418ff75 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
@@ -33,7 +33,6 @@ import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.gson.GsonMessageBodyHandler;
import org.onap.policy.controlloop.actor.test.BasicHttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.policy.Target;
@@ -93,7 +92,7 @@ public abstract class BasicSoOperation extends BasicHttpOperation<SoRequest> {
BusTopicParams clientParams = BusTopicParams.builder().clientName(MY_CLIENT).basePath("").hostname("localhost")
.managed(true).port(org.onap.policy.simulators.Util.SOSIM_SERVER_PORT)
- .serializationProvider(GsonMessageBodyHandler.class.getName()).build();
+ .build();
HttpClientFactoryInstance.getClientFactory().build(clientParams);
SoSimulatorJaxRs.setRequirePolling(true);
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
index 86242f042..f5d05a0e8 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
@@ -61,9 +61,7 @@ import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
-import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
@@ -271,8 +269,10 @@ public class VfModuleDeleteTest extends BasicSoOperation {
Map<String, Object> headers = Map.of("key-A", "value-A");
+ String reqText = oper.prettyPrint(req);
+
final CompletableFuture<Response> delFuture =
- oper.delete("my-uri", headers, MediaType.APPLICATION_JSON, req, callback);
+ oper.delete("my-uri", headers, MediaType.APPLICATION_JSON, reqText, callback);
ArgumentCaptor<HttpRequest> reqCaptor = ArgumentCaptor.forClass(HttpRequest.class);
verify(javaClient).sendAsync(reqCaptor.capture(), any());
@@ -311,8 +311,10 @@ public class VfModuleDeleteTest extends BasicSoOperation {
SoRequest req = new SoRequest();
req.setRequestId(REQ_ID);
+ String reqText = oper.prettyPrint(req);
+
CompletableFuture<Response> delFuture =
- oper.delete("/my-uri", Map.of(), MediaType.APPLICATION_JSON, req, callback);
+ oper.delete("/my-uri", Map.of(), MediaType.APPLICATION_JSON, reqText, callback);
assertTrue(delFuture.isCompletedExceptionally());
@@ -321,33 +323,6 @@ public class VfModuleDeleteTest extends BasicSoOperation {
assertSame(thrown, thrownCaptor.getValue().getCause());
}
- @Test
- public void testEncodeBody() {
- // try when request is already a string
- assertEquals("hello", oper.encodeRequest("hello"));
-
- // try with a real request
- SoRequest req = new SoRequest();
- req.setRequestId(REQ_ID);
- assertEquals("{\"requestId\":\"" + REQ_ID.toString() + "\"}", oper.encodeRequest(req));
-
- // coder throws an exception
- oper = new MyOperation(params, config) {
- @Override
- protected Coder makeCoder() {
- return new StandardCoder() {
- @Override
- public String encode(Object object) throws CoderException {
- throw new CoderException(EXPECTED_EXCEPTION);
- }
- };
- }
- };
-
- assertThatIllegalArgumentException().isThrownBy(() -> oper.encodeRequest(req))
- .withMessage("cannot encode request");
- }
-
/**
* Tests addAuthHeader() when there is a username, but no password.
*/
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 6786b7da9..4331edb04 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
@@ -53,7 +53,7 @@ public class BasicHttpOperation<Q> extends BasicOperation {
@Captor
protected ArgumentCaptor<InvocationCallback<Response>> callbackCaptor;
@Captor
- protected ArgumentCaptor<Entity<Q>> requestCaptor;
+ protected ArgumentCaptor<Entity<String>> requestCaptor;
@Captor
protected ArgumentCaptor<Map<String, Object>> headerCaptor;
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
index b7a41ddf0..5bd6b59ad 100644
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
@@ -42,6 +42,8 @@ public class VfcActorServiceProvider extends ActorImpl {
// Strings for VFC Actor
private static final String VFC_ACTOR = "VFC";
+ public static final String NAME = VFC_ACTOR;
+
// Strings for targets
private static final String TARGET_VM = "VM";
@@ -58,9 +60,9 @@ public class VfcActorServiceProvider extends ActorImpl {
* Constructor.
*/
public VfcActorServiceProvider() {
- super(VFC_ACTOR);
+ super(NAME);
- addOperator(new VfcOperator(VFC_ACTOR, Restart.NAME, Restart::new));
+ addOperator(new VfcOperator(NAME, Restart.NAME, Restart::new));
}
// TODO old code: remove lines down to **HERE**
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java
index 0fd2c0bfd..0c4350c63 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java
@@ -25,7 +25,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.onap.policy.controlloop.ControlLoopOperation;
-import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.policy.PolicyResult;
/**
@@ -44,7 +43,6 @@ public class OperationOutcome {
private String message;
private boolean finalOutcome;
private Object response;
- private ControlLoopResponse controlLoopResponse;
/**
* Copy constructor.
@@ -62,7 +60,6 @@ public class OperationOutcome {
this.message = source.message;
this.finalOutcome = source.finalOutcome;
this.response = source.response;
- this.controlLoopResponse = source.controlLoopResponse;
}
/**
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
index 8285a5635..2a460667a 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
@@ -166,18 +166,8 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial
* @param request request to be published
*/
protected void publishRequest(Q request) {
- String json;
- try {
- if (request instanceof String) {
- json = request.toString();
- } else {
- json = makeCoder().encode(request);
- }
- } catch (CoderException e) {
- throw new IllegalArgumentException("cannot encode request", e);
- }
-
- logMessage(EventType.OUT, topicHandler.getSinkTopicCommInfrastructure(), topicHandler.getSinkTopic(), request);
+ String json = prettyPrint(request);
+ logMessage(EventType.OUT, topicHandler.getSinkTopicCommInfrastructure(), topicHandler.getSinkTopic(), json);
if (!topicHandler.send(json)) {
throw new IllegalStateException("nothing published");
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
index 1acc1ff65..766468c07 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
@@ -177,7 +177,7 @@ public abstract class HttpOperation<T> extends OperationPartial {
logger.info("{}.{}: response received for {}", params.getActor(), params.getOperation(), params.getRequestId());
- String strResponse = HttpClient.getBody(rawResponse, String.class);
+ String strResponse = rawResponse.readEntity(String.class);
logMessage(EventType.IN, CommInfrastructure.REST, url, strResponse);
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
index 4aa723614..1df318799 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
@@ -989,30 +989,24 @@ public abstract class OperationPartial implements Operation {
}
/**
- * Logs a response. If the response is not of type, String, then it attempts to
+ * Logs a message. If the message is not of type, String, then it attempts to
* pretty-print it into JSON before logging.
*
* @param direction IN or OUT
* @param infra communication infrastructure on which it was published
* @param source source name (e.g., the URL or Topic name)
- * @param response response to be logged
+ * @param message message to be logged
* @return the JSON text that was logged
*/
- public <T> String logMessage(EventType direction, CommInfrastructure infra, String source, T response) {
+ public <T> String logMessage(EventType direction, CommInfrastructure infra, String source, T message) {
String json;
try {
- if (response == null) {
- json = null;
- } else if (response instanceof String) {
- json = response.toString();
- } else {
- json = makeCoder().encode(response, true);
- }
+ json = prettyPrint(message);
- } catch (CoderException e) {
+ } catch (IllegalArgumentException e) {
String type = (direction == EventType.IN ? "response" : "request");
logger.warn("cannot pretty-print {}", type, e);
- json = response.toString();
+ json = message.toString();
}
logger.info("[{}|{}|{}|]{}{}", direction, infra, source, NetLoggerUtil.SYSTEM_LS, json);
@@ -1020,6 +1014,28 @@ public abstract class OperationPartial implements Operation {
return json;
}
+ /**
+ * Converts a message to a "pretty-printed" String using the operation's normal
+ * serialization provider (i.e., it's <i>coder</i>).
+ *
+ * @param message response to be logged
+ * @return the JSON text that was logged
+ * @throws IllegalArgumentException if the message cannot be converted
+ */
+ public <T> String prettyPrint(T message) {
+ if (message == null) {
+ return null;
+ } else if (message instanceof String) {
+ return message.toString();
+ } else {
+ try {
+ return makeCoder().encode(message, true);
+ } catch (CoderException e) {
+ throw new IllegalArgumentException("cannot encode message", e);
+ }
+ }
+ }
+
// these may be overridden by subclasses or junit tests
/**
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
index c60a0f00c..5820becc5 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
@@ -30,7 +30,6 @@ import java.time.Instant;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.controlloop.ControlLoopOperation;
-import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.policy.PolicyResult;
public class OperationOutcomeTest {
@@ -44,7 +43,6 @@ public class OperationOutcomeTest {
private static final String MESSAGE = "my-message";
private static final String RESPONSE = "my-response";
- private ControlLoopResponse response;
private OperationOutcome outcome;
/**
@@ -52,8 +50,6 @@ public class OperationOutcomeTest {
*/
@Before
public void setUp() {
- response = new ControlLoopResponse();
-
outcome = new OperationOutcome();
}
@@ -72,7 +68,6 @@ public class OperationOutcomeTest {
assertEquals(RESULT, outcome2.getResult());
assertEquals(MESSAGE, outcome2.getMessage());
assertSame(RESPONSE, outcome2.getResponse());
- assertSame(response, outcome2.getControlLoopResponse());
}
@Test
@@ -145,6 +140,5 @@ public class OperationOutcomeTest {
outcome.setSubRequestId(SUB_REQ_ID);
outcome.setTarget(TARGET);
outcome.setResponse(RESPONSE);
- outcome.setControlLoopResponse(response);
}
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java
index eb1aa880f..291811a6e 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java
@@ -150,8 +150,7 @@ public class HttpOperationTest {
/*
* Start the clients, one to the server, and one to a non-existent server.
*/
- TopicParamsBuilder builder = BusTopicParams.builder().managed(true).hostname("localhost").basePath(BASE_URI)
- .serializationProvider(GsonMessageBodyHandler.class.getName());
+ TopicParamsBuilder builder = BusTopicParams.builder().managed(true).hostname("localhost").basePath(BASE_URI);
HttpClientFactoryInstance.getClientFactory().build(builder.clientName(HTTP_CLIENT).port(port).build());
@@ -532,14 +531,15 @@ public class HttpOperationTest {
MyRequest request = new MyRequest();
- Entity<MyRequest> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
-
Map<String, Object> headers = makeHeaders();
headers.put("Accept", MediaType.APPLICATION_JSON);
String url = getUrl();
- logMessage(EventType.OUT, CommInfrastructure.REST, url, request);
+ String strRequest = prettyPrint(request);
+ logMessage(EventType.OUT, CommInfrastructure.REST, url, strRequest);
+
+ Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
// @formatter:off
return handleResponse(outcome, url,
@@ -558,14 +558,15 @@ public class HttpOperationTest {
MyRequest request = new MyRequest();
- Entity<MyRequest> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
-
Map<String, Object> headers = makeHeaders();
headers.put("Accept", MediaType.APPLICATION_JSON);
String url = getUrl();
- logMessage(EventType.OUT, CommInfrastructure.REST, url, request);
+ String strRequest = prettyPrint(request);
+ logMessage(EventType.OUT, CommInfrastructure.REST, url, strRequest);
+
+ Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
// @formatter:off
return handleResponse(outcome, url,