diff options
author | Plummer, Brittany <brittany.plummer@att.com> | 2020-02-06 11:26:19 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2020-02-06 11:26:19 -0500 |
commit | fdc8f787e9874f82409cdb2eae0475162d6519aa (patch) | |
tree | f6648e8ce7d476edb9e3c1fac2611e63f4920a79 /mso-api-handlers/mso-api-handler-infra/src/test/java/org | |
parent | 422c2a3615ca059b2b9e79304738106fb845bf69 (diff) |
optimize camunda process instance history
Set buinessKey to requestId. Added plugin to pass businessKey to
subprocesses
Updated process-instance and activity-instance lookups to filter
response
Removed duplicate tests and updated att history lookup
Updated businessKey to be set to mso-request-id
Updated snapshot version to fix build issues
Removed query param from properties. added uribuilder
Updated to use uriBuilder.build().toString()
Updated unit tests to lookup by procesInstanceId to fix build failure
Issue-ID: SO-2650
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I357053c52a75ee5149a56392ce866dbb654b541d
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org')
5 files changed, 32 insertions, 63 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java index 4dc281b3fc..5f41257808 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java @@ -44,12 +44,13 @@ public class CamundaRequestHandlerTest extends BaseTest { @Test public void timeoutTest() { wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_6718de35-b9a5-4670-b19f-a0f4ac22bfaf")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=6718de35-b9a5-4670-b19f-a0f4ac22bfaf&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/HistoryCheckResponse.json") .withStatus(org.apache.http.HttpStatus.SC_OK).withFixedDelay(40000))); thrown.expect(ResourceAccessException.class); - camundaRequestHandler.getCamundaProcessInstanceHistory("6718de35-b9a5-4670-b19f-a0f4ac22bfaf", false); + camundaRequestHandler.getCamundaProcessInstanceHistory("6718de35-b9a5-4670-b19f-a0f4ac22bfaf", false, true, + false); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerUnitTest.java index 261b64f2e6..53b9207337 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerUnitTest.java @@ -105,10 +105,8 @@ public class CamundaRequestHandlerUnitTest { activityInstanceResponse = new ResponseEntity<List<HistoricActivityInstanceEntity>>(activityInstanceList, HttpStatus.ACCEPTED); - doReturn("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_").when(env) - .getProperty("mso.camunda.rest.history.uri"); - doReturn("/sobpmnengine/history/activity-instance?processInstanceId=").when(env) - .getProperty("mso.camunda.rest.activity.uri"); + doReturn("/sobpmnengine/history/process-instance").when(env).getProperty("mso.camunda.rest.history.uri"); + doReturn("/sobpmnengine/history/activity-instance").when(env).getProperty("mso.camunda.rest.activity.uri"); doReturn("auth").when(env).getRequiredProperty("mso.camundaAuth"); doReturn("key").when(env).getRequiredProperty("mso.msoKey"); doReturn("http://localhost:8089").when(env).getProperty("mso.camundaURL"); @@ -208,9 +206,9 @@ public class CamundaRequestHandlerUnitTest { @Test public void getTaskName() throws IOException, ContactCamundaException { doReturn(processInstanceResponse).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID, - false); + false, false, true); doReturn(activityInstanceResponse).when(camundaRequestHandler) - .getCamundaActivityHistory("c4c6b647-a26e-11e9-b144-0242ac14000b"); + .getCamundaActivityHistory("c2fd4066-a26e-11e9-b144-0242ac14000b"); doReturn("Last task executed: BB to Execute").when(camundaRequestHandler).getActivityName(activityInstanceList); String expectedTaskName = "Last task executed: BB to Execute"; @@ -255,7 +253,7 @@ public class CamundaRequestHandlerUnitTest { @Test public void getTaskNameProcessInstanceLookupFailureTest() throws IOException, ContactCamundaException { doThrow(HttpClientErrorException.class).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID, - false); + false, false, true); String result = camundaRequestHandler.getTaskName(REQUEST_ID); assertNull(result); @@ -265,8 +263,8 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaActivityHistoryTest() throws IOException, ContactCamundaException { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId=" - + "c4c6b647-a26e-11e9-b144-0242ac14000b"; + String targetUrl = + "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId=c4c6b647-a26e-11e9-b144-0242ac14000b&maxResults=1"; doReturn(activityInstanceResponse).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricActivityInstanceEntity>>() {}); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); @@ -279,8 +277,8 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaActivityHistoryErrorTest() { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId=" - + "c4c6b647-a26e-11e9-b144-0242ac14000b"; + String targetUrl = + "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId=c4c6b647-a26e-11e9-b144-0242ac14000b&maxResults=1"; doThrow(new ResourceAccessException("IOException")).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricActivityInstanceEntity>>() {}); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); @@ -296,14 +294,14 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaProccesInstanceHistoryTest() throws IOException, ContactCamundaException { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = - "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID; + String targetUrl = "http://localhost:8089/sobpmnengine/history/process-instance?processInstanceBusinessKey=" + + REQUEST_ID + "&active=true&maxResults=1"; doReturn(processInstanceResponse).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); ResponseEntity<List<HistoricProcessInstanceEntity>> actualResponse = - camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, false); + camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, false, true, false); assertEquals(processInstanceResponse, actualResponse); } @@ -311,14 +309,14 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaProccesInstanceHistoryRetryTest() { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = - "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID; + String targetUrl = "http://localhost:8089/sobpmnengine/history/process-instance?processInstanceBusinessKey=" + + REQUEST_ID + "&active=true&maxResults=1"; doThrow(new ResourceAccessException("I/O error")).when(restTemplateRetry).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); thrown.expect(ResourceAccessException.class); - camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, true); + camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, true, true, false); verify(restTemplateRetry, times(2)).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}); @@ -328,14 +326,14 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaProccesInstanceHistoryNoRetryTest() { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = - "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID; + String targetUrl = "http://localhost:8089/sobpmnengine/history/process-instance?processInstanceBusinessKey=" + + REQUEST_ID + "&sortBy=startTime&sortOrder=desc&maxResults=1"; doThrow(HttpClientErrorException.class).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); thrown.expect(HttpStatusCodeException.class); - camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, false); + camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, false, false, true); verify(restTemplate, times(1)).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}); @@ -345,15 +343,15 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaProccesInstanceHistoryFailThenSuccessTest() throws IOException, ContactCamundaException { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = - "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID; + String targetUrl = "http://localhost:8089/sobpmnengine/history/process-instance?processInstanceBusinessKey=" + + REQUEST_ID + "&sortBy=startTime&sortOrder=desc&maxResults=1"; when(restTemplateRetry.exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {})) .thenThrow(new ResourceAccessException("I/O Exception")).thenReturn(processInstanceResponse); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); ResponseEntity<List<HistoricProcessInstanceEntity>> actualResponse = - camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, true); + camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, true, false, true); assertEquals(processInstanceResponse, actualResponse); verify(restTemplateRetry, times(2)).exchange(targetUrl, HttpMethod.GET, requestEntity, diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java index aa6a3836c1..46fd2f9025 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java @@ -101,8 +101,8 @@ public class OrchestrationRequestsTest extends BaseTest { .withBody(new String(Files.readAllBytes( Paths.get("src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json")))) .withStatus(org.apache.http.HttpStatus.SC_OK))); - wireMockServer.stubFor( - get(("/sobpmnengine/history/activity-instance?processInstanceId=c4c6b647-a26e-11e9-b144-0242ac14000b")) + wireMockServer.stubFor(get( + ("/sobpmnengine/history/activity-instance?processInstanceId=c2fd4066-a26e-11e9-b144-0242ac14000b&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(new String(Files.readAllBytes(Paths.get( "src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json")))) diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java index abdf38dfa6..7f9ff98b19 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java @@ -299,7 +299,7 @@ public class RequestHandlerUtilsTest extends BaseTest { @Test public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException { wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/HistoryCheckResponse.json") .withStatus(org.apache.http.HttpStatus.SC_OK))); @@ -314,7 +314,7 @@ public class RequestHandlerUtilsTest extends BaseTest { @Test public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException { wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK))); @@ -326,21 +326,6 @@ public class RequestHandlerUtilsTest extends BaseTest { } @Test - public void camundaHistoryCheckNotInProgressTest() throws ContactCamundaException, RequestDbFailureException { - wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) - .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .withBodyFile("Camunda/HistoryCheckResponseCompleted.json") - .withStatus(org.apache.http.HttpStatus.SC_OK))); - - InfraActiveRequests duplicateRecord = new InfraActiveRequests(); - duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f"); - boolean inProgress = false; - inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null); - assertFalse(inProgress); - } - - @Test public void setCamundaHeadersTest() throws ContactCamundaException, RequestDbFailureException { String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password String key = "07a7159d3bf51a0e53be7a8f89699be7"; 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 006b82ac58..f566628ee3 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 @@ -2440,7 +2440,7 @@ public class ServiceInstancesTest extends BaseTest { .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json") .withStatus(HttpStatus.SC_ACCEPTED))); wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/HistoryCheckResponse.json") .withStatus(org.apache.http.HttpStatus.SC_OK))); @@ -2463,7 +2463,7 @@ public class ServiceInstancesTest extends BaseTest { .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json") .withStatus(HttpStatus.SC_ACCEPTED))); wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR))); @@ -2897,7 +2897,7 @@ public class ServiceInstancesTest extends BaseTest { @Test public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException { wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/HistoryCheckResponse.json") .withStatus(org.apache.http.HttpStatus.SC_OK))); @@ -2912,7 +2912,7 @@ public class ServiceInstancesTest extends BaseTest { @Test public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException { wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK))); @@ -2924,21 +2924,6 @@ public class ServiceInstancesTest extends BaseTest { } @Test - public void camundaHistoryCheckNotInProgressTest() throws ContactCamundaException, RequestDbFailureException { - wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) - .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .withBodyFile("Camunda/HistoryCheckResponseCompleted.json") - .withStatus(org.apache.http.HttpStatus.SC_OK))); - - InfraActiveRequests duplicateRecord = new InfraActiveRequests(); - duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f"); - boolean inProgress = false; - inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null); - assertFalse(inProgress); - } - - @Test public void handleReplaceInstance_Test() throws JsonParseException, JsonMappingException, IOException { String replaceVfModule = inputStream("/ReplaceVfModule.json"); ObjectMapper mapper = new ObjectMapper(); |