diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test')
4 files changed, 63 insertions, 47 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java index 7bb1bdf71a..6efcdc47e5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java @@ -28,10 +28,9 @@ import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.exceptions.*; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; - import java.io.IOException; import java.util.LinkedList; import java.util.List; @@ -89,7 +88,7 @@ public class ApiExceptionTest extends BaseTest { @Test public void testDuplicateRequestException() throws ApiException { - ErrorLoggerInfo testLog = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ErrorLoggerInfo testLog = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); thrown.expect(DuplicateRequestException.class); thrown.expectMessage(startsWith("Error: Locked instance")); thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND))); 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 bb78c822f7..1943b42404 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 @@ -29,6 +29,15 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static org.onap.so.logger.MdcConstants.ECOMP_REQUEST_ID; +import static org.onap.so.logger.MdcConstants.ENDTIME; +import static org.onap.so.logger.MdcConstants.INVOCATION_ID; +import static org.onap.so.logger.MdcConstants.PARTNERNAME; +import static org.onap.so.logger.MdcConstants.RESPONSECODE; +import static org.onap.so.logger.MdcConstants.RESPONSEDESC; +import static org.onap.so.logger.MdcConstants.SERVICE_NAME; +import static org.onap.so.logger.MdcConstants.STATUSCODE; +import static org.onap.so.logger.MdcConstants.CLIENT_ID; import java.io.IOException; import java.util.Map; @@ -44,7 +53,6 @@ import org.onap.so.apihandlerinfra.tasksbeans.RequestInfo; import org.onap.so.apihandlerinfra.tasksbeans.TaskRequestReference; import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest; import org.onap.so.apihandlerinfra.tasksbeans.ValidResponses; -import org.onap.so.logger.MsoLogger; import org.onap.so.serviceinstancebeans.RequestError; import org.onap.so.serviceinstancebeans.ServiceException; import org.springframework.http.HttpEntity; @@ -64,8 +72,6 @@ public class ManualTasksTest extends BaseTest{ private final String basePath = "/tasks/v1/"; - - @Test public void testCreateOpEnvObjectMapperError() throws IOException { TestAppender.events.clear(); @@ -88,8 +94,8 @@ public class ManualTasksTest extends BaseTest{ HttpHeaders headers = new HttpHeaders(); 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"); + headers.set(ECOMP_REQUEST_ID, "987654321"); + headers.set(CLIENT_ID, "VID"); HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers); UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete"); @@ -116,22 +122,22 @@ public class ManualTasksTest extends BaseTest{ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); assertNotNull(mdc.get(ONAPLogConstants.MDCs.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)); + assertNotNull(mdc.get(INVOCATION_ID)); + assertEquals("UNKNOWN",mdc.get(PARTNERNAME)); + assertEquals("tasks/v1/55/complete",mdc.get(SERVICE_NAME)); + assertEquals("INPROGRESS",mdc.get(STATUSCODE)); }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); - assertNotNull(mdc.get(MsoLogger.ENDTIME)); + assertNotNull(mdc.get(ENDTIME)); assertNotNull(mdc.get(ONAPLogConstants.MDCs.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)); + assertNotNull(mdc.get(INVOCATION_ID)); + assertEquals("202",mdc.get(RESPONSECODE)); + assertEquals("UNKNOWN",mdc.get(PARTNERNAME)); + assertEquals("tasks/v1/55/complete",mdc.get(SERVICE_NAME)); + assertEquals("COMPLETE",mdc.get(STATUSCODE)); + assertNotNull(mdc.get(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)); @@ -151,8 +157,8 @@ public class ManualTasksTest extends BaseTest{ HttpHeaders headers = new HttpHeaders(); 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"); + headers.set(ECOMP_REQUEST_ID, "987654321"); + headers.set(CLIENT_ID, "VID"); HttpEntity<String> entity = new HttpEntity<String>(invalidRequest, headers); UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + "55" + "/complete"); @@ -187,8 +193,8 @@ public class ManualTasksTest extends BaseTest{ HttpHeaders headers = new HttpHeaders(); 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"); + headers.set(ECOMP_REQUEST_ID, "987654321"); + headers.set(CLIENT_ID, "VID"); HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers); UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete"); @@ -227,8 +233,8 @@ public class ManualTasksTest extends BaseTest{ HttpHeaders headers = new HttpHeaders(); 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"); + headers.set(ECOMP_REQUEST_ID, "987654321"); + headers.set(CLIENT_ID, "VID"); HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers); UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete"); 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 d6c794ef2e..17fa011c93 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 @@ -34,6 +34,18 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID; +import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID; +import static org.onap.so.logger.MdcConstants.CLIENT_ID; +import static org.onap.so.logger.MdcConstants.ENDTIME; +import static org.onap.so.logger.MdcConstants.INVOCATION_ID; +import static org.onap.so.logger.MdcConstants.PARTNERNAME; +import static org.onap.so.logger.MdcConstants.RESPONSECODE; +import static org.onap.so.logger.MdcConstants.RESPONSEDESC; +import static org.onap.so.logger.MdcConstants.SERVICE_NAME; +import static org.onap.so.logger.MdcConstants.STATUSCODE; +import static org.onap.so.logger.HttpHeadersConstants.TRANSACTION_ID; + import java.io.File; import java.io.IOException; @@ -59,8 +71,7 @@ import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.logger.LogConstants; -import org.onap.so.logger.MsoLogger; +import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.RequestDetails; @@ -117,11 +128,11 @@ public class ServiceInstancesTest extends BaseTest{ // set headers headers = new HttpHeaders(); headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name"); - headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); - headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); - headers.set(MsoLogger.CLIENT_ID, "VID"); - headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx"); + headers.set(CLIENT_ID, "VID"); + headers.set(REQUESTOR_ID, "xxxxxx"); try { // generate one-time port number to avoid RANDOM port number later. initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH)); initialPort = initialUrl.getPort(); @@ -263,22 +274,22 @@ public class ServiceInstancesTest extends BaseTest{ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); assertNotNull(mdc.get(ONAPLogConstants.MDCs.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)); + assertNotNull(mdc.get(INVOCATION_ID)); + assertEquals("UNKNOWN",mdc.get(PARTNERNAME)); + assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(SERVICE_NAME)); + assertEquals("INPROGRESS",mdc.get(STATUSCODE)); }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); - assertNotNull(mdc.get(MsoLogger.ENDTIME)); + assertNotNull(mdc.get(ENDTIME)); assertNotNull(mdc.get(ONAPLogConstants.MDCs.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)); + assertNotNull(mdc.get(INVOCATION_ID)); + assertEquals("202",mdc.get(RESPONSECODE)); + assertEquals("UNKNOWN",mdc.get(PARTNERNAME)); + assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(SERVICE_NAME)); + assertEquals("COMPLETE",mdc.get(STATUSCODE)); + assertNotNull(mdc.get(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)); @@ -2387,14 +2398,14 @@ 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")); - assertEquals(response.getHeaders().get(MsoLogger.TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d"); + assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d"); for(ILoggingEvent logEvent : TestAppender.events){ if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging") && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertEquals("VID",mdc.get(MsoLogger.PARTNERNAME)); + assertEquals("VID",mdc.get(PARTNERNAME)); } } } @@ -2451,7 +2462,7 @@ public class ServiceInstancesTest extends BaseTest{ public void deleteInstanceGroupNoPartnerNameHeader() throws IOException{ HttpHeaders noPartnerHeaders = new HttpHeaders(); noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4"); - noPartnerHeaders.set(MsoLogger.REQUESTOR_ID, "xxxxxx"); + noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx"); uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c"; ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders); //then 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 ce1dde835d..65ec5fade6 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 @@ -40,8 +40,8 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestInfo; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters; import org.onap.so.client.aai.AAIVersion; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import javax.ws.rs.core.HttpHeaders; @@ -102,7 +102,7 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED))); stubFor(post(urlPathMatching("/events/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND))); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build(); + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); ValidateException expectedException = new ValidateException.Builder("Could not publish DMaap", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER) .errorInfo(errorLoggerInfo).build(); |