diff options
Diffstat (limited to 'bpmn')
34 files changed, 452 insertions, 282 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy index ba450c1b12..58c8f27de9 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy @@ -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. @@ -281,14 +281,14 @@ class SDNCAdapterUtils { } boolean isAic3 = execution.getVariable("isAic3") - + if(isAic3) { nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0") } else { nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X") } - + String content = """ <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1" xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1"> @@ -319,7 +319,7 @@ class SDNCAdapterUtils { /** * Builds an SDNC "reserve" request and stores it in the specified execution - * variable. + * variable. * @param execution the execution * @param action the type of action: reserve, turnup, etc * @param resultVar the execution variable in which the result will be stored @@ -424,7 +424,7 @@ class SDNCAdapterUtils { if (additionalData == null) { additionalData = "" } - + if(isAic3) { nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0") } @@ -470,7 +470,7 @@ class SDNCAdapterUtils { exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error") } } - + public String updateHomingInfo(String homingInfo, String aicVersion) { String newHomingInfo if(homingInfo == null || homingInfo.trim().length() == 0) { @@ -480,7 +480,7 @@ class SDNCAdapterUtils { newHomingInfo = homingInfo.substring(0, homingInfo.indexOf("</l2-homing-information>")) + "<aic-version>" + aicVersion + "</aic-version></l2-homing-information>" } } - + /** * Builds a topology SDNC request and return String request. * As V2 will use 1607-style request, region instead of aic clli code @@ -506,7 +506,7 @@ class SDNCAdapterUtils { } else { hdrRequestId = testHdrRequestId } - + String requestId = "" try { requestId = execution.getVariable("mso-request-id") @@ -561,6 +561,9 @@ class SDNCAdapterUtils { int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/") subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd) subscriberName = UriUtils.decode(subscriberName,"UTF-8") + }else{ + serviceType = execution.getVariable("serviceType") + subscriberName = execution.getVariable("subscriberName") } String content = @@ -635,11 +638,11 @@ class SDNCAdapterUtils { requestId = execution.getVariable("mso-request-id") if (requestId == null) { requestId = execution.getVariable("msoRequestId") - } + } } else { requestId = testRequestId - } - + } + String aicCloudRegion = cloudRegionId String tenantId = "" if (utils.nodeExists(requestXML, "tenant-id")) { @@ -717,7 +720,7 @@ class SDNCAdapterUtils { String content = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" - xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" + xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> <sdncadapter:RequestHeader> <sdncadapter:RequestId>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId> @@ -993,7 +996,7 @@ class SDNCAdapterUtils { exceptionUtil.buildAndThrowWorkflowException(execution, 400, msg) } } - + public String modelInfoToEcompModelInformation(String jsonModelInfo) { String modelInvariantUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelInvariantUuid") String modelUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelUuid") @@ -1004,11 +1007,11 @@ class SDNCAdapterUtils { String modelCustomizationString = "" if (modelCustomizationUuid != null) { modelCustomizationString = "<model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>" - } + } String modelVersion = jsonUtil.getJsonValue(jsonModelInfo, "modelVersion") if (modelVersion == null) { modelVersion = "" - } + } String modelName = jsonUtil.getJsonValue(jsonModelInfo, "modelName") String ecompModelInformation = """<onap-model-information> @@ -1019,6 +1022,6 @@ class SDNCAdapterUtils { <model-name>${MsoUtils.xmlEscape(modelName)}</model-name> </onap-model-information>""" - return ecompModelInformation - } + return ecompModelInformation + } }
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index b5203c676a..67fb6a6f37 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -346,13 +346,15 @@ public class BBInputSetup implements JavaDelegate { ModelInfo vnfModelInfo = new ModelInfo(); vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); this.mapCatalogVnf(tempVnf, vnfModelInfo, service); - for(VolumeGroup volumeGroup : tempVnf.getVolumeGroups()) { - String volumeGroupCustId = - this.bbInputSetupUtils.getAAIVolumeGroup(CLOUD_OWNER, - cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()).getModelCustomizationId(); - if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) { - lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); - break; + if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) == null) { + for(VolumeGroup volumeGroup : tempVnf.getVolumeGroups()) { + String volumeGroupCustId = + this.bbInputSetupUtils.getAAIVolumeGroup(CLOUD_OWNER, + cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()).getModelCustomizationId(); + if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) { + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); + break; + } } } break; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowProcessorException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowProcessorException.java new file mode 100644 index 0000000000..768bee578c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowProcessorException.java @@ -0,0 +1,19 @@ +package org.openecomp.mso.bpmn.common.workflow.service; + +import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; + +/** + * Exception thrown when an error occurs while processing the workflow. + * This encapsulates the workflow response so that the same can be sent back to api handler. + */ +public class WorkflowProcessorException extends RuntimeException { + WorkflowResponse workflowResponse; + + public WorkflowProcessorException(WorkflowResponse workflowResponse) { + this.workflowResponse = workflowResponse; + } + + public WorkflowResponse getWorkflowResponse() { + return workflowResponse; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DecomposeServiceTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DecomposeServiceTest.groovy new file mode 100644 index 0000000000..5deec5b434 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DecomposeServiceTest.groovy @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.scripts + +import org.junit.Before +import org.mockito.MockitoAnnotations +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.NetworkResource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.json.DecomposeJsonUtil +import org.onap.so.bpmn.core.domain.ServiceInstance + +import org.onap.so.bpmn.mock.FileUtil +import static org.mockito.Mockito.* +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import static org.junit.Assert.*; +import org.junit.Test; +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; + +class DecomposeServiceTest { + + @Test + public void testDecomposeService() { + + String catalogDbResponse = FileUtil.readResourceFile("__files/decomposition/catalogDbResponse.json"); + + ServiceDecomposition serviceDecomposition = new ServiceDecomposition(); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setInstanceId("serviceInstanceID"); + serviceDecomposition.setServiceType(""); + serviceDecomposition.setServiceRole(""); + + ArrayList networkResources = new ArrayList(); + NetworkResource networkResource = new NetworkResource(); + networkResource.setNetworkType("testNetworkType"); + networkResource.setNetworkRole("testNetworkRole"); + networkResource.setNetworkScope("testNetworkScope"); + networkResource.setToscaNodeType("testToscaModelType") + networkResource.setNetworkTechnology("testNetworkTechnology"); + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelName("testModleName"); + modelInfo.setModelUuid("testModelUuid") + modelInfo.setModelInvariantUuid("testModelInvariantId") + modelInfo.setModelVersion("testModelVersion"); + modelInfo.setModelCustomizationUuid("testModelCustomizationUuid"); + modelInfo.setModelInstanceName("testModelInstanceName"); + networkResource.setModelInfo(modelInfo); + + networkResources.add(networkResource); + serviceDecomposition.setNetworkResources(networkResources) + serviceDecomposition.setServiceInstance(serviceInstance); + + ServiceDecomposition serviceDecompositionExtracted = DecomposeJsonUtil.jsonToServiceDecomposition(catalogDbResponse, "serviceInstanceID") + + assertThat(serviceDecompositionExtracted, sameBeanAs(serviceDecomposition).ignoring("modelInfo").ignoring("vnfResources").ignoring("allottedResources").ignoring("networkResources.resourceId")); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/decomposition/catalogDbResponse.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/decomposition/catalogDbResponse.json new file mode 100644 index 0000000000..087233d08b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/decomposition/catalogDbResponse.json @@ -0,0 +1,33 @@ +{ + "serviceResources": { + "serviceType": "", + "workloadContext": "testWorkloadContext", + "serviceAllottedResources": [], + "modelInfo": { + "modelInvariantUuid": "testModelInvariantId", + "modelName": "testModleName", + "modelVersion": "testModelVersion", + "modelUuid": "testModelUuid" + }, + "environmentContext": "testEnvironmentContent", + "serviceRole": "", + "serviceVnfs": [], + "serviceNetworks": [ + { + "toscaNodeType": "testToscaModelType", + "networkTechnology": "testNetworkTechnology", + "networkScope": "testNetworkScope", + "modelInfo": { + "modelInvariantUuid": "testModelInvariantId", + "modelName": "testModleName", + "modelVersion": "testModelVersion", + "modelCustomizationUuid": "testModelCustomizationUuid", + "modelInstanceName": "testModelInstanceName", + "modelUuid": "testModelUuid" + }, + "networkRole": "testNetworkRole", + "networkType": "testNetworkType" + } + ] + } +}
\ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java index 099f084637..5e7a4796c4 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java @@ -69,7 +69,7 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { private OwningEntity owningEntity; @JsonProperty("serviceVnfs") private List <VnfResource> vnfResources; - @JsonProperty("networkResource") + @JsonProperty("serviceNetworks") private List <NetworkResource> networkResources; @JsonProperty("serviceAllottedResources") private List <AllottedResource> allottedResources; diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java index 82470f125b..5d8d55152c 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java @@ -103,6 +103,8 @@ public class ServiceDecompositionTest { serviceDecomp.addResource(allottedResource); serviceDecomp.addResource(configResource); + System.out.println(serviceDecomp.toJsonString()); + assertThat(serviceDecomp.getServiceResource(vnfResource.getResourceId()), sameBeanAs(vnfResource)); assertThat(serviceDecomp.getServiceResource(networkResource.getResourceId()), sameBeanAs(networkResource)); assertThat(serviceDecomp.getServiceResource(allottedResource.getResourceId()), sameBeanAs(allottedResource)); diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json index c424293ca2..f094e99782 100644 --- a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json +++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json @@ -1,51 +1,59 @@ { - "serviceResources" : { - "modelInfo" : { - "modelName" : "modelName", - "modelUuid" : "modelUuid", - "modelInvariantUuid" : "modelInvariantUuid", - "modelVersion" : "modelVersion", - "modelCustomizationUuid" : "modelCustomizationUuid", - "modelCustomizationName" : "modelCustomizationName", - "modelInstanceName" : "modelInstanceName", - "modelType" : "modelType" - }, - "serviceType" : "serviceType", - "serviceRole" : "serviceRole", - "project" : {}, - "owningEntity" : {}, - "serviceInstance" : { - "serviceInstanceId" : "serviceInstanceId" - }, - "serviceVnfs" : [ - { - "resourceId" : "vnfResourceId", - "resourceType" : "VNF", - "resourceInstance" : {}, - "homingSolution" : { - "license" : {}, - "rehome" : false - }, - "vfModules" : [] - } - ], - "networkResource" : [ - { - "resourceId" : "networkResourceId", - "resourceType" : "NETWORK" - } - ], - "serviceAllottedResources" : [ - { - "resourceId" : "allottedResourceId", - "resourceType" : "ALLOTTED_RESOURCE" - } - ], - "configResource" : [ - { - "resourceId" : "configResourceId", - "resourceType" : "CONFIGURATION" - } - ] - } -} + "serviceResources" : { + "serviceInstance" : { + "instanceId" : "serviceInstanceId", + "customer" : { } + }, + "modelInfo" : { + "modelName" : "modelName", + "modelUuid" : "modelUuid", + "modelInvariantUuid" : "modelInvariantUuid", + "modelVersion" : "modelVersion", + "modelCustomizationUuid" : "modelCustomizationUuid", + "modelCustomizationName" : "modelCustomizationName", + "modelInstanceName" : "modelInstanceName", + "modelType" : "modelType" + }, + "serviceType" : "serviceType", + "serviceRole" : "serviceRole", + "project" : { }, + "owningEntity" : { }, + "serviceVnfs" : [ { + "resourceId" : "vnfResourceId", + "resourceType" : "VNF", + "resourceInstance" : { }, + "homingSolution" : { + "license" : { }, + "rehome" : false + }, + "vfModules" : [ ] + } ], + "serviceNetworks" : [ { + "resourceId" : "networkResourceId", + "resourceType" : "NETWORK", + "resourceInstance" : { }, + "homingSolution" : { + "license" : { }, + "rehome" : false + } + } ], + "serviceAllottedResources" : [ { + "resourceId" : "allottedResourceId", + "resourceType" : "ALLOTTED_RESOURCE", + "resourceInstance" : { }, + "homingSolution" : { + "license" : { }, + "rehome" : false + } + } ], + "configResource" : [ { + "resourceId" : "configResourceId", + "resourceType" : "CONFIGURATION", + "resourceInstance" : { }, + "homingSolution" : { + "license" : { }, + "rehome" : false + } + } ] + } +}
\ No newline at end of file diff --git a/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterface.json b/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterface.json deleted file mode 100644 index b8c123eb15..0000000000 --- a/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterface.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "interface-name": "Xe-7/1/10", - "port-description": "VVIG EGRESS", - "resource-version": "1494002035673", - "relationship-list": { - "relationship": [ - { - "related-to": "physical-link", - "related-link": "/aai/v11/network/physical-links/physical-link/testPhysicalLinkUcpe", - "relationship-data": [ - { - "relationship-key": "physical-link.link-name", - "relationship-value": "L4YS.999964..ATI_EGRESS" - } - ] - } - ] - } -} diff --git a/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterfaces.json b/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterfaces.json deleted file mode 100644 index 9ea3869121..0000000000 --- a/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterfaces.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "p-interface": [ - { - "interface-name": "Xe-7/1/10", - "port-description": "VVIG EGRESS", - "resource-version": "1494002035673", - "relationship-list": { - "relationship": [ - { - "related-to": "physical-link", - "related-link": "/aai/v11/network/physical-links/physical-link/testPhysicalLinkUcpe", - "relationship-data": [ - { - "relationship-key": "physical-link.link-name", - "relationship-value": "L4YS.999964..ATI_EGRESS" - } - ] - } - ] - } - }, - { - "interface-name": "Xe-8/2/11", - "port-description": "VVIG EGRESS", - "resource-version": "1494002035673", - "relationship-list": { - "relationship": [ - { - "related-to": "physical-link", - "related-link": "/aai/v11/network/physical-links/physical-link/testPhysicalLinkUcpe2", - "relationship-data": [ - { - "relationship-key": "physical-link.link-name", - "relationship-value": "L4YS.999964..ATI_EGRESS" - } - ] - } - ] - } - } - ] -}
\ No newline at end of file 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 cfd07d8c39..ef72149d10 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 @@ -40,6 +40,7 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowContext; import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; import org.onap.so.logger.MsoLogger; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -92,7 +93,6 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { /** * Asynchronous JAX-RS method that starts a process instance. - * @param asyncResponse an object that will receive the asynchronous response * @param processKey the process key * @param variableMap input variables to the process * @return @@ -114,7 +114,10 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { processor.startProcess(processKey, variableMap); WorkflowResponse response = waitForResponse(getRequestId(inputVariables)); return Response.status(202).entity(response).build(); - } catch (Exception e) { + } catch (WorkflowProcessorException e) { + WorkflowResponse response = e.getWorkflowResponse(); + return Response.status(500).entity(response).build(); + }catch (Exception e) { WorkflowResponse response = buildUnkownError(getRequestId(inputVariables),e.getMessage()); return Response.status(500).entity(response).build(); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java index edc05afba2..da24ba14fd 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java @@ -28,11 +28,10 @@ import java.util.UUID; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.camunda.bpm.engine.variable.impl.VariableMapImpl; -import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse; -import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; +import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; import org.onap.so.logger.MsoLogger; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException; import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -79,13 +78,12 @@ public class WorkflowProcessor extends ProcessEngineAwareService { msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, logMarker + "Error in starting the process: " + e.getMessage()); - WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse(); - callbackResponse.setStatusCode(500); - callbackResponse.setMessage("Fail"); - callbackResponse.setResponse("Error occurred while executing the process: " + e); - - WorkflowContextHolder.getInstance().processCallback(processKey, processInstanceId, - getRequestId(inputVariables), callbackResponse); + WorkflowResponse workflowResponse = new WorkflowResponse(); + workflowResponse.setResponse("Error occurred while executing the process: " + e); + workflowResponse.setProcessInstanceID(processInstanceId); + workflowResponse.setMessageCode(500); + workflowResponse.setMessage("Fail"); + throw new WorkflowProcessorException(workflowResponse); } } diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java new file mode 100644 index 0000000000..ff5e18c210 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.workflow.service; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import javax.ws.rs.core.Response; + +import org.camunda.bpm.engine.test.Deployment; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; +import org.junit.Test; +import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; + + +public class WorkflowAsyncResourceExceptionHandlingTest { + + @Test + @Deployment(resources = { "testAsyncResource.bpmn" }) + public void asyncRequestSuccess() throws InterruptedException { + VariableMapImpl variableMap = new VariableMapImpl(); + + Map<String, Object> variableValueType = new HashMap<>(); + + Map<String, Object> requestMsg = new HashMap<>(); + requestMsg.put("value", ""); + requestMsg.put("type", "String"); + + Map<String, Object> msorequestId = new HashMap<>(); + msorequestId.put("type", "String"); + msorequestId.put("value",UUID.randomUUID().toString()); + + Map<String, Object> timeout = new HashMap<>(); + timeout.put("type", "String"); + timeout.put("value","5"); + + variableValueType.put("testAsyncRequestMsg", requestMsg); + variableValueType.put("mso-request-id", msorequestId); + variableValueType.put("mso-service-request-timeout", timeout); + + variableMap.put("variables", variableValueType); + WorkflowAsyncResource workflowAsyncResource = new WorkflowAsyncResource(); + workflowAsyncResource.setProcessor(new WorkflowProcessor()); + Response res = workflowAsyncResource.startProcessInstanceByKey("randomKey", variableMap); + assertEquals(500,res.getStatus()); + WorkflowResponse workflowResponse = (WorkflowResponse)res.getEntity(); + assertNotNull(workflowResponse); + assertEquals(500, workflowResponse.getMessageCode()); + assertTrue(workflowResponse.getResponse().startsWith("Error occurred while executing the process:")); + assertEquals("Fail", workflowResponse.getMessage()); + + + } + +} diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn index b91e2df8f7..0d2d829b6b 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="CreateNetworkBB" name="CreateNetworkBB" isExecutable="true"> <bpmn2:startEvent id="createNetwork_startEvent" name="Start Flow"> <bpmn2:outgoing>SequenceFlow_1maepy7</bpmn2:outgoing> @@ -31,11 +31,7 @@ <bpmn2:sequenceFlow id="SequenceFlow_1yy4aik" sourceRef="QueryNetworkPolicy_ServiceTask" targetRef="QueryNetworkTableRef_ServiceTask" /> <bpmn2:sequenceFlow id="SequenceFlow_0innva6" sourceRef="Create_Network_ServiceTask" targetRef="Update_Network_AAI_ServiceTask" /> <bpmn2:sequenceFlow id="SequenceFlow_0sissul" sourceRef="Update_Network_AAI_ServiceTask" targetRef="createNetwork_EndEvent" /> - <bpmn2:serviceTask id="QueryNetworkById_ServiceTask" name="Re-Query Network in AAI" camunda:expression="${AAIQueryTasks.getNetworkWrapperById(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn2:incoming>SequenceFlow_1maepy7</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_06rq9pi</bpmn2:outgoing> - </bpmn2:serviceTask> - <bpmn2:sequenceFlow id="SequenceFlow_1maepy7" sourceRef="createNetwork_startEvent" targetRef="QueryNetworkById_ServiceTask" /> + <bpmn2:sequenceFlow id="SequenceFlow_1maepy7" sourceRef="createNetwork_startEvent" targetRef="ServiceTask_get_cloud_region" /> <bpmn2:intermediateThrowEvent id="ThrowEvent_ToCollectAAIData" name="ThrowEvent_ToCollectAAIData"> <bpmn2:incoming>SequenceFlow_03ebe6c</bpmn2:incoming> <bpmn2:linkEventDefinition name="CatchEvent_Collect_AAI_Data" /> @@ -56,10 +52,9 @@ <bpmn2:sequenceFlow id="SequenceFlow_1oc7wcr" sourceRef="CatchEvent_Collect_AAI_Data" targetRef="QueryVpnBinding_ServiceTask" /> <bpmn2:sequenceFlow id="SequenceFlow_1eqfh23" sourceRef="CatchEvent_Create_Network" targetRef="Create_Network_ServiceTask" /> <bpmn2:serviceTask id="ServiceTask_get_cloud_region" name="Process cloud region by version " camunda:expression="${AssignNetworkBBUtils.getCloudRegion(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn2:incoming>SequenceFlow_06rq9pi</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_1maepy7</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_03ebe6c</bpmn2:outgoing> </bpmn2:serviceTask> - <bpmn2:sequenceFlow id="SequenceFlow_06rq9pi" sourceRef="QueryNetworkById_ServiceTask" targetRef="ServiceTask_get_cloud_region" /> <bpmn2:sequenceFlow id="SequenceFlow_03ebe6c" sourceRef="ServiceTask_get_cloud_region" targetRef="ThrowEvent_ToCollectAAIData" /> </bpmn2:process> <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> @@ -121,14 +116,11 @@ <dc:Bounds x="628" y="319" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_08q9eo4_di" bpmnElement="QueryNetworkById_ServiceTask"> - <dc:Bounds x="346" y="-77" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1maepy7_di" bpmnElement="SequenceFlow_1maepy7"> <di:waypoint xsi:type="dc:Point" x="272" y="-37" /> - <di:waypoint xsi:type="dc:Point" x="346" y="-37" /> + <di:waypoint xsi:type="dc:Point" x="426" y="-37" /> <bpmndi:BPMNLabel> - <dc:Bounds x="309" y="-52" width="0" height="0" /> + <dc:Bounds x="304" y="-52" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateThrowEvent_0fexg2g_di" bpmnElement="ThrowEvent_ToCollectAAIData"> @@ -177,20 +169,13 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_02qnccl_di" bpmnElement="ServiceTask_get_cloud_region"> - <dc:Bounds x="499" y="-77" width="100" height="80" /> + <dc:Bounds x="426" y="-77" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_06rq9pi_di" bpmnElement="SequenceFlow_06rq9pi"> - <di:waypoint xsi:type="dc:Point" x="446" y="-37" /> - <di:waypoint xsi:type="dc:Point" x="499" y="-37" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="473" y="-62" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_03ebe6c_di" bpmnElement="SequenceFlow_03ebe6c"> - <di:waypoint xsi:type="dc:Point" x="599" y="-37" /> + <di:waypoint xsi:type="dc:Point" x="526" y="-37" /> <di:waypoint xsi:type="dc:Point" x="666" y="-37" /> <bpmndi:BPMNLabel> - <dc:Bounds x="633" y="-52" width="0" height="0" /> + <dc:Bounds x="551" y="-52" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn index abc017c957..bd24eeaed7 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn @@ -29,7 +29,7 @@ <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> - <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> + <camunda:out source="heatStackId" target="heatStackId" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_16g4dz0</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ecr393</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn index a95dc9ce73..ffe74d1295 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn @@ -28,7 +28,7 @@ <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> - <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> + <camunda:out source="heatStackId" target="heatStackId" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0kfkpbh</bpmn:incoming> <bpmn:outgoing>SequenceFlow_06flg6h</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index 07d0b18938..832a96cae7 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -24,7 +24,7 @@ <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="deleteVfModuleRequest" target="deleteVfModuleRequest" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> - <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> + <camunda:out source="heatStackId" target="heatStackId" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_08tvhtf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_02lpx87</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetworkBB.bpmn index 208e41f174..fb250fc03f 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetworkBB.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0"> <bpmn:process id="UnassignNetworkBB" name="UnassignNetworkBB" isExecutable="true"> <bpmn:startEvent id="Start_UnassignNetworkBB" name="start"> <bpmn:outgoing>SequenceFlow_0zaz9o2</bpmn:outgoing> @@ -11,7 +11,7 @@ <bpmn:endEvent id="End_UnassignNetworkBB" name="end"> <bpmn:incoming>SequenceFlow_0csh9dc</bpmn:incoming> </bpmn:endEvent> - <bpmn:sequenceFlow id="SequenceFlow_0zaz9o2" sourceRef="Start_UnassignNetworkBB" targetRef="Task_GetL3NetworkById" /> + <bpmn:sequenceFlow id="SequenceFlow_0zaz9o2" sourceRef="Start_UnassignNetworkBB" targetRef="Task_VfModuleRelatioship" /> <bpmn:sequenceFlow id="SequenceFlow_1ks8kmt" sourceRef="Task_SNDCUnAssign" targetRef="Task_DeleteNetwork" /> <bpmn:sequenceFlow id="SequenceFlow_0csh9dc" sourceRef="Task_DeleteNetwork" targetRef="End_UnassignNetworkBB" /> <bpmn:serviceTask id="Task_DeleteNetwork" name="Delete Network (AAI)" camunda:expression="${AAIDeleteTasks.deleteNetwork(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> @@ -19,15 +19,10 @@ <bpmn:outgoing>SequenceFlow_0csh9dc</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="Task_VfModuleRelatioship" name="Veriyf 'vf-module' relationship exists" camunda:expression="${UnassignNetworkBB.checkRelationshipRelatedTo(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), "vf-module")}"> - <bpmn:incoming>SequenceFlow_1gd5h4c</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0zaz9o2</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0mxe1a7</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0mxe1a7" sourceRef="Task_VfModuleRelatioship" targetRef="Task_GetCloudRegionVersion" /> - <bpmn:sequenceFlow id="SequenceFlow_1gd5h4c" sourceRef="Task_GetL3NetworkById" targetRef="Task_VfModuleRelatioship" /> - <bpmn:serviceTask id="Task_GetL3NetworkById" name="Get L3Network by networkId (AAI)" camunda:expression="${AAIQueryTasks.getNetworkWrapperById(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0zaz9o2</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1gd5h4c</bpmn:outgoing> - </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0le4vrj" sourceRef="Task_GetCloudRegionVersion" targetRef="Task_SNDCUnAssign" /> <bpmn:serviceTask id="Task_GetCloudRegionVersion" name="Get Sdnc Cloud Region Version" camunda:expression="${UnassignNetworkBB.getCloudSdncRegion(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_0mxe1a7</bpmn:incoming> @@ -37,9 +32,9 @@ <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="UnassignNetworkBB"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start_UnassignNetworkBB"> - <dc:Bounds x="145" y="119" width="36" height="36" /> + <dc:Bounds x="269" y="119" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="152" y="155" width="22" height="12" /> + <dc:Bounds x="276" y="155" width="23" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0m0ikey_di" bpmnElement="Task_SNDCUnAssign"> @@ -52,10 +47,10 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0zaz9o2_di" bpmnElement="SequenceFlow_0zaz9o2"> - <di:waypoint xsi:type="dc:Point" x="181" y="137" /> - <di:waypoint xsi:type="dc:Point" x="232" y="137" /> + <di:waypoint xsi:type="dc:Point" x="305" y="137" /> + <di:waypoint xsi:type="dc:Point" x="375" y="137" /> <bpmndi:BPMNLabel> - <dc:Bounds x="207" y="122" width="0" height="0" /> + <dc:Bounds x="295" y="122" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1ks8kmt_di" bpmnElement="SequenceFlow_1ks8kmt"> @@ -85,16 +80,6 @@ <dc:Bounds x="500" y="122" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1gd5h4c_di" bpmnElement="SequenceFlow_1gd5h4c"> - <di:waypoint xsi:type="dc:Point" x="332" y="137" /> - <di:waypoint xsi:type="dc:Point" x="375" y="137" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="354" y="122" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_1scptd7_di" bpmnElement="Task_GetL3NetworkById"> - <dc:Bounds x="232" y="97" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0le4vrj_di" bpmnElement="SequenceFlow_0le4vrj"> <di:waypoint xsi:type="dc:Point" x="624" y="137" /> <di:waypoint xsi:type="dc:Point" x="665" y="137" /> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn index 9f431212b1..daf0358683 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="UpdateNetworkBB" name="UpdateNetworkBB" isExecutable="true"> <bpmn2:startEvent id="UpdateNetworkBB_Start" name="Start"> <bpmn2:outgoing>SequenceFlow_074w2et</bpmn2:outgoing> @@ -14,20 +14,15 @@ <bpmn2:linkEventDefinition name="SDNC_to_AAI" /> </bpmn2:intermediateThrowEvent> <bpmn2:sequenceFlow id="SequenceFlow_04yezm3" sourceRef="SDNCChangeAssignNetwork" targetRef="SDNC_End" /> - <bpmn2:serviceTask id="QueryNetworkAAI" name="Re-Query Network (AAI)" camunda:expression="${AAIQueryTasks.getNetworkWrapperById(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn2:incoming>SequenceFlow_1trqq6d</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_03janqs</bpmn2:outgoing> - </bpmn2:serviceTask> <bpmn2:intermediateCatchEvent id="AAI_Start" name="To AAI"> <bpmn2:outgoing>SequenceFlow_1trqq6d</bpmn2:outgoing> <bpmn2:linkEventDefinition name="SDNC_to_AAI" /> </bpmn2:intermediateCatchEvent> - <bpmn2:sequenceFlow id="SequenceFlow_1trqq6d" sourceRef="AAI_Start" targetRef="QueryNetworkAAI" /> + <bpmn2:sequenceFlow id="SequenceFlow_1trqq6d" sourceRef="AAI_Start" targetRef="QueryVpnBindingAAI" /> <bpmn2:serviceTask id="QueryVpnBindingAAI" name="Query Vpn Binding (AAI)" camunda:expression="${AAIQueryTasks.queryNetworkVpnBinding(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn2:incoming>SequenceFlow_03janqs</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_1trqq6d</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_1io4cl7</bpmn2:outgoing> </bpmn2:serviceTask> - <bpmn2:sequenceFlow id="SequenceFlow_03janqs" sourceRef="QueryNetworkAAI" targetRef="QueryVpnBindingAAI" /> <bpmn2:serviceTask id="QueryNetworkPolicyAAI" name="Query Network Policy (AAI)" camunda:expression="${AAIQueryTasks.queryNetworkPolicy(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn2:incoming>SequenceFlow_1io4cl7</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_16fm47t</bpmn2:outgoing> @@ -107,32 +102,22 @@ <dc:Bounds x="432.5" y="74" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_0d05e4a_di" bpmnElement="QueryNetworkAAI"> - <dc:Bounds x="104" y="193" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateCatchEvent_1hbb3j8_di" bpmnElement="AAI_Start"> - <dc:Bounds x="-1" y="215" width="36" height="36" /> + <dc:Bounds x="144" y="215" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="2" y="255" width="33" height="12" /> + <dc:Bounds x="147" y="255" width="33" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1trqq6d_di" bpmnElement="SequenceFlow_1trqq6d"> - <di:waypoint xsi:type="dc:Point" x="35" y="233" /> - <di:waypoint xsi:type="dc:Point" x="104" y="233" /> + <di:waypoint xsi:type="dc:Point" x="180" y="233" /> + <di:waypoint xsi:type="dc:Point" x="280" y="233" /> <bpmndi:BPMNLabel> - <dc:Bounds x="69.5" y="212" width="0" height="12" /> + <dc:Bounds x="185" y="212" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_09dctlw_di" bpmnElement="QueryVpnBindingAAI"> <dc:Bounds x="280" y="193" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_03janqs_di" bpmnElement="SequenceFlow_03janqs"> - <di:waypoint xsi:type="dc:Point" x="204" y="233" /> - <di:waypoint xsi:type="dc:Point" x="280" y="233" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="242" y="212" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1slp95d_di" bpmnElement="QueryNetworkPolicyAAI"> <dc:Bounds x="455" y="193" width="100" height="80" /> </bpmndi:BPMNShape> @@ -167,42 +152,42 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateCatchEvent_0sx0nb6_di" bpmnElement="AIC_Start"> - <dc:Bounds x="-1" y="332" width="36" height="36" /> + <dc:Bounds x="144" y="332" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1" y="372" width="34" height="12" /> + <dc:Bounds x="146" y="372" width="34" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_196cgux_di" bpmnElement="SequenceFlow_196cgux"> - <di:waypoint xsi:type="dc:Point" x="35" y="350" /> - <di:waypoint xsi:type="dc:Point" x="104" y="350" /> + <di:waypoint xsi:type="dc:Point" x="180" y="350" /> + <di:waypoint xsi:type="dc:Point" x="248" y="350" /> <bpmndi:BPMNLabel> - <dc:Bounds x="69.5" y="329" width="0" height="12" /> + <dc:Bounds x="169" y="329" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0i66n9g_di" bpmnElement="UpdateNetworkAdapter"> - <dc:Bounds x="104" y="310" width="100" height="80" /> + <dc:Bounds x="248" y="310" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0hsvgje_di" bpmnElement="SequenceFlow_0hsvgje"> - <di:waypoint xsi:type="dc:Point" x="204" y="350" /> - <di:waypoint xsi:type="dc:Point" x="278" y="350" /> + <di:waypoint xsi:type="dc:Point" x="348" y="350" /> + <di:waypoint xsi:type="dc:Point" x="422" y="350" /> <bpmndi:BPMNLabel> - <dc:Bounds x="241" y="329" width="0" height="12" /> + <dc:Bounds x="340" y="329" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1ydm5u9_di" bpmnElement="UpdateNetworkAAI"> - <dc:Bounds x="278" y="310" width="100" height="80" /> + <dc:Bounds x="422" y="310" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0fsts2w_di" bpmnElement="UpdateNetworkBB_End"> - <dc:Bounds x="493" y="332" width="36" height="36" /> + <dc:Bounds x="637" y="332" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="502" y="372" width="19" height="12" /> + <dc:Bounds x="646" y="372" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0fhfitm_di" bpmnElement="SequenceFlow_0fhfitm"> - <di:waypoint xsi:type="dc:Point" x="378" y="350" /> - <di:waypoint xsi:type="dc:Point" x="493" y="350" /> + <di:waypoint xsi:type="dc:Point" x="522" y="350" /> + <di:waypoint xsi:type="dc:Point" x="637" y="350" /> <bpmndi:BPMNLabel> - <dc:Bounds x="435.5" y="329" width="0" height="12" /> + <dc:Bounds x="535" y="329" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_11x1b8w_di" bpmnElement="SubProcess_1srp3f9" isExpanded="true"> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateNetworkBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateNetworkBBTest.java index cb3ab32884..13f8a6f812 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateNetworkBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateNetworkBBTest.java @@ -36,7 +36,7 @@ public class CreateNetworkBBTest extends BaseBPMNTest{ ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateNetworkBB",variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted().hasPassedInOrder("createNetwork_startEvent", "QueryNetworkById_ServiceTask", "ServiceTask_get_cloud_region", "QueryVpnBinding_ServiceTask", "QueryNetworkPolicy_ServiceTask", "QueryNetworkTableRef_ServiceTask", "Create_Network_ServiceTask", "Update_Network_AAI_ServiceTask", "createNetwork_EndEvent"); + assertThat(pi).isStarted().hasPassedInOrder("createNetwork_startEvent", "ServiceTask_get_cloud_region", "QueryVpnBinding_ServiceTask", "QueryNetworkPolicy_ServiceTask", "QueryNetworkTableRef_ServiceTask", "Create_Network_ServiceTask", "Update_Network_AAI_ServiceTask", "createNetwork_EndEvent"); assertThat(pi).isEnded(); } @@ -47,7 +47,7 @@ public class CreateNetworkBBTest extends BaseBPMNTest{ ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateNetworkBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("createNetwork_startEvent","QueryNetworkById_ServiceTask") + .hasPassedInOrder("createNetwork_startEvent") .hasNotPassed("End Flow"); assertThat(pi).isEnded(); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVolumeGroupBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVolumeGroupBBTest.java index eb372fb6a7..57388efc2e 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVolumeGroupBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVolumeGroupBBTest.java @@ -61,8 +61,6 @@ public class CreateVolumeGroupBBTest extends BaseBPMNTest{ .hasPassedInOrder("CreateVolumeGroupBB_Start", "QueryVfModuleSDNC", "CreateVolumeGroupVnfAdapter", "Vnf_Adapter") .hasNotPassed("UpdateVolumeGroupAAI", "CreateVolumeGroupBB_End"); assertThat(pi).isEnded(); - assertThat(pi).hasPassedInOrder("CreateVolumeGroupBB_Start", "QueryVfModuleSDNC", "CreateVolumeGroupVnfAdapter") - .hasNotPassed("Vnf_Adapter", "UpdateVolumeGroupAAI", "CreateVolumeGroupBB_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetworkBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetworkBBTest.java index fd95e00031..b6f7cbeb48 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetworkBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetworkBBTest.java @@ -36,7 +36,7 @@ public class UnassignNetworkBBTest extends BaseBPMNTest { public void sunnyDayAssignNetwork_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("UnassignNetworkBB",variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted().hasPassedInOrder("Start_UnassignNetworkBB","Task_GetL3NetworkById","Task_VfModuleRelatioship","Task_GetCloudRegionVersion","Task_SNDCUnAssign","Task_DeleteNetwork","End_UnassignNetworkBB"); + assertThat(pi).isStarted().hasPassedInOrder("Start_UnassignNetworkBB","Task_VfModuleRelatioship","Task_GetCloudRegionVersion","Task_SNDCUnAssign","Task_DeleteNetwork","End_UnassignNetworkBB"); assertThat(pi).isEnded(); } @@ -46,7 +46,7 @@ public class UnassignNetworkBBTest extends BaseBPMNTest { ProcessInstance pi = runtimeService.startProcessInstanceByKey("UnassignNetworkBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("Start_UnassignNetworkBB", "Task_GetL3NetworkById", "Task_VfModuleRelatioship") + .hasPassedInOrder("Start_UnassignNetworkBB", "Task_VfModuleRelatioship") .hasNotPassed("End_UnassignNetworkBB"); assertThat(pi).isEnded(); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UpdateNetworkBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UpdateNetworkBBTest.java index 853f713bd1..9fff0eb458 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UpdateNetworkBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UpdateNetworkBBTest.java @@ -38,7 +38,7 @@ public class UpdateNetworkBBTest extends BaseBPMNTest { assertThat(processInstance).isNotNull(); assertThat(processInstance).isStarted().hasPassedInOrder( "UpdateNetworkBB_Start", "SDNCChangeAssignNetwork", - "QueryNetworkAAI", "QueryVpnBindingAAI", "QueryNetworkPolicyAAI", "QueryNetworkTableRefAAI", + "QueryVpnBindingAAI", "QueryNetworkPolicyAAI", "QueryNetworkTableRefAAI", "UpdateNetworkAdapter", "UpdateNetworkAAI", "UpdateNetworkBB_End"); assertThat(processInstance).isEnded(); } @@ -49,8 +49,8 @@ public class UpdateNetworkBBTest extends BaseBPMNTest { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("UpdateNetworkBB", variables); assertThat(processInstance).isStarted().hasPassedInOrder( - "UpdateNetworkBB_Start", "SDNCChangeAssignNetwork", - "QueryNetworkAAI", "QueryVpnBindingAAI") + "UpdateNetworkBB_Start", "SDNCChangeAssignNetwork", + "QueryVpnBindingAAI") .hasNotPassed("QueryNetworkPolicyAAI", "QueryNetworkTableRefAAI", "UpdateNetworkAdapter", "UpdateNetworkAAI", "UpdateNetworkBB_End"); assertThat(processInstance).isEnded(); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index a376e581fe..731d9c24de 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -330,6 +330,10 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { if(!resourceClient.exists(uri)){ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai") + }else{ + Map<String, String> keys = uri.getURIKeys() + execution.setVariable("serviceType", keys.get("service-type")) + execution.setVariable("subscriberName", keys.get("global-customer-id")) } }catch(BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index 4f6fbf9966..d7f2087c05 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -328,6 +328,10 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { if(!resourceClient.exists(uri)){ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Service Instance not found in aai") + }else{ + Map<String, String> keys = uri.getURIKeys() + execution.setVariable("serviceType", keys.get("service-type")) + execution.setVariable("subscriberName", keys.get("global-customer-id")) } }catch(BpmnError e) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java index beffa25249..0079b351f2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java @@ -49,7 +49,6 @@ import org.springframework.stereotype.Component; public class AAIQueryTasks { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAIQueryTasks.class); - private static final String NETWORK_RESULT_WRAPPER_KEY = "l3NetworkAAIResultWrapper"; private static final String ERROR_MSG = "No relationships were returned from AAIResultWrapper.getRelationships()"; @Autowired private ExtractPojosForBB extractPojosForBB; @@ -58,23 +57,6 @@ public class AAIQueryTasks { @Autowired private AAINetworkResources aaiNetworkResources; private static final ModelMapper modelMapper = new ModelMapper(); - - /** - * BPMN access method to query L3Network object in AAI by it's Id - * - * @param execution - * @throws Exception - */ - public void getNetworkWrapperById(BuildingBlockExecution execution) { - try { - L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, - execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); - execution.setVariable(NETWORK_RESULT_WRAPPER_KEY, aaiResultWrapper); - } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } - } /** * BPMN access method to query data for VPN bindings from the AAI result wrapper. @@ -85,9 +67,9 @@ public class AAIQueryTasks { public void queryNetworkVpnBinding(BuildingBlockExecution execution) { try { - org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - - AAIResultWrapper aaiResultWrapper = execution.getVariable(NETWORK_RESULT_WRAPPER_KEY); + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, + execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships(); if (!networkRelationships.isPresent()) { throw (new Exception(ERROR_MSG)); @@ -120,7 +102,9 @@ public class AAIQueryTasks { public void getNetworkVpnBinding(BuildingBlockExecution execution) { try { - AAIResultWrapper aaiResultWrapper = execution.getVariable(NETWORK_RESULT_WRAPPER_KEY); + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, + execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); CreateNetworkRequest createNetworkRequest = execution.getVariable("createNetworkRequest"); Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships(); @@ -174,9 +158,9 @@ public class AAIQueryTasks { */ public void queryNetworkPolicy(BuildingBlockExecution execution) { try { - L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - - AAIResultWrapper aaiResultWrapper = execution.getVariable(NETWORK_RESULT_WRAPPER_KEY); + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, + execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships(); if (!networkRelationships.isPresent()) { throw (new Exception(ERROR_MSG)); @@ -187,7 +171,7 @@ public class AAIQueryTasks { for(AAIResourceUri netPolicyUri : netPoliciesUriList) { Optional<NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri); if(oNetPolicy.isPresent()) { - l3Network.getNetworkPolicies().add(modelMapper.map(oNetPolicy.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy.class)); + l3network.getNetworkPolicies().add(modelMapper.map(oNetPolicy.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy.class)); } } } @@ -205,9 +189,9 @@ public class AAIQueryTasks { */ public void queryNetworkTableRef(BuildingBlockExecution execution) { try { - L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - - AAIResultWrapper aaiResultWrapper = execution.getVariable(NETWORK_RESULT_WRAPPER_KEY); + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, + execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships(); if (!networkRelationships.isPresent()) { throw (new Exception(ERROR_MSG)); @@ -219,7 +203,7 @@ public class AAIQueryTasks { Optional<RouteTableReference> oRouteTableReference = aaiNetworkResources.getRouteTable(routeTableUri); if(oRouteTableReference.isPresent()) { org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference mappedRouteTableReference = modelMapper.map(oRouteTableReference.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference.class); - l3Network.getContrailNetworkRouteTableReferences().add(mappedRouteTableReference); + l3network.getContrailNetworkRouteTableReferences().add(mappedRouteTableReference); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 9c1fba62e9..b059a77641 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -144,9 +144,11 @@ public class AAIUpdateTasks { public void updateHeatStackIdVolumeGroup(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + String heatStackId = execution.getVariable("heatStackId"); VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); CloudRegion cloudRegion = gBBInput.getCloudRegion(); + volumeGroup.setHeatStackId(heatStackId); aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); } catch (Exception ex) { @@ -296,8 +298,10 @@ public class AAIUpdateTasks { public void updateHeatStackIdVfModule(BuildingBlockExecution execution) { try { + String heatStackId = execution.getVariable("heatStackId"); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + vfModule.setHeatStackId(heatStackId); aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java index 0b712452fd..554af37924 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java @@ -65,6 +65,7 @@ public class VnfAdapterImpl { execution.setVariable("isDebugLogEnabled", "true"); execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId()); execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId()); + execution.setVariable("heatStackId", null); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -80,23 +81,25 @@ public class VnfAdapterImpl { String heatStackId = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleStackId(); if(!StringUtils.isEmpty(heatStackId)) { vfModule.setHeatStackId(heatStackId); + execution.setVariable("heatStackId", heatStackId); } } else if(vnfRestResponse instanceof DeleteVfModuleResponse) { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); Boolean vfModuleDelete = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleDeleted(); if(null!= vfModuleDelete && vfModuleDelete) { vfModule.setHeatStackId(null); + execution.setVariable("heatStackId", null); } } else if(vnfRestResponse instanceof CreateVolumeGroupResponse) { VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); String heatStackId = ((CreateVolumeGroupResponse) vnfRestResponse).getVolumeGroupStackId(); if(!StringUtils.isEmpty(heatStackId)) { volumeGroup.setHeatStackId(heatStackId); + execution.setVariable("heatStackId", heatStackId); }else{ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "HeatStackId is missing from create VolumeGroup Vnf Adapter response."); } - } - execution.setVariable("generalBuildingBlock", execution.getGeneralBuildingBlock()); + } } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); 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 c6a63e1431..0fa0c69118 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 @@ -88,6 +88,7 @@ public class WorkflowAction { private static final String VOLUMEGROUP = "VolumeGroup"; private static final String NETWORK = "Network"; private static final String NETWORKCOLLECTION = "NetworkCollection"; + private static final String CONFIGURATION = "Configuration"; private static final String ASSIGNINSTANCE = "assignInstance"; private static final String CREATEINSTANCE = "createInstance"; private static final String USERPARAMSERVICE = "service"; @@ -136,6 +137,7 @@ public class WorkflowAction { RequestDetails requestDetails = sIRequest.getRequestDetails(); Resource resource = extractResourceIdAndTypeFromUri(uri); WorkflowType resourceType = resource.getResourceType(); + execution.setVariable("resourceName", resourceType.toString()); String resourceId = ""; if (resource.isGenerated()) { resourceId = validateResourceIdInAAI(resource.getResourceId(), resourceType, @@ -240,7 +242,7 @@ public class WorkflowAction { } if (resourceType == WorkflowType.SERVICE && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)) - && !resourceCounter.stream().filter(x -> VNF.equals(x.getResourceType())).collect(Collectors.toList()).isEmpty()) { + && !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType())).collect(Collectors.toList()).isEmpty()) { execution.setVariable("homing", true); execution.setVariable("calledHoming", false); } @@ -802,6 +804,12 @@ public class WorkflowAction { .collect(Collectors.toList()).get(i).getResourceId(), apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); } + } else if (orchFlow.getFlowName().contains(CONFIGURATION)) { + for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.CONFIGURATION == x.getResourceType()).collect(Collectors.toList()).size(); i++) { + flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resourceCounter.stream().filter(x -> WorkflowType.CONFIGURATION == x.getResourceType()) + .collect(Collectors.toList()).get(i).getResourceId(), apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); + } } else { flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, "", apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index 94dfdcc747..8661c8e91e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -96,6 +96,7 @@ public class AAIObjectMapper { map().setModelInvariantId(source.getModelInfoVfModule().getModelInvariantUUID()); map().setModelVersionId(source.getModelInfoVfModule().getModelUUID()); map().setPersonaModelVersion(source.getModelInfoVfModule().getModelInvariantUUID()); + map().setIsBaseVfModule(source.getModelInfoVfModule().getIsBaseBoolean()); } }); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index c9433a6212..b45752957e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -204,11 +204,13 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ @Test public void updateHeatStackIdVfModuleTest() throws Exception { + execution.setVariable("heatStackId", "newHeatStackId"); doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf); aaiUpdateTasks.updateHeatStackIdVfModule(execution); verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf); + assertEquals("newHeatStackId", vfModule.getHeatStackId()); } @Test @@ -270,11 +272,13 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ } @Test public void updateHeatStackIdVolumeGroupTest() throws Exception { + execution.setVariable("heatStackId", "newHeatStackId"); doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution); verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); + assertEquals("newHeatStackId", volumeGroup.getHeatStackId()); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 283f8881c7..3869988c40 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -427,14 +427,20 @@ public class WorkflowActionTest extends BaseTaskTest { orch12.setFlowName("ActivateVfModuleBB"); orchFlows.add(orch12); OrchestrationFlow orch13 = new OrchestrationFlow(); - orch13.setFlowName("ActivateVnfBB"); + orch13.setFlowName("AssignFabricConfigurationBB"); orchFlows.add(orch13); OrchestrationFlow orch14 = new OrchestrationFlow(); - orch14.setFlowName("ActivateNetworkCollectionBB"); + orch14.setFlowName("ActivateFabricConfigurationBB"); orchFlows.add(orch14); OrchestrationFlow orch15 = new OrchestrationFlow(); - orch15.setFlowName("ActivateServiceInstanceBB"); + orch15.setFlowName("ActivateVnfBB"); orchFlows.add(orch15); + OrchestrationFlow orch16 = new OrchestrationFlow(); + orch16.setFlowName("ActivateNetworkCollectionBB"); + orchFlows.add(orch16); + OrchestrationFlow orch17 = new OrchestrationFlow(); + orch17.setFlowName("ActivateServiceInstanceBB"); + orchFlows.add(orch17); Service service = new Service(); doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a"); @@ -772,7 +778,7 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals(UUID.randomUUID().toString().length(),ebbs.get(14).getWorkflowResourceIds().getVnfId().length()); assertEquals(ebbs.get(15).getBuildingBlock().getBpmnFlowName(),"ActivateServiceInstanceBB"); assertEquals(3,ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length()); - + assertEquals(true, execution.getVariable("homing")); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java index 6edda44c0a..c3b0048e07 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java @@ -245,6 +245,32 @@ public class AAIObjectMapperTest{ assertThat(reqMapper1, sameBeanAs(AAIVfModule)); } + + @Test + public void vfModuleBaseMap() throws Exception { + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("a"); + vfModule.setVfModuleName("b"); + vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelCustomizationUUID("f"); + modelInfoVfModule.setModelInvariantUUID("g"); + modelInfoVfModule.setModelUUID("h"); + modelInfoVfModule.setIsBaseBoolean(true); + vfModule.setModelInfoVfModule(modelInfoVfModule); + + org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule); + + String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleBaseMap.json"))); + + ObjectMapper omapper = new ObjectMapper(); + org.onap.aai.domain.yang.VfModule reqMapper1 = omapper.readValue( + jsonToCompare, + org.onap.aai.domain.yang.VfModule.class); + + assertThat(reqMapper1, sameBeanAs(AAIVfModule)); + + } @Test public void testMapInstanceGroup() { diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiVfModuleBaseMap.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiVfModuleBaseMap.json new file mode 100644 index 0000000000..9637e00fe1 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiVfModuleBaseMap.json @@ -0,0 +1,12 @@ +{ + + "modelCustomizationId" : "f", + "vfModuleId" : "a", + "vfModuleName" : "b", + "modelInvariantId" : "g", + "modelVersionId" : "h", + "orchestrationStatus" : "Assigned", + "personaModelVersion" : "g", + "isBaseVfModule" : true + +}
\ No newline at end of file |