diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra')
2 files changed, 23 insertions, 1 deletions
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 a5ccb1b29b..8896e93175 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 @@ -83,6 +83,7 @@ import io.swagger.annotations.ApiOperation; public class OrchestrationRequests { private static Logger logger = LoggerFactory.getLogger(OrchestrationRequests.class); + private static final String ERROR_MESSAGE_PREFIX = "Error Source: %s, Error Message: %s"; @Autowired private RequestsDbClient requestsDbClient; @@ -449,7 +450,12 @@ public class OrchestrationRequests { String statusMessages = null; if (iar.getStatusMessage() != null) { - statusMessages = "STATUS: " + iar.getStatusMessage(); + if (StringUtils.isNotBlank(iar.getExtSystemErrorSource())) { + statusMessages = "STATUS: " + + String.format(ERROR_MESSAGE_PREFIX, iar.getExtSystemErrorSource(), iar.getStatusMessage()); + } else { + statusMessages = "STATUS: " + iar.getStatusMessage(); + } } if (OrchestrationRequestFormat.STATUSDETAIL.toString().equalsIgnoreCase(format)) { 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 f672648a6b..627bbc631d 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 @@ -25,6 +25,7 @@ import static org.hamcrest.CoreMatchers.equalTo; 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.mockito.Mockito.doReturn; import javax.ws.rs.core.Response; import org.apache.commons.lang.StringUtils; @@ -232,6 +233,21 @@ public class OrchestrationRequestsUnitTest { } @Test + public void mapRequestStatusAndExtSysErrSrcToRequestErrorMessageTest() throws ApiException { + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + iar.setExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE); + iar.setFlowStatus(null); + iar.setStatusMessage("Error retrieving cloud region from AAI"); + + Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.DETAIL.toString()); + + assertTrue(actual.getRequestStatus().getStatusMessage() + .contains("Error Source: " + ROLLBACK_EXT_SYSTEM_ERROR_SOURCE)); + } + + @Test public void mapRequestStatusAndExtSysErrSrcToRequestFlowStatusSuccessfulCompletionTest() throws ApiException { InstanceReferences instanceReferences = new InstanceReferences(); instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); |