summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra
diff options
context:
space:
mode:
authorKuleshov, Elena <evn@att.com>2020-04-07 15:50:32 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-04-07 15:50:34 -0400
commit654db79e01a20632cf1d7c3c6a786160aaa82eed (patch)
tree5098ed345998eee759fa2b193ebaac47b48bf795 /mso-api-handlers/mso-api-handler-infra
parentda123b489a80779f3162d9e007616c6a083414bc (diff)
Add workflowName and operationName to v8 of
Add workflowName and operationName to v8 of orchestrationRequests response. Fix typo in the schema for infra_active_requests. Change version matching for the new interface fields. Issue-ID: SO-2799 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Icc7f3c6271023a578df2c1d969c807a578cc9577
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java19
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java71
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql2
7 files changed, 121 insertions, 2 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java
index 3007ddd7c9..f39a95e92c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java
@@ -197,6 +197,7 @@ public class InstanceManagement {
vnfId = sir.getVnfInstanceId();
}
+ currentActiveReq = setWorkflowNameAndOperationName(currentActiveReq, workflowUuid);
saveCurrentActiveRequest(currentActiveReq);
RequestClientParameter requestClientParameter;
@@ -293,6 +294,7 @@ public class InstanceManagement {
RecipeLookupResult recipeLookupResult = getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid);
+ currentActiveReq = setWorkflowNameAndOperationName(currentActiveReq, workflowUuid);
saveCurrentActiveRequest(currentActiveReq);
RequestClientParameter requestClientParameter;
@@ -357,4 +359,14 @@ public class InstanceManagement {
}
return null;
}
+
+ protected InfraActiveRequests setWorkflowNameAndOperationName(InfraActiveRequests currentActiveReq,
+ String workflowUuid) {
+ Workflow workflow = catalogDbClient.findWorkflowByArtifactUUID(workflowUuid);
+ if (workflow != null) {
+ currentActiveReq.setWorkflowName(workflow.getName());
+ currentActiveReq.setOperationName(workflow.getOperationName());
+ }
+ return currentActiveReq;
+ }
}
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 c43a050500..3993c65008 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
@@ -311,6 +311,19 @@ public class OrchestrationRequests {
request.setOriginalRequestId(originalRequestId);
}
+ if (!version.matches("v[1-7]")) {
+ String workflowName = iar.getWorkflowName();
+ if (workflowName == null) {
+ workflowName = iar.getRequestAction();
+ }
+ request.setWorkflowName(workflowName);
+
+ String operationName = iar.getOperationName();
+ if (operationName != null) {
+ request.setOperationName(operationName);
+ }
+ }
+
InstanceReferences ir = new InstanceReferences();
if (iar.getNetworkId() != null)
ir.setNetworkInstanceId(iar.getNetworkId());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java
index ba7fe2b9cb..081f235db1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java
@@ -45,9 +45,11 @@ import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.logger.HttpHeadersConstants;
import org.onap.so.serviceinstancebeans.RequestReferences;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -63,6 +65,9 @@ public class InstanceManagementTest extends BaseTest {
private final ObjectMapper mapper = new ObjectMapper();
private ObjectMapper errorMapper = new ObjectMapper();
+ @Autowired
+ InstanceManagement instanceManagement;
+
@Value("${wiremock.server.port}")
private String wiremockPort;
@@ -201,4 +206,18 @@ public class InstanceManagementTest extends BaseTest {
ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
}
+
+ @Test
+ public void workflowAndOperationNameTest() {
+ wireMockServer.stubFor(get(urlMatching(
+ ".*/workflow/search/findByArtifactUUID[?]artifactUUID=71526781-e55c-4cb7-adb3-97e09d9c76be"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(getWiremockResponseForCatalogdb("workflow_Response.json"))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+ InfraActiveRequests activeReq = new InfraActiveRequests();
+ activeReq =
+ instanceManagement.setWorkflowNameAndOperationName(activeReq, "71526781-e55c-4cb7-adb3-97e09d9c76be");
+ assertEquals(activeReq.getWorkflowName(), "testingWorkflow");
+ assertEquals(activeReq.getOperationName(), "testOperation");
+ }
}
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 3db2b2d96d..fdaca3566f 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
@@ -85,6 +85,9 @@ public class OrchestrationRequestsUnitTest {
private static final String RETRY_STATUS_MESSAGE = "RetryStatusMessage";
private static final String ROLLBACK_STATUS_MESSAGE = "RollbackStatusMessage";
private static final String TASK_INFORMATION = " TASK INFORMATION: Last task executed: Call SDNC";
+ private static final String WORKFLOW_NAME = "testWorkflowName";
+ private static final String OPERATION_NAME = "testOperationName";
+ private static final String REQUEST_ACTION = "createInstance";
private InfraActiveRequests iar;
boolean includeCloudRequest = false;
private static final String ROLLBACK_EXT_SYSTEM_ERROR_SOURCE = "SDNC";
@@ -152,12 +155,80 @@ public class OrchestrationRequestsUnitTest {
expected.setRequestScope(SERVICE);
expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT");
+ iar.setWorkflowName(WORKFLOW_NAME);
+ iar.setOperationName(OPERATION_NAME);
+
Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertThat(result, sameBeanAs(expected));
}
@Test
+ public void mapInfraActiveRequestToRequestWithWorkflowNameAndOperationNameTest() throws ApiException {
+ doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
+ InstanceReferences instanceReferences = new InstanceReferences();
+ 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 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.setOriginalRequestId(ORIGINAL_REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+ expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT");
+ expected.setWorkflowName(WORKFLOW_NAME);
+ expected.setOperationName(OPERATION_NAME);
+
+ iar.setOriginalRequestId(ORIGINAL_REQUEST_ID);
+ iar.setWorkflowName(WORKFLOW_NAME);
+ iar.setOperationName(OPERATION_NAME);
+
+ Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString(), "v8");
+ assertThat(result, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapInfraActiveRequestToRequestWithNoWorkflowNameAndNoOperationNameTest() throws ApiException {
+ doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
+ InstanceReferences instanceReferences = new InstanceReferences();
+ 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 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.setOriginalRequestId(ORIGINAL_REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+ expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT");
+
+
+ expected.setWorkflowName(REQUEST_ACTION);
+ expected.setRequestType(REQUEST_ACTION);
+
+ iar.setOriginalRequestId(ORIGINAL_REQUEST_ID);
+ iar.setRequestAction(REQUEST_ACTION);
+ iar.setWorkflowName(null);
+ iar.setOperationName(null);
+
+ Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest,
+ OrchestrationRequestFormat.DETAIL.toString(), "v8");
+ assertThat(result, sameBeanAs(expected));
+ }
+
+ @Test
public void mapRequestStatusAndExtSysErrSrcToRequestFalseTest() throws ApiException {
doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
InstanceReferences instanceReferences = new InstanceReferences();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json
index d6ed585537..5877f43a92 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json
@@ -1,5 +1,6 @@
{
"artifactUUID": "71526781-e55c-4cb7-adb3-97e09d9c76be",
"artifactName": "testingWorkflow.bpmn",
- "name": "testingWorkflow"
+ "name": "testingWorkflow",
+ "operationName": "testOperation"
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json
index 133d8bed9b..1d6cd43bf7 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json
@@ -1,5 +1,6 @@
{
"artifactUUID": "81526781-e55c-4cb7-adb3-97e09d9c76bf",
"artifactName": "testingPNFWorkflow.bpmn",
- "name": "testingPNFWorkflow"
+ "name": "testingPNFWorkflow",
+ "operationName": "testPnfOperation"
} \ No newline at end of file
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 19855bc85e..fd8c273b57 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
@@ -1300,6 +1300,8 @@ CREATE TABLE `infra_active_requests` (
`TENANT_NAME` varchar(200) DEFAULT NULL,
`PRODUCT_FAMILY_NAME` varchar(200) DEFAULT NULL,
`RESOURCE_STATUS_MESSAGE` longtext,
+ `WORKFLOW_NAME` varchar(200) DEFAULT NULL,
+ `OPERATION_NAME` varchar(200) DEFAULT NULL,
PRIMARY KEY (`REQUEST_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;