From 3c1fb89886d7ebf2efe1183e92b4ed8191f506b4 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 6 Mar 2020 14:00:58 -0500 Subject: Log full URL for REST calls Actors only log the URI, without the host and port info. Modified to log the full URL. Also adjusted URLs for trailing "/". Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn Change-Id: I0c9a2d139258ef23bc363a873b56f5cb4680247d --- .../controlloop/actor/aai/AaiGetOperation.java | 5 ----- .../controlloop/actor/aai/AaiGetOperationTest.java | 5 ----- .../controlloop/actor/guard/GuardOperation.java | 4 ++-- .../controlloop/actor/sdnc/SdncOperationTest.java | 2 +- .../controlloop/actor/test/BasicHttpOperation.java | 4 ++-- .../actorserviceprovider/impl/HttpOperation.java | 24 +++++++++------------- .../impl/HttpOperationTest.java | 22 ++++++++++---------- 7 files changed, 26 insertions(+), 40 deletions(-) (limited to 'models-interactions') diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java index 4c4124189..b527abc36 100644 --- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java +++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java @@ -131,11 +131,6 @@ public class AaiGetOperation extends HttpOperation { return AaiUtil.makeHeaders(params); } - @Override - public String makePath() { - return (getPath() + params.getTargetEntity()); - } - /** * Injects the response into the context. */ diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java index 13560ccf3..8e2633141 100644 --- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java +++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java @@ -122,11 +122,6 @@ public class AaiGetOperationTest extends BasicAaiOperation { verifyHeaders(oper.makeHeaders()); } - @Test - public void testMakePath() { - assertEquals(PATH + TARGET_ENTITY, oper.makePath()); - } - @Test public void testAaiGetOperator() { assertEquals(AaiConstants.ACTOR_NAME, oper.getActorName()); 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 e35caa06c..dd8b9273a 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 @@ -96,13 +96,13 @@ public class GuardOperation extends HttpOperation { Map headers = makeHeaders(); headers.put("Accept", MediaType.APPLICATION_JSON); - String url = makeUrl(); + String url = getUrl(); logMessage(EventType.OUT, CommInfrastructure.REST, url, request); // @formatter:off return handleResponse(outcome, url, - callback -> getClient().post(callback, makePath(), entity, headers)); + callback -> getClient().post(callback, getPath(), entity, headers)); // @formatter:on } diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java index 1a1cc5559..a83c354d2 100644 --- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java +++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java @@ -33,7 +33,7 @@ import org.onap.policy.sdnc.SdncRequest; public class SdncOperationTest extends BasicSdncOperation { - private static final String MY_URI = "/my-uri"; + private static final String MY_URI = "my-uri"; private SdncRequest request; private SdncOperation oper; 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 81156c184..6786b7da9 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 @@ -47,8 +47,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; */ public class BasicHttpOperation extends BasicOperation { protected static final String MY_CLIENT = "my-client"; - protected static final String BASE_URI = "/base-uri"; - protected static final String PATH = "/my-path"; + protected static final String BASE_URI = "http://my-host:6969/base-uri/"; + protected static final String PATH = "my-path/"; @Captor protected ArgumentCaptor> callbackCaptor; 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 aa98c0d36..e83fe8c94 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 @@ -80,6 +80,12 @@ public abstract class HttpOperation extends OperationPartial { return config.getClient(); } + /** + * Gets the path to be used when performing the request; this is typically appended to + * the base URL. This method simply invokes {@link #getPath()}. + * + * @return the path URI suffix + */ public String getPath() { return config.getPath(); } @@ -106,24 +112,14 @@ public abstract class HttpOperation extends OperationPartial { } /** - * Gets the path to be used when performing the request; this is typically appended to - * the base URL. This method simply invokes {@link #getPath()}. - * - * @return the path URI suffix - */ - public String makePath() { - return getPath(); - } - - /** - * Makes the URL to which the "get" request should be posted. This is primarily used + * Makes the URL to which the HTTP request should be posted. This is primarily used * for logging purposes. This particular method returns the base URL appended with the - * return value from {@link #makePath()}. + * return value from {@link #getPath()}. * * @return the URL to which from which to get */ - public String makeUrl() { - return (getClient().getBaseUrl() + makePath()); + public String getUrl() { + return (getClient().getBaseUrl() + getPath()); } /** 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 2e9f58cbc..81238defa 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 @@ -216,8 +216,8 @@ public class HttpOperationTest { } @Test - public void testMakePath() { - assertEquals(PATH, oper.makePath()); + public void testGetPath() { + assertEquals(PATH, oper.getPath()); } @Test @@ -227,7 +227,7 @@ public class HttpOperationTest { oper = new MyGetOperation<>(String.class); - assertThat(oper.makeUrl()).endsWith("/" + BASE_URI + PATH); + assertThat(oper.getUrl()).endsWith("/" + BASE_URI + PATH); } @Test @@ -503,13 +503,13 @@ public class HttpOperationTest { Map headers = makeHeaders(); headers.put("Accept", MediaType.APPLICATION_JSON); - String url = makeUrl(); + String url = getUrl(); logMessage(EventType.OUT, CommInfrastructure.REST, url, null); // @formatter:off return handleResponse(outcome, url, - callback -> getClient().get(callback, makePath(), headers)); + callback -> getClient().get(callback, getPath(), headers)); // @formatter:on } } @@ -529,13 +529,13 @@ public class HttpOperationTest { Map headers = makeHeaders(); headers.put("Accept", MediaType.APPLICATION_JSON); - String url = makeUrl(); + String url = getUrl(); logMessage(EventType.OUT, CommInfrastructure.REST, url, request); // @formatter:off return handleResponse(outcome, url, - callback -> getClient().post(callback, makePath(), entity, headers)); + callback -> getClient().post(callback, getPath(), entity, headers)); // @formatter:on } } @@ -555,13 +555,13 @@ public class HttpOperationTest { Map headers = makeHeaders(); headers.put("Accept", MediaType.APPLICATION_JSON); - String url = makeUrl(); + String url = getUrl(); logMessage(EventType.OUT, CommInfrastructure.REST, url, request); // @formatter:off return handleResponse(outcome, url, - callback -> getClient().put(callback, makePath(), entity, headers)); + callback -> getClient().put(callback, getPath(), entity, headers)); // @formatter:on } } @@ -576,13 +576,13 @@ public class HttpOperationTest { Map headers = makeHeaders(); headers.put("Accept", MediaType.APPLICATION_JSON); - String url = makeUrl(); + String url = getUrl(); logMessage(EventType.OUT, CommInfrastructure.REST, url, null); // @formatter:off return handleResponse(outcome, url, - callback -> getClient().delete(callback, makePath(), headers)); + callback -> getClient().delete(callback, getPath(), headers)); // @formatter:on } } -- cgit 1.2.3-korg