summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.so/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-05-29 16:32:57 -0400
committerJim Hahn <jrh3@att.com>2020-05-29 16:51:29 -0400
commit45e3d3ae1cc5a4c29526da4f4cb6096e1b6d7d4f (patch)
tree02b5f1fa7f150ef86846d37143b008e292ce9eaa /models-interactions/model-actors/actor.so/src/test
parent6d5459569af6a9c70abf5a8bbb54917decd37b38 (diff)
Use "coder" to serialize Actor requests
Modified the Actors to use the "coder" to serialize requests instead of defaulting to the HttpClient serialization provider. Decided to just pretty-print the requests since that can be used for both logging and transmission, which avoids serializing the request twice. Issue-ID: POLICY-2601 Change-Id: I190ed19dd852a1aa66156b358cbc97c3b121af1f Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.so/src/test')
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java37
1 files changed, 6 insertions, 31 deletions
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.
*/