aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers')
-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/MsoRequest.java10
-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/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java3
-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
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VnfLookup.json2
14 files changed, 73 insertions, 130 deletions
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/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index e3e840bbcd..c077558301 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -85,6 +85,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -105,6 +106,9 @@ public class MsoRequest {
@Autowired
private ResponseBuilder builder;
+ @Value("${mso.enforceDLP:false}")
+ private boolean enforceDLP;
+
private static Logger logger = LoggerFactory.getLogger(MsoRequest.class);
public Response buildServiceErrorResponse(int httpResponseCode, MsoException exceptionType, String errorText,
@@ -179,8 +183,10 @@ public class MsoRequest {
rules.add(new ModelInfoValidation());
rules.add(new CloudConfigurationValidation());
rules.add(new SubscriberInfoValidation());
- rules.add(new PlatformLOBValidation());
- rules.add(new ProjectOwningEntityValidation());
+ if (!enforceDLP) {
+ rules.add(new PlatformLOBValidation());
+ rules.add(new ProjectOwningEntityValidation());
+ }
rules.add(new RelatedInstancesValidation());
rules.add(new ConfigurationParametersValidation());
}
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/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java
index 20be2b5a8b..71405b0f63 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java
@@ -43,8 +43,7 @@ public class PlatformLOBValidation implements ValidationRule {
platform = info.getSir().getRequestDetails().getPlatform();
lineOfBusiness = info.getSir().getRequestDetails().getLineOfBusiness();
- if (reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.createInstance
- && !info.getReqParameters().getEnforceValidNfValues()) {
+ if (reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.createInstance) {
if (reqVersion > 5 && platform == null) {
throw new ValidationException("platform");
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java
index cebbd6389c..07641ae87b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java
@@ -45,8 +45,7 @@ public class ProjectOwningEntityValidation implements ValidationRule {
project = info.getSir().getRequestDetails().getProject();
owningEntity = info.getSir().getRequestDetails().getOwningEntity();
if (reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.service.name())
- && !info.getReqParameters().getEnforceValidNfValues() && action == Action.createInstance
- || action == Action.assignInstance) {
+ && action == Action.createInstance || action == Action.assignInstance) {
if (reqVersion > 5 && owningEntity == null) {
throw new ValidationException("owningEntity");
}
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
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VnfLookup.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VnfLookup.json
index eef0776f5d..25aa8a2d81 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VnfLookup.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VnfLookup.json
@@ -13,7 +13,7 @@
"vnfName":"Robot_VNF_For_Volume_Group",
"vnfType":"Vf zrdm5bpxmc02092017-Service/Vf zrdm5bpxmc02092017-VF 0",
"tenantId":"0422ffb57ba042c0800a29dc85ca70f8",
- "requestBody":"{\"requestDetails\": {\"relatedInstanceList\": [{\"relatedInstance\": {\"instanceId\": \"f5435110-b276-4920-9261-a18a5582d357\", \"modelInfo\": {\"modelVersionId\": \"bad955c3-29b2-4a27-932e-28e942cc6480\", \"modelVersion\": \"1\", \"modelName\": \"Vf zrdm5bpxmc02092017-Service\", \"modelInvariantId\": \"b16a9398-ffa3-4041-b78c-2956b8ad9c7b\", \"modelType\": \"service\"}}}], \"requestParameters\": {\"userParams\": [], \"enforceValidNfValues\": false, \"testApi\": \"GR_API\"}, \"lineOfBusiness\": {\"lineOfBusinessName\": \"vSAMP12_14-2XXX-Aug18-9001 - LOB\"}, \"requestInfo\": {\"source\": \"VID\", \"requestorId\": \"az2016\", \"instanceName\": \"Robot_VNF_For_Volume_Group\", \"suppressRollback\": false, \"productFamilyId\": \"06f76284-8710-11e6-ae22-56b6b6499611\"}, \"platform\": {\"platformName\": \"vSAMP12_14-2XXX-Aug18-9001 - Platform\"}, \"modelInfo\": {\"modelName\": \"Vf zrdm5bpxmc02092017-VF\", \"modelVersion\": \"1\", \"modelInvariantId\": \"23122c9b-dd7f-483f-bf0a-e069303db2f7\", \"modelType\": \"vnf\", \"modelCustomizationName\": \"Vf zrdm5bpxmc02092017-VF 0\", \"modelVersionId\": \"d326f424-2312-4dd6-b7fe-364fadbd1ef5\", \"modelCustomizationId\": \"96c23a4a-6887-4b2c-9cce-1e4ea35eaade\"}, \"cloudConfiguration\": {\"cloudOwner\": \"cloudOwner\", \"tenantId\": \"0422ffb57ba042c0800a29dc85ca70f8\", \"lcpCloudRegionId\": \"regionOne\"}}}",
+ "requestBody":"{\"requestDetails\": {\"relatedInstanceList\": [{\"relatedInstance\": {\"instanceId\": \"f5435110-b276-4920-9261-a18a5582d357\", \"modelInfo\": {\"modelVersionId\": \"bad955c3-29b2-4a27-932e-28e942cc6480\", \"modelVersion\": \"1\", \"modelName\": \"Vf zrdm5bpxmc02092017-Service\", \"modelInvariantId\": \"b16a9398-ffa3-4041-b78c-2956b8ad9c7b\", \"modelType\": \"service\"}}}], \"requestParameters\": {\"userParams\": [],\"testApi\": \"GR_API\"}, \"lineOfBusiness\": {\"lineOfBusinessName\": \"vSAMP12_14-2XXX-Aug18-9001 - LOB\"}, \"requestInfo\": {\"source\": \"VID\", \"requestorId\": \"az2016\", \"instanceName\": \"Robot_VNF_For_Volume_Group\", \"suppressRollback\": false, \"productFamilyId\": \"06f76284-8710-11e6-ae22-56b6b6499611\"}, \"platform\": {\"platformName\": \"vSAMP12_14-2XXX-Aug18-9001 - Platform\"}, \"modelInfo\": {\"modelName\": \"Vf zrdm5bpxmc02092017-VF\", \"modelVersion\": \"1\", \"modelInvariantId\": \"23122c9b-dd7f-483f-bf0a-e069303db2f7\", \"modelType\": \"vnf\", \"modelCustomizationName\": \"Vf zrdm5bpxmc02092017-VF 0\", \"modelVersionId\": \"d326f424-2312-4dd6-b7fe-364fadbd1ef5\", \"modelCustomizationId\": \"96c23a4a-6887-4b2c-9cce-1e4ea35eaade\"}, \"cloudConfiguration\": {\"cloudOwner\": \"cloudOwner\", \"tenantId\": \"0422ffb57ba042c0800a29dc85ca70f8\", \"lcpCloudRegionId\": \"regionOne\"}}}",
"lastModifiedBy":"CamundaBPMN",
"modifyTime":"2019-11-11T19:29:15.000+0000",
"cloudRegion":"regionOne",