diff options
Diffstat (limited to 'bpmn')
8 files changed, 95 insertions, 37 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/Client/InfraActiveRequestExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/Client/InfraActiveRequestExpected.json index fe58357d53..361dd9f405 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/Client/InfraActiveRequestExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/Client/InfraActiveRequestExpected.json @@ -1,7 +1,5 @@ { "requestId": "00032ab7-3fb3-42e5-965d-8ea592502017", - "clientRequestId": "00032ab7-3fb3-42e5-965d-8ea592502016", - "action": "deleteInstance", "requestStatus": "COMPLETE", "statusMessage": "Vf Module has been deleted successfully.", "progress": 100, @@ -12,22 +10,18 @@ "vnfName": null, "vnfType": null, "serviceType": null, - "aicNodeClli": null, "tenantId": "6accefef3cb442ff9e644d589fb04107", - "provStatus": null, "vnfParams": null, "vnfOutputs": null, "requestBody": "{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"vSAMP10aDEV::base::module-0\"},\"requestInfo\":{\"source\":\"VID\"},\"cloudConfiguration\":{\"tenantId\":\"6accefef3cb442ff9e644d589fb04107\",\"lcpCloudRegionId\":\"mtn6\"}}", "responseBody": null, "lastModifiedBy": "BPMN", "modifyTime": 1482451228000, - "requestType": null, "volumeGroupId": null, "volumeGroupName": null, "vfModuleId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992", "vfModuleName": null, "vfModuleModelName": "vSAMP10aDEV::base::module-0", - "aaiServiceId": null, "aicCloudRegion": "mtn6", "callBackUrl": null, "correlator": null, diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/InfraActiveRequestExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/InfraActiveRequestExpected.json index dd4dc65190..9c962e9722 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/InfraActiveRequestExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/InfraActiveRequestExpected.json @@ -1,7 +1,5 @@ { "requestId": "00032ab7-3fb3-42e5-965d-8ea592502017", - "clientRequestId": "00032ab7-3fb3-42e5-965d-8ea592502016", - "action": "deleteInstance", "requestStatus": "COMPLETE", "statusMessage": "Vf Module has been deleted successfully.", "progress": 100, @@ -12,22 +10,18 @@ "vnfName": null, "vnfType": null, "serviceType": null, - "aicNodeClli": null, "tenantId": "6accefef3cb442ff9e644d589fb04107", - "provStatus": null, "vnfParams": null, "vnfOutputs": null, "requestBody": "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"vSAMP10aDEV::base::module-0\"},\"requestInfo\":{\"source\":\"VID\"},\"cloudConfiguration\":{\"tenantId\":\"6accefef3cb442ff9e644d589fb04107\",\"lcpCloudRegionId\":\"mtn6\"}}}", "responseBody": null, "lastModifiedBy": "BPMN", "modifyTime": 1482451228000, - "requestType": null, "volumeGroupId": null, "volumeGroupName": null, "vfModuleId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992", "vfModuleName": null, "vfModuleModelName": "vSAMP10aDEV::base::module-0", - "aaiServiceId": null, "aicCloudRegion": "mtn6", "callBackUrl": null, "correlator": null, diff --git a/bpmn/MSOCommonBPMN/src/test/resources/response/infraActiveRequestsResponse.json b/bpmn/MSOCommonBPMN/src/test/resources/response/infraActiveRequestsResponse.json index 9cc84f2cd4..3623e888e7 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/response/infraActiveRequestsResponse.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/response/infraActiveRequestsResponse.json @@ -1,7 +1,5 @@ { "requestId": "00032ab7-3fb3-42e5-965d-8ea592502017", - "clientRequestId": "00032ab7-3fb3-42e5-965d-8ea592502016", - "action": "deleteInstance", "requestStatus": "COMPLETE", "statusMessage": "Vf Module has been deleted successfully.", "progress": 100, @@ -12,22 +10,18 @@ "vnfName": null, "vnfType": null, "serviceType": null, - "aicNodeClli": null, "tenantId": "6accefef3cb442ff9e644d589fb04107", - "provStatus": null, "vnfParams": null, "vnfOutputs": null, "requestBody": "{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"vSAMP10aDEV::base::module-0\"},\"requestInfo\":{\"source\":\"VID\"},\"cloudConfiguration\":{\"tenantId\":\"6accefef3cb442ff9e644d589fb04107\",\"lcpCloudRegionId\":\"mtn6\"}}", "responseBody": null, "lastModifiedBy": "BPMN", "modifyTime": 1482451228000, - "requestType": null, "volumeGroupId": null, "volumeGroupName": null, "vfModuleId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992", "vfModuleName": null, "vfModuleModelName": "vSAMP10aDEV::base::module-0", - "aaiServiceId": null, "aicCloudRegion": "mtn6", "callBackUrl": null, "correlator": null, diff --git a/bpmn/mso-infrastructure-bpmn/pom.xml b/bpmn/mso-infrastructure-bpmn/pom.xml index 25913eabba..1ae0dd48f7 100644 --- a/bpmn/mso-infrastructure-bpmn/pom.xml +++ b/bpmn/mso-infrastructure-bpmn/pom.xml @@ -93,10 +93,19 @@ <artifactId>maven-jar-plugin</artifactId> <executions> <execution> - <id>tests</id> + <id>tests-jar</id> + <goals> + <goal>test-jar</goal> + </goals> + <configuration> + <skip>false</skip> + </configuration> </execution> <execution> <id>original</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java index ace6e1937d..4fb63651eb 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -102,7 +102,11 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, getRequestId(inputVariables)); processor.startProcess(processKey, variableMap); WorkflowResponse response = waitForResponse(inputVariables); - return Response.status(202).entity(response).build(); + if (response.getMessageCode() == 500) { + return Response.status(500).entity(response).build(); + } else { + return Response.status(202).entity(response).build(); + } } catch (WorkflowProcessorException e) { WorkflowResponse response = e.getWorkflowResponse(); return Response.status(500).entity(response).build(); @@ -112,7 +116,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { } } - private WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception { + protected WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception { String requestId = getRequestId(inputVariables); long currentWaitTime = 0; long waitTime = getWaitTime(inputVariables); diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceTest.java new file mode 100644 index 0000000000..df9a23019a --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceTest.java @@ -0,0 +1,59 @@ +package org.onap.so.bpmn.common.workflow.service; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; +import static org.mockito.ArgumentMatchers.anyMap; +import java.util.HashMap; +import java.util.Map; +import javax.ws.rs.core.Response; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; + +@RunWith(MockitoJUnitRunner.class) +public class WorkflowAsyncResourceTest { + + @InjectMocks + @Spy + private WorkflowAsyncResource workflowAsyncResource; + + @Mock + private WorkflowProcessor processor; + + private WorkflowResponse workflowResponse; + private VariableMapImpl varMap; + + @Before + public void before() { + workflowResponse = new WorkflowResponse(); + varMap = new VariableMapImpl(); + Map<String, Object> variables = new HashMap<String, Object>(); + Map<String, Object> requestIdMap = new HashMap<String, Object>(); + requestIdMap.put("value", "123"); + requestIdMap.put("type", "String"); + variables.put("mso-request-id", requestIdMap); + varMap.put("variables", variables); + } + + @Test + public void startProcessInstanceByKey200Test() throws Exception { + workflowResponse.setMessageCode(200); + doReturn(workflowResponse).when(workflowAsyncResource).waitForResponse(anyMap()); + Response response = workflowAsyncResource.startProcessInstanceByKey("123", varMap); + assertEquals(202, response.getStatus()); + } + + @Test + public void startProcessInstanceByKey500Test() throws Exception { + workflowResponse.setMessageCode(500); + doReturn(workflowResponse).when(workflowAsyncResource).waitForResponse(anyMap()); + Response response = workflowAsyncResource.startProcessInstanceByKey("123", varMap); + assertEquals(500, response.getStatus()); + } +} diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index e112fdc161..f2e0ce29ff 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn @@ -89,7 +89,7 @@ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isTopLevelFlow")==true&&execution.getVariable("sentSyncResponse")==false}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_0eana0l" sourceRef="Task_SendSyncAckError" targetRef="Task_UpdateDb" /> - <bpmn:serviceTask id="Task_SendSyncAckError" name="Send Sync Ack API Handler" camunda:asyncAfter="true" camunda:expression="${WorkflowActionBBTasks.sendSyncAck(execution)}"> + <bpmn:serviceTask id="Task_SendSyncAckError" name="Send Sync Ack API Handler" camunda:asyncAfter="true" camunda:expression="${WorkflowActionBBTasks.sendErrorSyncAck(execution)}"> <bpmn:incoming>SequenceFlow_0vi883o</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0eana0l</bpmn:outgoing> </bpmn:serviceTask> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 11c6455474..c3f5a98ce7 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -71,11 +71,13 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.Networks; import org.onap.so.serviceinstancebeans.RelatedInstance; import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.VfModules; @@ -182,21 +184,7 @@ public class WorkflowAction { execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, true); ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); RequestDetails requestDetails = sIRequest.getRequestDetails(); - String cloudOwner = ""; - try { - cloudOwner = requestDetails.getCloudConfiguration().getCloudOwner(); - } catch (Exception ex) { - logger.error("Exception in getCloundOwner", ex); - cloudOwner = environment.getProperty(defaultCloudOwner); - } - boolean suppressRollback = false; - try { - suppressRollback = requestDetails.getRequestInfo().getSuppressRollback(); - } catch (Exception ex) { - logger.error("Exception in getSuppressRollback", ex); - suppressRollback = false; - } - execution.setVariable("suppressRollback", suppressRollback); + execution.setVariable("suppressRollback", isSuppressRollback(requestDetails.getRequestInfo())); boolean isResume = false; if (isUriResume(uri)) { isResume = true; @@ -234,6 +222,7 @@ public class WorkflowAction { "Could not resume request with request Id: " + requestId + ". No flowsToExecute was found"); } } else { + String cloudOwner = getCloudOwner(requestDetails.getCloudConfiguration()); if (aLaCarte) { if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, @@ -410,6 +399,21 @@ public class WorkflowAction { } } + private String getCloudOwner(CloudConfiguration cloudConfiguration) { + if (cloudConfiguration != null && cloudConfiguration.getCloudOwner() != null) { + return cloudConfiguration.getCloudOwner(); + } + logger.warn("cloud owner value not found in request details, it will be set as default"); + return environment.getProperty(defaultCloudOwner); + } + + private boolean isSuppressRollback(RequestInfo requestInfo) { + if (requestInfo != null) { + return requestInfo.getSuppressRollback(); + } + return false; + } + protected <T> List<T> getRelatedResourcesInVfModule(String vnfId, String vfModuleId, Class<T> resultClass, AAIObjectType type) { List<T> vnfcs = new ArrayList<>(); |