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.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java37
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java8
4 files changed, 40 insertions, 14 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 451fa64585..e56eb422d8 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
@@ -115,7 +115,7 @@ public class CamundaRequestHandler {
List<HistoricProcessInstanceEntity> historicProcessInstanceList = response.getBody();
- if (historicProcessInstanceList != null) {
+ if (historicProcessInstanceList != null && !historicProcessInstanceList.isEmpty()) {
Collections.reverse(historicProcessInstanceList);
processInstanceId = historicProcessInstanceList.get(0).getId();
} else {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
index 6f36fb2aff..a5ccb1b29b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
@@ -42,6 +42,7 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.EnumUtils;
import org.apache.http.HttpStatus;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandler.common.ResponseBuilder;
@@ -411,7 +412,11 @@ public class OrchestrationRequests {
protected String mapRequestStatusToRequest(InfraActiveRequests iar, String format) {
if (iar.getRequestStatus() != null) {
- if (!StringUtils.isBlank(format) && OrchestrationRequestFormat.DETAIL.toString().equalsIgnoreCase(format)) {
+ boolean requestFormat = false;
+ if (format != null) {
+ requestFormat = EnumUtils.isValidEnum(OrchestrationRequestFormat.class, format.toUpperCase());
+ }
+ if (requestFormat) {
return iar.getRequestStatus();
} else {
if (Status.ABORTED.toString().equalsIgnoreCase(iar.getRequestStatus())
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 e6b5163f59..830f38f98b 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
@@ -30,6 +30,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.camunda.bpm.engine.impl.persistence.entity.HistoricActivityInstanceEntity;
import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
@@ -119,7 +120,7 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void getActivityNameTest() throws IOException {
+ public void getActivityNameTest() {
String expectedActivityName = "Last task executed: BB to Execute";
String actualActivityName = camundaRequestHandler.getActivityName(activityInstanceList);
@@ -127,7 +128,7 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void getActivityNameNullActivityNameTest() throws IOException {
+ public void getActivityNameNullActivityNameTest() {
String expectedActivityName = "Task name is null.";
HistoricActivityInstanceEntity activityInstance = new HistoricActivityInstanceEntity();
List<HistoricActivityInstanceEntity> activityInstanceList = new ArrayList<>();
@@ -139,7 +140,7 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void getActivityNameNullListTest() throws IOException {
+ public void getActivityNameNullListTest() {
String expectedActivityName = "No results returned on activityInstance history lookup.";
List<HistoricActivityInstanceEntity> activityInstanceList = null;
String actualActivityName = camundaRequestHandler.getActivityName(activityInstanceList);
@@ -148,7 +149,7 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void getActivityNameEmptyListTest() throws IOException {
+ public void getActivityNameEmptyListTest() {
String expectedActivityName = "No results returned on activityInstance history lookup.";
List<HistoricActivityInstanceEntity> activityInstanceList = new ArrayList<>();
String actualActivityName = camundaRequestHandler.getActivityName(activityInstanceList);
@@ -157,7 +158,7 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void getTaskNameTest() throws IOException, ContactCamundaException {
+ public void getTaskNameTest() throws ContactCamundaException {
doReturn(processInstanceResponse).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID);
doReturn(activityInstanceResponse).when(camundaRequestHandler)
.getCamundaActivityHistory("c4c6b647-a26e-11e9-b144-0242ac14000b", REQUEST_ID);
@@ -170,7 +171,7 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void getTaskNameNullProcessInstanceListTest() throws IOException, ContactCamundaException {
+ public void getTaskNameNullProcessInstanceListTest() throws ContactCamundaException {
ResponseEntity<List<HistoricProcessInstanceEntity>> response = new ResponseEntity<>(null, HttpStatus.OK);
doReturn(response).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID);
String expected = "No processInstances returned for requestId: " + REQUEST_ID;
@@ -181,7 +182,7 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void getTaskNameNullProcessInstanceIdTest() throws IOException, ContactCamundaException {
+ public void getTaskNameNullProcessInstanceIdTest() throws ContactCamundaException {
HistoricProcessInstanceEntity processInstance = new HistoricProcessInstanceEntity();
List<HistoricProcessInstanceEntity> processInstanceList = new ArrayList<>();
processInstanceList.add(processInstance);
@@ -196,7 +197,19 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void getTaskNameProcessInstanceLookupFailureTest() throws IOException, ContactCamundaException {
+ public void getTaskNameEmptyProcessInstanceListTest() throws ContactCamundaException {
+ ResponseEntity<List<HistoricProcessInstanceEntity>> response =
+ new ResponseEntity<>(Collections.emptyList(), HttpStatus.OK);
+ doReturn(response).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID);
+ String expected = "No processInstances returned for requestId: " + REQUEST_ID;
+
+ String actual = camundaRequestHandler.getTaskName(REQUEST_ID);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getTaskNameProcessInstanceLookupFailureTest() throws ContactCamundaException {
doThrow(HttpClientErrorException.class).when(camundaRequestHandler)
.getCamundaProcessInstanceHistory(REQUEST_ID);
@@ -205,7 +218,7 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void getCamundaActivityHistoryTest() throws IOException, ContactCamundaException {
+ public void getCamundaActivityHistoryTest() throws ContactCamundaException {
HttpHeaders headers = setHeaders();
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
String targetUrl = "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId="
@@ -239,7 +252,7 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void getCamundaProccesInstanceHistoryTest() throws IOException, ContactCamundaException {
+ public void getCamundaProccesInstanceHistoryTest() {
HttpHeaders headers = setHeaders();
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
String targetUrl =
@@ -292,7 +305,7 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void getCamundaProccesInstanceHistoryFailThenSuccessTest() throws IOException, ContactCamundaException {
+ public void getCamundaProccesInstanceHistoryFailThenSuccessTest() {
HttpHeaders headers = setHeaders();
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
String targetUrl =
@@ -310,7 +323,7 @@ public class CamundaRequestHandlerTest {
}
@Test
- public void setCamundaHeadersTest() throws ContactCamundaException, RequestDbFailureException {
+ public void setCamundaHeadersTest() {
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/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
index 5023155768..f672648a6b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
@@ -295,6 +295,14 @@ public class OrchestrationRequestsUnitTest {
assertEquals(Status.ABORTED.toString(), result);
}
+ @Test
+ public void mapRequestStatusToRequestForFormatStatusDetailTest() throws ApiException {
+ iar.setRequestStatus(Status.ABORTED.toString());
+ String result = orchestrationRequests.mapRequestStatusToRequest(iar, "statusDetail");
+
+ assertEquals(Status.ABORTED.toString(), result);
+ }
+
@Test
public void mapRequestStatusToRequestForFormatEmptyStringTest() throws ApiException {