From 593187e78b52cada60430d4006900a3b50da170c Mon Sep 17 00:00:00 2001 From: "Plummer, Brittany" Date: Mon, 27 Apr 2020 14:40:36 -0400 Subject: refactor camunda client in apih Switched CamundaClient to use restTemplate Combined clients into one CamundaClient Initial setup of exception handling in camundaclient Initial fix of compilation issues Switched CamundaClient constructor Updated how url is set in CamundaClient Updated auth to fix tag mismatch warning Added throwing ClientConnectionException to client Updated ServiceInstancesTest cases Updated error handling for CamundaClient Updated how response is returned Fixed failing unit tests in apih infra Refactored response handler for responseentity Fixed failing unit tests in apih Removed old unit tests for client Import cleanup for unneeded changes Updated to use new CamundaClient Updated CamundaClient and ResponseHandler tests Removed unused RequestHandler Issue-ID: SO-2834 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I82ff489c9c939a7e8ec0e48476daf7e45baa5f20 --- .../org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java | 12 ++++++------ .../java/org/onap/so/apihandlerinfra/ManualTasksTest.java | 3 ++- .../org/onap/so/apihandlerinfra/ServiceInstancesTest.java | 5 ++--- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap') diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java index 979aa8fbb1..86e847234b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java @@ -103,7 +103,7 @@ public class E2EServiceInstancesTest extends BaseTest { String uri = e2eServInstancesUri + "v3"; ResponseEntity response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } @Test @@ -143,7 +143,7 @@ public class E2EServiceInstancesTest extends BaseTest { String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e"; ResponseEntity response = sendRequest(inputStream("/DeleteRequest.json"), uri, HttpMethod.DELETE); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } @Test @@ -183,14 +183,14 @@ public class E2EServiceInstancesTest extends BaseTest { String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/scale"; ResponseEntity response = sendRequest(inputStream("/ScaleRequest.json"), uri, HttpMethod.POST); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } @Test public void updateE2EServiceInstance() throws IOException { String uri = e2eServInstancesUri + "v3/9b9f02c0-298b-458a-bc9c-be3692e4f35e"; ResponseEntity response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.PUT); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } @Test @@ -240,8 +240,8 @@ public class E2EServiceInstancesTest extends BaseTest { RequestError expectedResponse = new RequestError(); ServiceException exception = new ServiceException(); exception.setMessageId("SVC1000"); - exception.setText( - "Failed calling bpmn localhost:" + env.getProperty("wiremock.server.port") + " failed to respond"); + exception.setText("Failed calling bpmn Client from http://localhost:" + env.getProperty("wiremock.server.port") + + "/mso/async/services/CompareModelofE2EServiceInstance failed to connect or respond"); expectedResponse.setServiceException(exception); String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/modeldifferences"; 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 fcf25b23e9..f4ff19f53d 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 @@ -182,7 +182,8 @@ public class ManualTasksTest extends BaseTest { RequestError expectedResponse = new RequestError(); ServiceException se = new ServiceException(); se.setMessageId("SVC1000"); - se.setText("Request Failed due to BPEL error with HTTP Status = 502"); + se.setText("Client from http://localhost:" + env.getProperty("wiremock.server.port") + + "/sobpmnengine/task/55/complete failed to connect or respond"); expectedResponse.setServiceException(se); HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); 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 1332ffd913..143c92861a 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 @@ -2214,7 +2214,6 @@ public class ServiceInstancesTest extends BaseTest { wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .withBodyFile("Camunda/UnauthorizedResponse.json") .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED))); wireMockServer.stubFor(get(urlMatching(".*/service/.*")) @@ -2231,7 +2230,7 @@ public class ServiceInstancesTest extends BaseTest { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); - assertEquals("Exception caught mapping Camunda JSON response to object", + assertEquals("Request Failed due to BPEL error with HTTP Status = 401 UNAUTHORIZED", realResponse.getServiceException().getText()); } @@ -2430,7 +2429,7 @@ public class ServiceInstancesTest extends BaseTest { ResponseEntity response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); - assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value()); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText()); -- cgit 1.2.3-korg