From 0c1dd50e1fe778e6d2463dc490259cae9c48a0e7 Mon Sep 17 00:00:00 2001 From: "Chan, Mercy" Date: Tue, 18 Jun 2019 17:44:22 -0400 Subject: update apih to accept new uri parameter added extSystemErrorSource queryparam flag to getOrchestrationRequest endpoint. added junit tests for the protected method that maps external system error source to request object being returned. added junit tests to test mapExtSystemErrorSourceToRequest method with extSystemErrorSource flag Change-Id: If5c9a41938d4cc922c26f7d64e3a839b6547556f Issue-ID: SO-2035 Signed-off-by: Benjamin, Max (mb388a) --- .../so/apihandlerinfra/OrchestrationRequests.java | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap') 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 e14b01792a..b4a3128de8 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 @@ -94,8 +94,8 @@ public class OrchestrationRequests { @Produces(MediaType.APPLICATION_JSON) @Transactional public Response getOrchestrationRequest(@PathParam("requestId") String requestId, - @PathParam("version") String version, @QueryParam("includeCloudRequest") boolean includeCloudRequest) - throws ApiException { + @PathParam("version") String version, @QueryParam("includeCloudRequest") boolean includeCloudRequest, + @QueryParam("extSystemErrorSource") boolean extSystemErrorSource) throws ApiException { String apiVersion = version.substring(1); GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse(); @@ -142,7 +142,8 @@ public class OrchestrationRequests { throw validateException; } - Request request = mapInfraActiveRequestToRequest(infraActiveRequest, includeCloudRequest); + Request request = mapInfraActiveRequestToRequest(infraActiveRequest, includeCloudRequest, extSystemErrorSource); + if (!requestProcessingData.isEmpty()) { request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); } @@ -158,7 +159,8 @@ public class OrchestrationRequests { @Produces(MediaType.APPLICATION_JSON) @Transactional public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version, - @QueryParam("includeCloudRequest") boolean includeCloudRequest) throws ApiException { + @QueryParam("includeCloudRequest") boolean includeCloudRequest, + @QueryParam("extSystemErrorSource") boolean extSystemErrorSource) throws ApiException { long startTime = System.currentTimeMillis(); @@ -195,7 +197,8 @@ public class OrchestrationRequests { List requestProcessingData = requestsDbClient.getRequestProcessingDataBySoRequestId(infraActive.getRequestId()); RequestList requestList = new RequestList(); - Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest); + Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest, extSystemErrorSource); + if (!requestProcessingData.isEmpty()) { request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); } @@ -290,8 +293,8 @@ public class OrchestrationRequests { return Response.status(HttpStatus.SC_NO_CONTENT).entity("").build(); } - protected Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest) - throws ApiException { + protected Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest, + boolean extSystemErrorSource) throws ApiException { String requestBody = iar.getRequestBody(); Request request = new Request(); @@ -427,10 +430,19 @@ public class OrchestrationRequests { }); } + mapExtSystemErrorSourceToRequest(iar, status, extSystemErrorSource); + request.setRequestStatus(status); return request; } + protected void mapExtSystemErrorSourceToRequest(InfraActiveRequests iar, RequestStatus status, + boolean extSystemErrorSource) { + if (extSystemErrorSource) { + status.setExtSystemErrorSource(iar.getExtSystemErrorSource()); + } + } + public List mapRequestProcessingData( List processingData) { List addedRequestProcessingData = new ArrayList<>(); -- cgit 1.2.3-korg