From 5de97ac3cb0e91b0717e5379d26c7360f1c64993 Mon Sep 17 00:00:00 2001 From: "Plummer, Brittany" Date: Thu, 15 Aug 2019 15:48:49 -0400 Subject: apih format statusdetail to return granular Should return unchanged requestState on statusDetail queryParam Formatted files with changes to fix build Added enum validation for setting requestStatus Updated test to send in "statusDetail" Issue-ID: SO-2230 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I8f5d79bc287581635a1543a00ddc69fb9eba2295 --- .../java/org/onap/so/apihandlerinfra/OrchestrationRequests.java | 7 ++++++- .../onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'mso-api-handlers/mso-api-handler-infra') 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/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 { -- cgit 1.2.3-korg