summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-03-10 14:54:10 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-10 14:54:10 +0000
commit43fc1ee27456a17668e5f3f424a0bc6b7973e6e8 (patch)
treee867127dae70e6f698938a33585b2bc117963859 /mso-api-handlers/mso-api-handler-infra/src
parent4dc7f5c75956c68223003ad10670ef47bdad6e26 (diff)
parent7b42dee721e03ee3f0a52dda92010e09d748cf72 (diff)
Merge "false positive on network creates"
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java30
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java98
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql2
3 files changed, 93 insertions, 37 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 4e019ca602..33c2ac80be 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
@@ -106,7 +106,7 @@ public class OrchestrationRequests {
private CamundaRequestHandler camundaRequestHandler;
@GET
- @Path("/{version:[vV][4-7]}/{requestId}")
+ @Path("/{version:[vV][4-8]}/{requestId}")
@Operation(description = "Find Orchestrated Requests for a given requestId", responses = @ApiResponse(
content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
@Produces(MediaType.APPLICATION_JSON)
@@ -115,7 +115,6 @@ public class OrchestrationRequests {
@PathParam("version") String version, @QueryParam("includeCloudRequest") boolean includeCloudRequest,
@QueryParam(value = "format") String format) throws ApiException {
- String apiVersion = version.substring(1);
GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse();
InfraActiveRequests infraActiveRequest = null;
@@ -152,7 +151,7 @@ public class OrchestrationRequests {
}
}
- Request request = mapInfraActiveRequestToRequest(infraActiveRequest, includeCloudRequest, format);
+ Request request = mapInfraActiveRequestToRequest(infraActiveRequest, includeCloudRequest, format, version);
if (null != requestProcessingData && !requestProcessingData.isEmpty()) {
request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData));
@@ -161,11 +160,11 @@ public class OrchestrationRequests {
orchestrationResponse.setRequest(request);
return builder.buildResponse(HttpStatus.SC_OK, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID), orchestrationResponse,
- apiVersion);
+ version);
}
@GET
- @Path("/{version:[vV][4-7]}")
+ @Path("/{version:[vV][4-8]}")
@Operation(description = "Find Orchestrated Requests for a URI Information", responses = @ApiResponse(
content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
@Produces(MediaType.APPLICATION_JSON)
@@ -206,7 +205,7 @@ public class OrchestrationRequests {
for (InfraActiveRequests infraActive : activeRequests) {
RequestList requestList = new RequestList();
- Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest, format);
+ Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest, format, version);
if (isRequestProcessingDataRequired(format)) {
List<RequestProcessingData> requestProcessingData =
@@ -292,7 +291,7 @@ public class OrchestrationRequests {
}
protected Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest,
- String format) throws ApiException {
+ String format, String version) throws ApiException {
String requestBody = iar.getRequestBody();
Request request = new Request();
@@ -402,7 +401,7 @@ public class OrchestrationRequests {
});
}
- mapRequestStatusAndExtSysErrSrcToRequest(iar, status, format);
+ mapRequestStatusAndExtSysErrSrcToRequest(iar, status, format, version);
request.setRequestStatus(status);
return request;
@@ -431,7 +430,7 @@ public class OrchestrationRequests {
}
protected void mapRequestStatusAndExtSysErrSrcToRequest(InfraActiveRequests iar, RequestStatus status,
- String format) {
+ String format, String version) {
String rollbackStatusMessage = iar.getRollbackStatusMessage();
String flowStatusMessage = iar.getFlowStatus();
String retryStatusMessage = iar.getRetryStatusMessage();
@@ -467,6 +466,12 @@ public class OrchestrationRequests {
if (rollbackStatusMessage != null) {
status.setRollbackStatusMessage(rollbackStatusMessage);
}
+ if (version.matches("v[8-9]|v[1-9][0-9]")) {
+ if (iar.getResourceStatusMessage() != null) {
+ status.setResourceStatusMessage(iar.getResourceStatusMessage());
+ }
+ }
+
status.setExtSystemErrorSource(iar.getExtSystemErrorSource());
status.setRollbackExtSystemErrorSource(iar.getRollbackExtSystemErrorSource());
} else {
@@ -492,6 +497,13 @@ public class OrchestrationRequests {
statusMessages = "ROLLBACK STATUS: " + rollbackStatusMessage;
}
}
+ if (iar.getResourceStatusMessage() != null) {
+ if (statusMessages != null) {
+ statusMessages = statusMessages + " " + "RESOURCE STATUS: " + iar.getResourceStatusMessage();
+ } else {
+ statusMessages = "RESOURCE STATUS: " + iar.getResourceStatusMessage();
+ }
+ }
}
if (statusMessages != null) {
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 22c82bf75c..4631b53bc0 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
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,9 +25,9 @@ import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
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;
@@ -92,6 +92,7 @@ public class OrchestrationRequestsUnitTest {
iar.setFlowStatus(FLOW_STATUS);
iar.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE);
iar.setRetryStatusMessage(RETRY_STATUS_MESSAGE);
+ iar.setResourceStatusMessage("The vf module already exist");
}
@Test
@@ -101,8 +102,10 @@ public class OrchestrationRequestsUnitTest {
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
- requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
- FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+ requestStatus.setStatusMessage(
+ String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s",
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE,
+ "The vf module already exist"));
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
@@ -114,7 +117,7 @@ public class OrchestrationRequestsUnitTest {
iar.setOriginalRequestId(ORIGINAL_REQUEST_ID);
Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
- OrchestrationRequestFormat.DETAIL.toString());
+ OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertThat(result, sameBeanAs(expected));
}
@@ -125,8 +128,11 @@ public class OrchestrationRequestsUnitTest {
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
- requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
- FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+ requestStatus.setStatusMessage(
+ String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s",
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE,
+ "The vf module already exist"));
+
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
expected.setInstanceReferences(instanceReferences);
@@ -134,7 +140,7 @@ public class OrchestrationRequestsUnitTest {
expected.setRequestScope(SERVICE);
Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
- OrchestrationRequestFormat.DETAIL.toString());
+ OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertThat(result, sameBeanAs(expected));
}
@@ -145,8 +151,10 @@ public class OrchestrationRequestsUnitTest {
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
- requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
- FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+ requestStatus.setStatusMessage(
+ String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s",
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE,
+ "The vf module already exist"));
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
@@ -157,7 +165,7 @@ public class OrchestrationRequestsUnitTest {
includeCloudRequest = false;
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
- OrchestrationRequestFormat.DETAIL.toString());
+ OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertThat(actual, sameBeanAs(expected));
}
@@ -183,7 +191,34 @@ public class OrchestrationRequestsUnitTest {
includeCloudRequest = false;
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
- OrchestrationRequestFormat.STATUSDETAIL.toString());
+ OrchestrationRequestFormat.STATUSDETAIL.toString(), "v7");
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapRequestStatusAndExtSysErrSrcToRequestStatusDetailV8Test() throws ApiException {
+ doReturn(null).when(camundaRequestHandler).getTaskName(REQUEST_ID);
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE);
+ requestStatus.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE);
+ requestStatus.setRequestState(iar.getRequestStatus());
+ requestStatus.setFlowStatus(FLOW_STATUS);
+ requestStatus.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE);
+ requestStatus.setRetryStatusMessage(RETRY_STATUS_MESSAGE);
+ requestStatus.setResourceStatusMessage("The vf module already exist");
+
+ 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.STATUSDETAIL.toString(), "v8");
assertThat(actual, sameBeanAs(expected));
}
@@ -194,7 +229,7 @@ public class OrchestrationRequestsUnitTest {
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
requestStatus.setStatusMessage(
- "FLOW STATUS: FlowStatus RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage");
+ "FLOW STATUS: FlowStatus RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage RESOURCE STATUS: The vf module already exist");
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
@@ -205,7 +240,7 @@ public class OrchestrationRequestsUnitTest {
includeCloudRequest = false;
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
- OrchestrationRequestFormat.SIMPLENOTASKINFO.toString());
+ OrchestrationRequestFormat.SIMPLENOTASKINFO.toString(), "v7");
assertThat(expected, sameBeanAs(actual));
}
@@ -217,7 +252,7 @@ public class OrchestrationRequestsUnitTest {
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
requestStatus.setStatusMessage(
- "FLOW STATUS: FlowStatus TASK INFORMATION: TaskName RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage");
+ "FLOW STATUS: FlowStatus TASK INFORMATION: TaskName RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage RESOURCE STATUS: The vf module already exist");
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
@@ -227,7 +262,7 @@ public class OrchestrationRequestsUnitTest {
includeCloudRequest = false;
- Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, null);
+ Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, null, "v7");
assertThat(expected, sameBeanAs(actual));
}
@@ -238,8 +273,10 @@ public class OrchestrationRequestsUnitTest {
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
- requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
- FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+ requestStatus.setStatusMessage(
+ String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s",
+ FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE,
+ "The vf module already exist"));
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
@@ -250,7 +287,7 @@ public class OrchestrationRequestsUnitTest {
includeCloudRequest = false;
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
- OrchestrationRequestFormat.DETAIL.toString());
+ OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertThat(actual, sameBeanAs(expected));
}
@@ -272,9 +309,10 @@ public class OrchestrationRequestsUnitTest {
includeCloudRequest = false;
iar.setFlowStatus(null);
+ iar.setResourceStatusMessage(null);
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
- OrchestrationRequestFormat.DETAIL.toString());
+ OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertThat(actual, sameBeanAs(expected));
}
@@ -288,7 +326,7 @@ public class OrchestrationRequestsUnitTest {
iar.setStatusMessage("Error retrieving cloud region from AAI");
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
- OrchestrationRequestFormat.DETAIL.toString());
+ OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertTrue(actual.getRequestStatus().getStatusMessage()
.contains("Error Source: " + ROLLBACK_EXT_SYSTEM_ERROR_SOURCE));
@@ -300,8 +338,10 @@ public class OrchestrationRequestsUnitTest {
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
- requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
- "Successfully completed all Building Blocks", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+ requestStatus.setStatusMessage(
+ String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s",
+ "Successfully completed all Building Blocks", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE,
+ "The vf module already exist"));
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
@@ -313,7 +353,7 @@ public class OrchestrationRequestsUnitTest {
iar.setFlowStatus("Successfully completed all Building Blocks");
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
- OrchestrationRequestFormat.DETAIL.toString());
+ OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertThat(actual, sameBeanAs(expected));
}
@@ -324,8 +364,10 @@ public class OrchestrationRequestsUnitTest {
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
- requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s",
- "All Rollback flows have completed successfully", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
+ requestStatus.setStatusMessage(
+ String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s",
+ "All Rollback flows have completed successfully", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE,
+ "The vf module already exist"));
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
@@ -337,7 +379,7 @@ public class OrchestrationRequestsUnitTest {
iar.setFlowStatus("All Rollback flows have completed successfully");
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
- OrchestrationRequestFormat.DETAIL.toString());
+ OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertThat(actual, sameBeanAs(expected));
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
index 85a17dd369..19855bc85e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
@@ -1299,6 +1299,7 @@ CREATE TABLE `infra_active_requests` (
`ROLLBACK_EXT_SYSTEM_ERROR_SOURCE` varchar(80) DEFAULT NULL,
`TENANT_NAME` varchar(200) DEFAULT NULL,
`PRODUCT_FAMILY_NAME` varchar(200) DEFAULT NULL,
+ `RESOURCE_STATUS_MESSAGE` longtext,
PRIMARY KEY (`REQUEST_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
@@ -1342,6 +1343,7 @@ CREATE TABLE `archived_infra_requests` (
`OPERATIONAL_ENV_ID` varchar(45) DEFAULT NULL,
`OPERATIONAL_ENV_NAME` varchar(200) DEFAULT NULL,
`REQUEST_URL` varchar(500) DEFAULT NULL,
+ `RESOURCE_STATUS_MESSAGE` longtext,
PRIMARY KEY (`REQUEST_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;