summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPlummer, Brittany <brittany.plummer@att.com>2020-02-06 11:26:19 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-02-06 11:26:19 -0500
commitfdc8f787e9874f82409cdb2eae0475162d6519aa (patch)
treef6648e8ce7d476edb9e3c1fac2611e63f4920a79
parent422c2a3615ca059b2b9e79304738106fb845bf69 (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
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java3
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java30
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java24
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java33
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java11
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java5
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerUnitTest.java44
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java19
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java23
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json21
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponseCompleted.json21
14 files changed, 129 insertions, 125 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java
index 70365b744c..25f7c4b93f 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java
@@ -75,9 +75,8 @@ public class WorkflowProcessor extends ProcessEngineAwareService {
}
}
- // Note: the business key is used to identify the process in unit tests
protected static String getBusinessKey(Map<String, Object> inputVariables) {
- return getOrCreate(inputVariables, "mso-business-key");
+ return getOrCreate(inputVariables, "mso-request-id");
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java
new file mode 100644
index 0000000000..80d86ad009
--- /dev/null
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java
@@ -0,0 +1,30 @@
+package org.onap.so.bpmn.core.plugins;
+
+import org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior;
+import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener;
+import org.camunda.bpm.engine.impl.context.Context;
+import org.camunda.bpm.engine.impl.core.model.CallableElement;
+import org.camunda.bpm.engine.impl.el.ElValueProvider;
+import org.camunda.bpm.engine.impl.el.Expression;
+import org.camunda.bpm.engine.impl.el.ExpressionManager;
+import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl;
+import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl;
+import org.camunda.bpm.engine.impl.util.xml.Element;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class CallActivityBusinessKeyParseListener extends AbstractBpmnParseListener {
+
+ @Override
+ public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) {
+ ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
+ Expression expression = expressionManager.createExpression("#{execution.processBusinessKey}");
+ ElValueProvider p = new ElValueProvider(expression);
+ CallableElementActivityBehavior callableElementActivityBehavior =
+ (CallableElementActivityBehavior) activity.getActivityBehavior();
+ CallableElement callableElement = (CallableElement) callableElementActivityBehavior.getCallableElement();
+ callableElement.setBusinessKeyValueProvider(p);
+ callableElementActivityBehavior.setCallableElement(callableElement);
+ }
+}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java
new file mode 100644
index 0000000000..a2d897e367
--- /dev/null
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java
@@ -0,0 +1,24 @@
+package org.onap.so.bpmn.core.plugins;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener;
+import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin;
+import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class CallActivityBusinessKeyParseListenerPlugin extends AbstractProcessEnginePlugin {
+
+ @Override
+ public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
+ List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners();
+ if (preParseListeners == null) {
+ preParseListeners = new ArrayList<>();
+ processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);
+ }
+ preParseListeners.add(new CallActivityBusinessKeyParseListener());
+ }
+
+}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
index 93f98a34a6..0161422b64 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
@@ -1534,6 +1534,18 @@ public abstract class WorkflowTest {
}
}
+ protected Object getVariableFromHistoryByProcessInstanceId(String processInstanceId, String variableName) {
+ try {
+ HistoricVariableInstance v = historyService.createHistoricVariableInstanceQuery()
+ .processInstanceId(processInstanceId).variableName(variableName).singleResult();
+ return v == null ? null : v.getValue();
+ } catch (Exception e) {
+ logger.debug("Error retrieving variable {} from historical process with processInstanceId {}: ",
+ variableName, processInstanceId, e);
+ return null;
+ }
+ }
+
/**
* Gets a variable value from a process instance based on businessKey and process name. Must be used when multiple
* instances exist with the same business key such as when business key is passed to subflows or shared across
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
index e9f17c42d0..17377d881a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
@@ -2,10 +2,10 @@ package org.onap.so.apihandlerinfra;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.ws.rs.core.UriBuilder;
import javax.xml.bind.DatatypeConverter;
import org.camunda.bpm.engine.impl.persistence.entity.HistoricActivityInstanceEntity;
import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
@@ -42,10 +42,29 @@ public class CamundaRequestHandler {
@Autowired
private Environment env;
+ private String buildCamundaUrlString(boolean historyLookup, boolean sort, boolean active, String lookupId) {
+ UriBuilder uriBuilder = UriBuilder.fromUri(env.getProperty("mso.camundaURL"));
+ if (historyLookup) {
+ uriBuilder.path(env.getProperty("mso.camunda.rest.history.uri"));
+ uriBuilder.queryParam("processInstanceBusinessKey", lookupId);
+ if (active) {
+ uriBuilder.queryParam("active", true);
+ }
+ if (sort) {
+ uriBuilder.queryParam("sortBy", "startTime");
+ uriBuilder.queryParam("sortOrder", "desc");
+ }
+ } else {
+ uriBuilder.path(env.getProperty("mso.camunda.rest.activity.uri"));
+ uriBuilder.queryParam("processInstanceId", lookupId);
+ }
+ uriBuilder.queryParam("maxResults", 1);
+ return uriBuilder.build().toString();
+ }
+
public ResponseEntity<List<HistoricProcessInstanceEntity>> getCamundaProcessInstanceHistory(String requestId,
- boolean retry) {
- String path = env.getProperty("mso.camunda.rest.history.uri") + requestId;
- String targetUrl = env.getProperty("mso.camundaURL") + path;
+ boolean retry, boolean activeOnly, boolean sort) {
+ String targetUrl = buildCamundaUrlString(true, sort, activeOnly, requestId);
HttpHeaders headers =
setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
@@ -77,8 +96,7 @@ public class CamundaRequestHandler {
protected ResponseEntity<List<HistoricActivityInstanceEntity>> getCamundaActivityHistory(String processInstanceId) {
RestTemplate restTemplate = getRestTemplate(false);
- String path = env.getProperty("mso.camunda.rest.activity.uri") + processInstanceId;
- String targetUrl = env.getProperty("mso.camundaURL") + path;
+ String targetUrl = buildCamundaUrlString(false, false, false, processInstanceId);
HttpHeaders headers =
setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
@@ -92,7 +110,7 @@ public class CamundaRequestHandler {
String taskInformation = null;
try {
- response = getCamundaProcessInstanceHistory(requestId, false);
+ response = getCamundaProcessInstanceHistory(requestId, false, false, true);
} catch (RestClientException e) {
logger.warn("Error querying Camunda for process-instance history for requestId: {}, exception: {}",
requestId, e.getMessage());
@@ -112,7 +130,6 @@ public class CamundaRequestHandler {
String taskInformation = null;
if (historicProcessInstanceList != null && !historicProcessInstanceList.isEmpty()) {
- Collections.reverse(historicProcessInstanceList);
processInstanceId = historicProcessInstanceList.get(0).getId();
} else {
logger.warn("No processInstances returned for requestId: {} to get TaskInformation", requestId);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
index 0c6ad0ba22..75b7e74d49 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
@@ -356,7 +356,7 @@ public class RequestHandlerUtils extends AbstractRestHandler {
String requestId = duplicateRecord.getRequestId();
ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
try {
- response = camundaRequestHandler.getCamundaProcessInstanceHistory(requestId, true);
+ response = camundaRequestHandler.getCamundaProcessInstanceHistory(requestId, true, true, false);
} catch (RestClientException e) {
logger.error("Error querying Camunda for process-instance history for requestId: {}, exception: {}",
requestId, e.getMessage());
@@ -370,13 +370,8 @@ public class RequestHandlerUtils extends AbstractRestHandler {
if (response.getBody().isEmpty()) {
updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
- }
- for (HistoricProcessInstance instance : response.getBody()) {
- if (("ACTIVE").equals(instance.getState())) {
- return true;
- } else {
- updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
- }
+ } else {
+ return true;
}
return false;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
index babefd9478..baa7af77a5 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
@@ -25,9 +25,9 @@ mso:
task:
uri: /sobpmnengine/task
history:
- uri: /sobpmnengine/history/process-instance?variables=mso-request-id_eq_
+ uri: /sobpmnengine/history/process-instance
activity:
- uri: /sobpmnengine/history/activity-instance?processInstanceId=
+ uri: /sobpmnengine/history/activity-instance
camundaURL: http://localhost:8089
camundaAuth: E8E19DD16CC90D2E458E8FF9A884CC0452F8F3EB8E321F96038DE38D5C1B0B02DFAE00B88E2CF6E2A4101AB2C011FC161212EE
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();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json
index faa283463b..4ff2663145 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json
@@ -19,26 +19,5 @@
"caseInstanceId":null,
"tenantId":null,
"state":"COMPLETED"
- },
- {
- "id":"c4c6b647-a26e-11e9-b144-0242ac14000b",
- "businessKey":null,
- "processDefinitionId":"ExecuteBuildingBlock:1:a46566de-a26b-11e9-b144-0242ac14000b",
- "processDefinitionKey":"ExecuteBuildingBlock",
- "processDefinitionName":"ExecuteBuildingBlock",
- "processDefinitionVersion":1,
- "startTime":"2019-07-09T17:27:04.298+0000",
- "endTime":"2019-07-09T17:27:05.690+0000",
- "removalTime":null,
- "durationInMillis":1392,
- "startUserId":null,
- "startActivityId":"Start_ExecuteBuildingBlock",
- "deleteReason":null,
- "rootProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b",
- "superProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b",
- "superCaseInstanceId":null,
- "caseInstanceId":null,
- "tenantId":null,
- "state":"COMPLETED"
}
] \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponseCompleted.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponseCompleted.json
deleted file mode 100644
index fdf0e9a286..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponseCompleted.json
+++ /dev/null
@@ -1,21 +0,0 @@
-[
- {
- "id":"d1a0456e-1458-11e9-8afb-0242ac190006",
- "businessKey":null,
- "processDefinitionId":"86cfa113-141a-11e9-8afb-0242ac190006",
- "processDefinitionKey":"UnassignServiceInstanceATTBB",
- "processDefinitionName":"UnassignServiceInstanceATTBB",
- "processDefinitionVersion":1,
- "startTime":"2019-01-09T21:52:11.813+0000",
- "endTime":"2019-01-09T21:52:12.353+0000",
- "durationInMillis":540,
- "startUserId":null,
- "startActivityId":"Start_UnassignServiceInstanceBB",
- "deleteReason":null,
- "superProcessInstanceId":"d15f6c9e-1458-11e9-8afb-0242ac190006",
- "superCaseInstanceId":null,
- "caseInstanceId":null,
- "tenantId":null,
- "state":"COMPLETED"
- }
-] \ No newline at end of file