From b92b1f86492d1fb0e546ef5124116abdf2d07dc9 Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Thu, 30 Aug 2018 19:06:46 -0400 Subject: Update Logging Add CXF interceptor for SOAP based logging Clean up extra logging statements Add UT to ensure MDC properly populated Change package name on Jax-RS Filter to be more accurate Issue-ID: SO-947 Change-Id: I3a2afc58de3bf370675658ce3d19cf899b90def7 Change-Id: I3a2afc58de3bf370675658ce3d19cf899b90def7 Signed-off-by: Smokowski, Steve (ss835w) --- .../java/org/onap/so/apihandlerinfra/JerseyConfiguration.java | 2 +- .../process/CreateEcompOperationalEnvironment.java | 4 ++-- .../org/onap/so/apihandlerinfra/ServiceInstancesTest.java | 3 ++- .../process/CreateEcompOperationalEnvironmentTest.java | 11 ++++++----- 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-infra') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java index 1700e121f0..e6bbc4de4a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java @@ -29,7 +29,7 @@ import org.onap.so.apihandler.filters.RequestUriFilter; import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestration; import org.onap.so.apihandlerinfra.tenantisolation.CloudResourcesOrchestration; -import org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging; +import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging; import org.onap.so.web.exceptions.RuntimeExceptionMapper; import org.springframework.context.annotation.Configuration; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java index c16f7bb9ef..b09bbae0ad 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java @@ -76,8 +76,8 @@ public class CreateEcompOperationalEnvironment { requestDb.updateInfraFailureCompletion(e.getMessage(), requestId, request.getOperationalEnvironmentId()); throw validateException; } - //Update request database - requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", requestId, request.getOperationalEnvironmentId()); + //Update request database + requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", requestId, request.getOperationalEnvironmentId()); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 5b37d772c6..76f4bb08a2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -29,6 +29,7 @@ import com.github.tomakehurst.wiremock.http.Fault; import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -1934,7 +1935,7 @@ public class ServiceInstancesTest extends BaseTest{ @Test public void invalidRequestId() throws IOException { String illegalRequestId = "1234"; - headers.set("X-ECOMP-RequestID", illegalRequestId); + headers.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId); uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java index 0ace9d5445..585eff23c4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java @@ -23,7 +23,7 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertThat; - +import java.util.UUID; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.http.HttpStatus; @@ -107,22 +107,23 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{ .errorInfo(errorLoggerInfo).build(); InfraActiveRequests iar = new InfraActiveRequests(); - iar.setRequestId("123"); + String uuid = UUID.randomUUID().toString(); + iar.setRequestId(uuid); iar.setOperationalEnvName("myOpEnv"); iar.setRequestScope("create"); iar.setRequestStatus("PENDING"); iar.setRequestAction("UNKNOWN"); - stubFor(get(urlPathEqualTo("/infraActiveRequests/123")) + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+uuid)) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(iar)) .withStatus(HttpStatus.SC_OK))); stubFor(post(urlPathEqualTo("/infraActiveRequests/")) - .withRequestBody(containing("{\"requestId\":\"123\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"FAILURE, operationalEnvironmentId - operationalEnvId; Error message: empty")) + .withRequestBody(containing("{\"requestId\":\""+uuid+ "\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"FAILURE, operationalEnvironmentId - operationalEnvId; Error message:")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); try { - createEcompOpEn.execute("123", getCloudOrchestrationRequest()); + createEcompOpEn.execute(uuid, getCloudOrchestrationRequest()); }catch(ApiException e){ assertThat(e, sameBeanAs((ApiException) expectedException).ignoring("cause")); } -- cgit 1.2.3-korg