aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test/java/org
diff options
context:
space:
mode:
authorSmokowski, Steve (ss835w) <ss835w@us.att.com>2018-08-13 09:05:45 -0400
committerSmokowski, Steve (ss835w) <ss835w@us.att.com>2018-08-13 14:53:57 -0400
commit26aefcd7cc7a4959ba9e98653f4cd3f872c69b34 (patch)
tree6531e673aace32aa01984818fd85ae2f44ad0252 /mso-api-handlers/mso-api-handler-infra/src/test/java/org
parenta81aef2172c2cb4c6735f6018aee7deb04140b5d (diff)
Update CatalogDB Logging
Update CatalogDB Logging to remove MSO Logger, remove useless log lines, clean up minor sonar issues while working in the file Issue-ID: SO-847 Change-Id: Icab5d8cf2885d2193bb55f495b3230dde0f5af54 Change-Id: I2d2b2fa919074c439b6c9039aa7ed5e45a792781 Signed-off-by: Smokowski, Steve (ss835w) <ss835w@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java135
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java55
2 files changed, 114 insertions, 76 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
index c9d83efced..5d6aa43a9b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
@@ -26,6 +26,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import java.io.IOException;
@@ -57,62 +58,80 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
public class ManualTasksTest extends BaseTest{
- private final String basePath = "/tasks/v1/";
-
-
-
- @Test
- public void testCreateOpEnvObjectMapperError() throws IOException {
- TestAppender.events.clear();
- stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
-
- String taskId = "55";
- TasksRequest taskReq = new TasksRequest();
- RequestDetails reqDetail = new RequestDetails();
- RequestInfo reqInfo = new RequestInfo();
- reqInfo.setRequestorId("testId");
- reqInfo.setSource("testSource");
- reqInfo.setResponseValue(ValidResponses.skip);
- reqDetail.setRequestInfo(reqInfo);
- taskReq.setRequestDetails(reqDetail);
-
- //expected response
- TaskRequestReference expectedResponse = new TaskRequestReference();
- expectedResponse.setTaskId(taskId);
-
- headers.set("Accept", MediaType.APPLICATION_JSON);
- headers.set("Content-Type", MediaType.APPLICATION_JSON);
- headers.set(MsoLogger.ECOMP_REQUEST_ID, "987654321");
- headers.set(MsoLogger.CLIENT_ID, "VID");
- HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers);
-
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete");
- ResponseEntity<String> response = restTemplate.exchange(
- builder.toUriString(),
- HttpMethod.POST, entity, String.class);
-
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- TaskRequestReference realResponse = mapper.readValue(response.getBody(), TaskRequestReference.class);
-
-
- //then
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- assertThat(realResponse, sameBeanAs(expectedResponse));
- ILoggingEvent logEvent = TestAppender.events.get(0);
- Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertEquals("987654321", mdc.get(MsoLogger.REQUEST_ID));
- assertEquals("VID", mdc.get(MsoLogger.CLIENT_ID));
- assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
- assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
- assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
- assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("987654321", response.getHeaders().get("X-TransactionID").get(0));
- MDC.remove(MsoLogger.CLIENT_ID);
-
- }
+ private final String basePath = "/tasks/v1/";
+
+
+
+ @Test
+ public void testCreateOpEnvObjectMapperError() throws IOException {
+ TestAppender.events.clear();
+ stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
+
+ String taskId = "55";
+ TasksRequest taskReq = new TasksRequest();
+ RequestDetails reqDetail = new RequestDetails();
+ RequestInfo reqInfo = new RequestInfo();
+ reqInfo.setRequestorId("testId");
+ reqInfo.setSource("testSource");
+ reqInfo.setResponseValue(ValidResponses.skip);
+ reqDetail.setRequestInfo(reqInfo);
+ taskReq.setRequestDetails(reqDetail);
+
+ //expected response
+ TaskRequestReference expectedResponse = new TaskRequestReference();
+ expectedResponse.setTaskId(taskId);
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ headers.set(MsoLogger.ECOMP_REQUEST_ID, "987654321");
+ headers.set(MsoLogger.CLIENT_ID, "VID");
+ HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete");
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ TaskRequestReference realResponse = mapper.readValue(response.getBody(), TaskRequestReference.class);
+
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+
+ for(ILoggingEvent logEvent : TestAppender.events)
+ if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
+ logEvent.getMarker().getName().equals("ENTRY")
+ ){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
+ assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
+ assertEquals("tasks/v1/55/complete",mdc.get(MsoLogger.SERVICE_NAME));
+ assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
+ }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
+ logEvent.getMarker().getName().equals("EXIT")){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(MsoLogger.ENDTIME));
+ assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
+ assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
+ assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
+ assertEquals("tasks/v1/55/complete",mdc.get(MsoLogger.SERVICE_NAME));
+ assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE));
+ assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
+ assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
+ assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
+ assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
+ assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+ }
+ }
}
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 fbe720a07d..ef318513fc 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
@@ -124,7 +124,7 @@ public class ServiceInstancesTest extends BaseTest{
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
headers.set(MsoLogger.CLIENT_ID, "VID");
//expect
ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
@@ -141,18 +141,37 @@ public class ServiceInstancesTest extends BaseTest{
assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- ILoggingEvent logEvent = TestAppender.events.get(0);
- Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(MsoLogger.REQUEST_ID));
- assertEquals("VID", mdc.get(MsoLogger.CLIENT_ID));
- MDC.remove(MsoLogger.CLIENT_ID);
- assertTrue(response.getBody().contains("1882939"));
- assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
- assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
- assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
- assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", response.getHeaders().get("X-TransactionID").get(0));
-
+
+
+
+ for(ILoggingEvent logEvent : TestAppender.events)
+ if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
+ logEvent.getMarker().getName().equals("ENTRY")
+ ){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
+ assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
+ assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
+ assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
+ }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
+ logEvent.getMarker().getName().equals("EXIT")){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(MsoLogger.ENDTIME));
+ assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
+ assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
+ assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
+ assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
+ assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE));
+ assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
+ assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
+ assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
+ assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+ }
+
//ExpectedRecord
InfraActiveRequests expectedRecord = new InfraActiveRequests();
expectedRecord.setRequestStatus("IN_PROGRESS");
@@ -575,7 +594,7 @@ public class ServiceInstancesTest extends BaseTest{
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3";
- headers.set(MsoLogger.TRANSACTION_ID, requestId);
+ headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
//expected response
ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
RequestReferences requestReferences = new RequestReferences();
@@ -684,7 +703,7 @@ public class ServiceInstancesTest extends BaseTest{
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5";
- headers.set(MsoLogger.TRANSACTION_ID, requestId);
+ headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
//expected response
ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
RequestReferences requestReferences = new RequestReferences();
@@ -838,7 +857,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void createVfModuleNoModelType() throws JsonParseException, JsonMappingException, IOException{
- headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
InfraActiveRequests expectedRecord = new InfraActiveRequests();
expectedRecord.setRequestStatus("FAILED");
expectedRecord.setAction("createInstance");
@@ -1039,7 +1058,7 @@ public class ServiceInstancesTest extends BaseTest{
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4";
- headers.set(MsoLogger.TRANSACTION_ID, requestId);
+ headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
//expected response
ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
RequestReferences requestReferences = new RequestReferences();
@@ -1123,7 +1142,7 @@ public class ServiceInstancesTest extends BaseTest{
}
@Test
public void convertJsonToServiceInstanceRequestFail() throws JsonParseException, JsonMappingException, IOException {
- headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
//ExpectedRecord
InfraActiveRequests expectedRecord = new InfraActiveRequests();
expectedRecord.setRequestStatus("FAILED");