From 37eaeb8c7293c196786ac0d93538fd9ceb3aa412 Mon Sep 17 00:00:00 2001 From: "Plummer, Brittany" Date: Tue, 3 Mar 2020 19:14:38 -0500 Subject: Added simpleNotTaskInfo format modifier Added simpleNotTaskInfo format modifier Issue-ID: SO-2697 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Ifd0c00800e272165885c4a971a3fe5a9beca5686 --- .../so/constants/OrchestrationRequestFormat.java | 2 +- .../so/apihandlerinfra/OrchestrationRequests.java | 15 ++++--- .../OrchestrationRequestsUnitTest.java | 51 ++++++++++++++++++++++ 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java b/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java index 641bbb28c7..141352edce 100644 --- a/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java +++ b/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java @@ -21,5 +21,5 @@ package org.onap.so.constants; public enum OrchestrationRequestFormat { - DETAIL, STATUSDETAIL, SIMPLE + DETAIL, STATUSDETAIL, SIMPLE, SIMPLENOTASKINFO } 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 fec93f72e4..b7d3d633d6 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 @@ -439,11 +439,13 @@ public class OrchestrationRequests { String retryStatusMessage = iar.getRetryStatusMessage(); String taskName = null; - if (flowStatusMessage != null && !flowStatusMessage.equals("Successfully completed all Building Blocks") - && !flowStatusMessage.equals("All Rollback flows have completed successfully")) { - taskName = camundaRequestHandler.getTaskName(iar.getRequestId()); - if (taskName != null) { - flowStatusMessage = flowStatusMessage + " TASK INFORMATION: " + taskName; + if (format == null || !format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLENOTASKINFO.toString())) { + if (flowStatusMessage != null && !flowStatusMessage.equals("Successfully completed all Building Blocks") + && !flowStatusMessage.equals("All Rollback flows have completed successfully")) { + taskName = camundaRequestHandler.getTaskName(iar.getRequestId()); + if (taskName != null) { + flowStatusMessage = flowStatusMessage + " TASK INFORMATION: " + taskName; + } } } @@ -544,7 +546,8 @@ public class OrchestrationRequests { } protected boolean isRequestProcessingDataRequired(String format) { - if (StringUtils.isNotEmpty(format) && format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLE.name())) { + if (StringUtils.isNotEmpty(format) && (format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLE.name()) + || format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLENOTASKINFO.toString()))) { return false; } else { return true; 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 47aa3cccb5..22c82bf75c 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 @@ -27,6 +27,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import static org.mockito.Mockito.doReturn; import javax.ws.rs.core.Response; import org.apache.commons.lang.StringUtils; @@ -186,6 +187,50 @@ public class OrchestrationRequestsUnitTest { assertThat(actual, sameBeanAs(expected)); } + @Test + public void mapRequestStatusNoTaskInfoTest() throws ApiException { + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); + requestStatus.setStatusMessage( + "FLOW STATUS: FlowStatus RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage"); + + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + + includeCloudRequest = false; + + Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.SIMPLENOTASKINFO.toString()); + assertThat(expected, sameBeanAs(actual)); + } + + @Test + public void mapRequestStatusNullFormatTest() throws ApiException { + doReturn("TaskName").when(camundaRequestHandler).getTaskName(REQUEST_ID); + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); + requestStatus.setStatusMessage( + "FLOW STATUS: FlowStatus TASK INFORMATION: TaskName RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage"); + + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + + includeCloudRequest = false; + + Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, null); + assertThat(expected, sameBeanAs(actual)); + } + @Test public void mapRequestStatusAndExtSysErrSrcToRequestDetailTest() throws ApiException { doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID); @@ -338,4 +383,10 @@ public class OrchestrationRequestsUnitTest { orchestrationRequests.infraActiveRequestLookup(iar.getRequestId()); } + @Test + public void isRequestProcessingDataRequiredTest() { + boolean required = orchestrationRequests.isRequestProcessingDataRequired("simpleNoTaskInfo"); + assertFalse(required); + } + } -- cgit 1.2.3-korg