diff options
Diffstat (limited to 'bpmn')
34 files changed, 614 insertions, 186 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy index bb557a8285..a43a2b1f89 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -131,7 +131,7 @@ class AllottedResourceUtils { String[] split = arLink.split("/service-instance/") String[] splitB = split[1].split("/allotted-resources/") String siId = splitB[0] - msoLogger.trace(" Exit getARLinkbyId - parentServiceInstanceId:" + siId ) + msoLogger.trace(" Exit getPSIFmARLink - parentServiceInstanceId:" + siId ) return siId } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy index 2e937ed134..ee93f3a445 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy @@ -18,13 +18,11 @@ * ============LICENSE_END========================================================= */ package org.onap.so.bpmn.common.scripts + import org.onap.so.bpmn.core.UrnPropertiesReader import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.common.scripts.AaiUtil -import org.onap.so.bpmn.common.scripts.ExceptionUtil - import org.onap.so.bpmn.core.domain.InventoryType import org.onap.so.bpmn.core.domain.Resource import org.onap.so.bpmn.core.domain.ResourceType @@ -246,7 +244,7 @@ class OofHoming extends AbstractServiceTaskProcessor { resource.getHomingSolution().setCloudOwner(cloudOwner) resource.getHomingSolution().setCloudRegionId(cloudRegionId) - CloudSite cloudSite = new CloudSite(); + CloudSite cloudSite = new CloudSite() cloudSite.setId(cloudRegionId) cloudSite.setRegionId(cloudRegionId) String orchestrator = execution.getVariable("orchestrator") @@ -254,10 +252,18 @@ class OofHoming extends AbstractServiceTaskProcessor { cloudSite.setOrchestrator(orchestrator) } - CloudIdentity cloudIdentity = new CloudIdentity(); - cloudIdentity.setId(cloudRegionId); - cloudIdentity.setIdentityUrl("/api/multicloud /v1/" + cloudOwner + "/" + cloudRegionId + "/infra_workload") - cloudSite.setIdentityService(cloudIdentity); + CloudIdentity cloudIdentity = new CloudIdentity() + cloudIdentity.setId(cloudRegionId) + // Get MSB Url + String msbHost = oofUtils.getMsbHost(execution) + String multicloudApiEndpoint = UrnPropertiesReader + .getVariable("mso.multicloud.api.endpoint", execution, + "/api/multicloud-titaniumcloud/v1") + cloudIdentity.setIdentityUrl(msbHost + multicloudApiEndpoint + + "/" + cloudOwner + "/" + + cloudRegionId + "/infra_workload") + + cloudSite.setIdentityService(cloudIdentity) // Set cloudsite in catalog DB here oofUtils.createCloudSiteCatalogDb(cloudSite) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index b9bc1c7c00..46ecc7bbe6 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -158,6 +158,8 @@ class OofUtils { utils.log("DEBUG", "Allotted Resource: " + resource.toString(), isDebugEnabled) def serviceResourceId = resource.getResourceId() + def toscaNodeType = resource.getToscaNodeType() + def resourceModuleName = toscaNodeType.substring(toscaNodeType.lastIndexOf(".") + 1) def resourceModelInvariantId = resource.getModelInfo().getModelInvariantUuid() def resourceModelVersionId = resource.getModelInfo().getModelUuid() def resourceModelName = resource.getModelInfo().getModelName() @@ -173,7 +175,7 @@ class OofUtils { String demand = " {\n" + - " \"resourceModuleName\": \"${resourceModelName}\",\n" + + " \"resourceModuleName\": \"${resourceModuleName}\",\n" + " \"serviceResourceId\": \"${serviceResourceId}\",\n" + " \"tenantId\": \"${tenantId}\",\n" + " \"resourceModelInfo\": {\n" + @@ -199,6 +201,8 @@ class OofUtils { utils.log("DEBUG", "VNF Resource: " + vnfResource.toString(), isDebugEnabled) ModelInfo vnfResourceModelInfo = vnfResource.getModelInfo() + def toscaNodeType = vnfResource.getToscaNodeType() + def resourceModuleName = toscaNodeType.substring(toscaNodeType.lastIndexOf(".") + 1) def serviceResourceId = vnfResource.getResourceId() def resourceModelInvariantId = vnfResourceModelInfo.getModelInvariantUuid() def resourceModelName = vnfResourceModelInfo.getModelName() @@ -211,7 +215,7 @@ class OofUtils { String placementDemand = " {\n" + - " \"resourceModuleName\": \"${resourceModelName}\",\n" + + " \"resourceModuleName\": \"${resourceModuleName}\",\n" + " \"serviceResourceId\": \"${serviceResourceId}\",\n" + " \"tenantId\": \"${tenantId}\",\n" + " \"resourceModelInfo\": {\n" + @@ -519,4 +523,12 @@ class OofUtils { exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from CatalogDB.") } } + + String getMsbHost(DelegateExecution execution) { + msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap") + + Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger() + + return UriBuilder.fromPath("").host(msbHost).port(msbPort).scheme("http").build().toString() + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 0f52c96d0e..1e77c35ee3 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -337,6 +337,9 @@ public class BBInputSetupMapperLayer { context.setRequestParameters(this.mapRequestParameters(requestDetails.getRequestParameters())); context.setUserParams(this.mapNameValueUserParams(requestDetails.getRequestParameters())); } + if (requestDetails.getConfigurationParameters() != null) { + context.setConfigurationParameters(requestDetails.getConfigurationParameters()); + } return context; } diff --git a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml deleted file mode 100644 index 33c8cb1ac0..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- - ============LICENSE_START======================================================= - ONAP SO - ================================================================================ - 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========================================================= - --> - -<process-application - xmlns="http://www.camunda.org/schema/1.0/ProcessApplication" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - <process-archive name="MSOCommonBPMN"> - <properties> - <property name="isDeleteUponUndeploy">false</property> - <property name="isScanForProcessDefinitions">true</property> - </properties> - </process-archive> - -</process-application> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json index 926bf2ccb7..5eb9a26901 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json @@ -27,7 +27,13 @@ "skip": "ignore" } ] - } + }, + "configurationParameters": [ + { + "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", + "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" + } + ] }, "orchContext": { "is-rollback-enabled": false diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestContextExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestContextExpected.json index dfc6d4f555..906903e0b2 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestContextExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestContextExpected.json @@ -25,6 +25,11 @@ "skip": "ignore" } ] - } - + }, + "configurationParameters": [ + { + "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", + "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" + } + ] } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContext.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContext.json index 7386828d27..9afbdd9150 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContext.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqContext.json @@ -23,6 +23,12 @@ } ] - } + }, + "configurationParameters": [ + { + "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", + "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" + } + ] } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java index 968c8c1590..750cd241e8 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java @@ -69,6 +69,10 @@ public class UrnPropertiesReader { return variableValue; } + public static String getVariable(String variableName, DelegateExecution execution, String defaultValue) { + return Optional.ofNullable(getVariable(variableName, execution)).orElse(defaultValue); + } + /** * Return the URN property value from the environment object * @param variableName URN property name diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn index 0991ab5c36..cf284e8ed9 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn @@ -28,9 +28,11 @@ </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1jwsja5" sourceRef="Task_CreateVnf" targetRef="Task_createPlatform" /> <bpmn:sequenceFlow id="SequenceFlow_1nle8kc" sourceRef="Task_createInstanceGroups" targetRef="ExclusiveGateway_02tchpp" /> - <bpmn:sequenceFlow id="SequenceFlow_11jum90" name="no" sourceRef="ExclusiveGateway_02tchpp" targetRef="ExclusiveGateway_1blf52g" /> + <bpmn:sequenceFlow id="SequenceFlow_11jum90" name="no" sourceRef="ExclusiveGateway_02tchpp" targetRef="ExclusiveGateway_1blf52g"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("callHoming") == false}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1uiok7v" name="yes" sourceRef="ExclusiveGateway_02tchpp" targetRef="Task_callHoming"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("callHoming")}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("callHoming") == true}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_0v8d14a" sourceRef="Task_callHoming" targetRef="ExclusiveGateway_1blf52g" /> <bpmn:callActivity id="Task_callHoming" name="Call Homing" calledElement="HomingBB"> @@ -64,7 +66,7 @@ <bpmn:sequenceFlow id="SequenceFlow_1i52a7x" sourceRef="StartEvent_1c3cyuv" targetRef="EndEvent_1bywujf" /> </bpmn:subProcess> <bpmn:sequenceFlow id="SequenceFlow_14mpqit" sourceRef="ExclusiveGateway_1blf52g" targetRef="Task_SDNCAdapterVnfTopologyAssign" /> - <bpmn:inclusiveGateway id="ExclusiveGateway_02tchpp" name="Call Homing?" default="SequenceFlow_11jum90"> + <bpmn:inclusiveGateway id="ExclusiveGateway_02tchpp" name="Call Homing?"> <bpmn:incoming>SequenceFlow_1nle8kc</bpmn:incoming> <bpmn:outgoing>SequenceFlow_11jum90</bpmn:outgoing> <bpmn:outgoing>SequenceFlow_1uiok7v</bpmn:outgoing> @@ -217,7 +219,7 @@ <bpmndi:BPMNShape id="InclusiveGateway_0x0c3kk_di" bpmnElement="ExclusiveGateway_02tchpp"> <dc:Bounds x="679" y="109" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="732" y="128" width="64" height="12" /> + <dc:Bounds x="731" y="128" width="67" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="InclusiveGateway_0ijggth_di" bpmnElement="ExclusiveGateway_1blf52g"> 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 d4330290ea..2c134a9f59 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 @@ -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.4.0"> <bpmn:process id="WorkflowActionBB" name="WorkflowActionBB" isExecutable="true"> <bpmn:startEvent id="Start_WorkflowActionBB" name="start"> <bpmn:outgoing>SequenceFlow_15s0okp</bpmn:outgoing> @@ -18,6 +18,8 @@ <camunda:in source="retryCount" target="retryCount" /> <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" /> <camunda:in source="aLaCarte" target="aLaCarte" /> + <camunda:in source="orchestrationStatusValidationResult" target="orchestrationStatusValidationResult" /> + <camunda:out source="orchestrationStatusValidationResult" target="orchestrationStatusValidationResult" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0mew9im</bpmn:incoming> <bpmn:outgoing>SequenceFlow_07h9d4y</bpmn:outgoing> @@ -563,4 +565,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions>
\ No newline at end of file +</bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java index 03d0875212..3fb8faa6c8 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java @@ -35,6 +35,7 @@ public class AssignVnfBBTest extends BaseBPMNTest { @Test public void sunnyDayAssignVnfBBTest() throws InterruptedException, IOException { variables.put("callHoming", true); + mockSubprocess("ReceiveWorkflowMessage", "Mocked ReceiveWorkflowMessage", "GenericStub"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("AssignVnfBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted().hasPassedInOrder("Start_AssignVnfBB", "Task_CreateVnf", "Task_createPlatform", "Task_createLineOfBusiness", "Task_createInstanceGroups", diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/BuildingBlockValidatorRunnerTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/BuildingBlockValidatorRunnerTest.java new file mode 100644 index 0000000000..a241ae5eff --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/BuildingBlockValidatorRunnerTest.java @@ -0,0 +1,42 @@ +/*- + * ============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.infrastructure.bpmn.subprocess; + +import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.job; +import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.execute; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Test; +import org.onap.so.bpmn.BaseBPMNTest; + +public class BuildingBlockValidatorRunnerTest extends BaseBPMNTest{ + @Test + public void sunnyDayActivateNetwork_Test() throws InterruptedException { + variables.put("flowToBeCalled","CreateVolumeGroupBB"); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("BuildingBlockValidatorRunnerTest", variables); + assertThat(pi).isNotNull(); + + execute(job()); + execute(job()); + assertThat(pi).isStarted().hasPassedInOrder("ServiceTask_1","ServiceTask_2","ServiceTask_3"); + 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 a32f539475..34a17cbb89 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 @@ -53,6 +53,7 @@ public class CreateVolumeGroupBBTest extends BaseBPMNTest{ @Test public void rainyDayCreateVolumeGroupUpdateHeatStackIdError_Test() throws Exception { + mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub"); doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateHeatStackIdVolumeGroup(any(BuildingBlockExecution.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVolumeGroupBB", variables); assertThat(pi).isNotNull(); diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVolumeGroupBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVolumeGroupBBTest.java index 576c009e4a..cd6c266ba4 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVolumeGroupBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVolumeGroupBBTest.java @@ -32,6 +32,7 @@ import org.onap.so.bpmn.common.BuildingBlockExecution; public class DeleteVolumeGroupBBTest extends BaseBPMNTest { @Test public void sunnyDayDeleteVolumeGroup_Test() throws InterruptedException { + mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVolumeGroupBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted().hasPassedInOrder("DeleteVolumeGroupBB_Start", "DeleteVolumeGroupVnfAdapter", "VnfAdapter", "UpdateVolumeGroupAAI", "DeleteVolumeGroupBB_End"); @@ -40,6 +41,7 @@ public class DeleteVolumeGroupBBTest extends BaseBPMNTest { @Test public void rainyDayDeleteVolumeGroup_Test() throws Exception { + mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub"); doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateOrchestrationStatusAssignedVolumeGroup(any(BuildingBlockExecution.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVolumeGroupBB", variables); assertThat(pi).isNotNull(); diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java index 0dde361b7e..5162b83f4a 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/HomingBBTest.java @@ -51,7 +51,7 @@ public class HomingBBTest extends BaseBPMNTest{ ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("start", "sniroOofCheck", "startBpmnError", "bpmnErrorSubprocess", "processMsoWorkflowException", "endBpmnError") + .hasPassedInOrder("start", "sniroOofCheck", "startBpmnError", "processMsoWorkflowException", "endBpmnError") .hasNotPassed("callReceiveAsync"); assertThat(pi).isEnded(); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/META-INF/processes.xml b/bpmn/so-bpmn-building-blocks/src/test/resources/META-INF/processes.xml new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/META-INF/processes.xml diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/subprocess/BuildingBlock/BuildingBlockValidatorRunnerTest.bpmn b/bpmn/so-bpmn-building-blocks/src/test/resources/subprocess/BuildingBlock/BuildingBlockValidatorRunnerTest.bpmn new file mode 100644 index 0000000000..446dfe3104 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/subprocess/BuildingBlock/BuildingBlockValidatorRunnerTest.bpmn @@ -0,0 +1,122 @@ +<?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:process id="BuildingBlockValidatorRunnerTest" name="BuildingBlockValidatorRunnerTest" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>SequenceFlow_0vof4nz</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="ServiceTask_1" name="PreValidate" camunda:expression="${BuildingBlockValidatorRunner.preValidate(flowToBeCalled, InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0vof4nz</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_14nr57b</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="ServiceTask_2" name="PreValidate" camunda:expression="${BuildingBlockValidatorRunner.preValidate(flowToBeCalled, InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1vsqhv8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_04xg7yh</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0vof4nz" sourceRef="StartEvent_1" targetRef="ServiceTask_1" /> + <bpmn:endEvent id="EndEvent_1wyjfsw"> + <bpmn:incoming>SequenceFlow_06wt67a</bpmn:incoming> + </bpmn:endEvent> + <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_1" name="RetryTimer"> + <bpmn:incoming>SequenceFlow_14nr57b</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1vsqhv8</bpmn:outgoing> + <bpmn:timerEventDefinition> + <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT10S</bpmn:timeDuration> + </bpmn:timerEventDefinition> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="SequenceFlow_14nr57b" sourceRef="ServiceTask_1" targetRef="IntermediateCatchEvent_1" /> + <bpmn:sequenceFlow id="SequenceFlow_1vsqhv8" sourceRef="IntermediateCatchEvent_1" targetRef="ServiceTask_2" /> + <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_2" name="RetryTimer"> + <bpmn:incoming>SequenceFlow_04xg7yh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0w8ajcb</bpmn:outgoing> + <bpmn:timerEventDefinition> + <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT10S</bpmn:timeDuration> + </bpmn:timerEventDefinition> + </bpmn:intermediateCatchEvent> + <bpmn:serviceTask id="ServiceTask_3" name="PreValidate" camunda:expression="${BuildingBlockValidatorRunner.preValidate(flowToBeCalled, InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0w8ajcb</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_06wt67a</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_04xg7yh" sourceRef="ServiceTask_2" targetRef="IntermediateCatchEvent_2" /> + <bpmn:sequenceFlow id="SequenceFlow_0w8ajcb" sourceRef="IntermediateCatchEvent_2" targetRef="ServiceTask_3" /> + <bpmn:sequenceFlow id="SequenceFlow_06wt67a" sourceRef="ServiceTask_3" targetRef="EndEvent_1wyjfsw" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="BuildingBlockValidatorRunnerTest"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="320" y="131" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="293" y="167" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0k9j83h_di" bpmnElement="ServiceTask_1"> + <dc:Bounds x="435" y="109" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_06izmow_di" bpmnElement="ServiceTask_2"> + <dc:Bounds x="685" y="109" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0vof4nz_di" bpmnElement="SequenceFlow_0vof4nz"> + <di:waypoint xsi:type="dc:Point" x="356" y="149" /> + <di:waypoint xsi:type="dc:Point" x="435" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="395.5" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_1wyjfsw_di" bpmnElement="EndEvent_1wyjfsw"> + <dc:Bounds x="1106" y="131" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1079" y="171" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_1xxf97p_di" bpmnElement="IntermediateCatchEvent_1"> + <dc:Bounds x="596" y="131" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="587" y="106" width="55" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_14nr57b_di" bpmnElement="SequenceFlow_14nr57b"> + <di:waypoint xsi:type="dc:Point" x="535" y="149" /> + <di:waypoint xsi:type="dc:Point" x="596" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="565.5" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1vsqhv8_di" bpmnElement="SequenceFlow_1vsqhv8"> + <di:waypoint xsi:type="dc:Point" x="632" y="149" /> + <di:waypoint xsi:type="dc:Point" x="685" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="658.5" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateCatchEvent_1hx48zh_di" bpmnElement="IntermediateCatchEvent_2"> + <dc:Bounds x="853" y="131" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="844" y="106" width="55" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_059dhj6_di" bpmnElement="ServiceTask_3"> + <dc:Bounds x="943" y="109" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_04xg7yh_di" bpmnElement="SequenceFlow_04xg7yh"> + <di:waypoint xsi:type="dc:Point" x="785" y="149" /> + <di:waypoint xsi:type="dc:Point" x="853" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="819" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0w8ajcb_di" bpmnElement="SequenceFlow_0w8ajcb"> + <di:waypoint xsi:type="dc:Point" x="889" y="149" /> + <di:waypoint xsi:type="dc:Point" x="943" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="916" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_06wt67a_di" bpmnElement="SequenceFlow_06wt67a"> + <di:waypoint xsi:type="dc:Point" x="1043" y="149" /> + <di:waypoint xsi:type="dc:Point" x="1106" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1074.5" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java index 90b48ab2c1..159298b4ad 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2018 Nokia. + * ================================================================================ * 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 @@ -31,41 +33,32 @@ import java.util.Spliterator; public final class JsonUtilForCorrelationId { - private static final String JSON_HEADER = "pnfRegistrationFields"; private static final String JSON_CORRELATION_ID_FIELD_NAME = "correlationId"; static List<String> parseJsonToGelAllCorrelationId(String json) { - List<String> list = new ArrayList<>(); JsonElement je = new JsonParser().parse(json); - if (je.isJsonObject()) { - getCorrelationIdFromJsonObject(je.getAsJsonObject()).ifPresent(corr -> list.add(corr)); - } else { - JsonArray array = je.getAsJsonArray(); - Spliterator<JsonElement> spliterator = array.spliterator(); - spliterator.forEachRemaining(jsonElement -> { - parseJsonElementToJsonObject(jsonElement) - .ifPresent(jsonObject -> getCorrelationIdFromJsonObject(jsonObject) - .ifPresent(correlationId -> list.add(correlationId))); - }); - } + JsonArray array = je.getAsJsonArray(); + List<String> list = new ArrayList<>(); + Spliterator<JsonElement> spliterator = array.spliterator(); + spliterator.forEachRemaining(jsonElement -> { + handleEscapedCharacters(jsonElement) + .ifPresent(jsonObject -> getCorrelationId(jsonObject) + .ifPresent(correlationId -> list.add(correlationId))); + }); return list; } - private static Optional<JsonObject> parseJsonElementToJsonObject(JsonElement jsonElement) { + private static Optional<JsonObject> handleEscapedCharacters(JsonElement jsonElement) { if (jsonElement.isJsonObject()) { return Optional.ofNullable(jsonElement.getAsJsonObject()); } return Optional.ofNullable(new JsonParser().parse(jsonElement.getAsString()).getAsJsonObject()); } - private static Optional<String> getCorrelationIdFromJsonObject(JsonObject jsonObject) { - if (jsonObject.has(JSON_HEADER)) { - JsonObject jo = jsonObject.getAsJsonObject(JSON_HEADER); - if (jo.has(JSON_CORRELATION_ID_FIELD_NAME)) { - return Optional.ofNullable(jo.get(JSON_CORRELATION_ID_FIELD_NAME).getAsString()); - } + private static Optional<String> getCorrelationId(JsonObject jsonObject) { + if (jsonObject.has(JSON_CORRELATION_ID_FIELD_NAME)) { + return Optional.ofNullable(jsonObject.get(JSON_CORRELATION_ID_FIELD_NAME).getAsString()); } return Optional.empty(); } - } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java index 518d7ff194..373e84bb9d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2018 Nokia. + * ================================================================================ * 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 diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java index 24d1810ac6..fde112b009 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2018 Nokia. + * ================================================================================ * 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 @@ -24,30 +26,18 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.junit.Test; -import org.onap.so.bpmn.infrastructure.pnf.dmaap.JsonUtilForCorrelationId; public class JsonUtilForCorrelationIdTest { - private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[\n" - + " {\n" - + " \"pnfRegistrationFields\" : {\n" - + " \"correlationId\" : \"corrTest1\",\n" - + " \"value\" : \"value1\"\n" - + " }\n" - + " },\n" - + " {\n" - + " \"pnfRegistrationFields\" : {\n" - + " \"correlationId\" : \"corrTest2\",\n" - + " \"value\" : \"value2\"\n" - + " }\n" - + " }\n" - + "]"; + private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[{\"correlationId\": \"corrTest1\"," + + "\"key1\":\"value1\"},{\"correlationId\": \"corrTest2\",\"key2\":\"value2\"}]"; + + private static final String JSON_WITH_ONE_CORRELATION_ID = "[{\"correlationId\":\"corrTest3\"}]"; + + private static final String JSON_WITH_TWO_CORRELATION_ID_AND_ESCAPED_CHARACTERS = + "[\"{\\\"correlationId\\\":\\\"corrTest4\\\"}\", \"{\\\"correlationId\\\":\\\"corrTest5\\\"}\"]"; - private static final String JSON_EXAMPLE_WITH_CORRELATION_ID2 = "{\"pnfRegistrationFields\":{\"correlationId\":\"corrTest3\"}}"; - private static final String JSON_EXAMPLE_WITH_CORRELATION_ID3 = "[\"{\\\"pnfRegistrationFields\\\":" - + "{\\\"correlationId\\\":\\\"corrTest4\\\"}}\", \"{\\\"pnfRegistrationFields\\\":" - + "{\\\"correlationId\\\":\\\"corrTest5\\\"}}\"]"; - private static final String JSON_EXAMPLE_WITH_CORRELATION_ID4 = "{\"header\":{\"key\":\"value\"}}"; + private static final String JSON_WITH_NO_CORRELATION_ID = "[{\"key1\":\"value1\"}]"; @Test public void parseJsonSuccessful() { @@ -56,21 +46,21 @@ public class JsonUtilForCorrelationIdTest { assertThat(expectedResult).containsExactly("corrTest1", "corrTest2"); List<String> expectedResult2 = JsonUtilForCorrelationId - .parseJsonToGelAllCorrelationId(JSON_EXAMPLE_WITH_CORRELATION_ID2); + .parseJsonToGelAllCorrelationId(JSON_WITH_ONE_CORRELATION_ID); assertThat(expectedResult2).containsExactly("corrTest3"); } @Test public void parseJsonWithEscapeCharacters_Successful() { List<String> expectedResult = JsonUtilForCorrelationId - .parseJsonToGelAllCorrelationId(JSON_EXAMPLE_WITH_CORRELATION_ID3); + .parseJsonToGelAllCorrelationId(JSON_WITH_TWO_CORRELATION_ID_AND_ESCAPED_CHARACTERS); assertThat(expectedResult).containsExactly("corrTest4", "corrTest5"); } @Test public void parseJson_emptyListReturnedWhenNothingFound() { List<String> expectedResult = JsonUtilForCorrelationId - .parseJsonToGelAllCorrelationId(JSON_EXAMPLE_WITH_CORRELATION_ID4); + .parseJsonToGelAllCorrelationId(JSON_WITH_NO_CORRELATION_ID); assertThat(expectedResult).isEmpty(); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java index 470061f6c2..33b4689629 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2018 Nokia. + * ================================================================================ * 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 @@ -56,22 +58,10 @@ public class PnfEventReadyDmaapClientTest { private static final String CORRELATION_ID = "corrTestId"; private static final String CORRELATION_ID_NOT_FOUND_IN_MAP = "otherCorrId"; - private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[\n" - + " {\n" - + " \"pnfRegistrationFields\" : {\n" - + " \"correlationId\" : \"%s\",\n" - + " \"value\" : \"value1\"\n" - + " }\n" - + " },\n" - + " {\n" - + " \"pnfRegistrationFields\" : {\n" - + " \"correlationId\" : \"corr\",\n" - + " \"value\" : \"value2\"\n" - + " }\n" - + " }\n" - + "]"; - private static final String JSON_EXAMPLE_WITH_NO_CORRELATION_ID = - "{\"pnfRegistrationFields\":{\"field\":\"value\"}}"; + private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[{\"correlationId\": \"%s\"," + + "\"value\":\"value1\"},{\"correlationId\": \"corr\",\"value\":\"value2\"}]"; + + private static final String JSON_EXAMPLE_WITH_NO_CORRELATION_ID = "[{\"key1\":\"value1\"}]"; private static final String HOST = "hostTest"; private static final int PORT = 1234; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java new file mode 100644 index 0000000000..612051f903 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2018 Bell Canada. + * + * 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. + */ +package org.onap.so.bpmn.buildingblock; + +import java.util.Map; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class HomingV2 { + + @Autowired + private OofHomingV2 oofHomingV2; + @Autowired + private SniroHomingV2 sniroHomingV2; + + private static final String HOMINGSOLUTION = "Homing_Solution"; + + public void callHoming(BuildingBlockExecution execution) { + if (isOof(execution)) { + oofHomingV2.callOof(execution); + } else { + sniroHomingV2.callSniro(execution); + } + } + + public void processSolution(BuildingBlockExecution execution, String asyncResponse) { + if (isOof(execution)) { + oofHomingV2.processSolution(execution, asyncResponse); + } else { + sniroHomingV2.processSolution(execution, asyncResponse); + } + } + + // Default solution is SNIRO. OOF gets called only if specified. + private boolean isOof(BuildingBlockExecution execution) { + for (Map<String, Object> params : execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters() + .getUserParams()) { + if (params.containsKey(HOMINGSOLUTION) && params.get(HOMINGSOLUTION).equals("oof")) { + return true; + } + } + return false; + } +} 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 87c04d7ecc..38261c0f1a 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 @@ -54,6 +54,7 @@ import org.springframework.stereotype.Component; @Component public class AAIUpdateTasks { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAIUpdateTasks.class); + private static final String ALACARTE = "aLaCarte"; private static final String MULTI_STAGE_DESIGN_OFF = "false"; private static final String MULTI_STAGE_DESIGN_ON = "true"; @Autowired @@ -196,7 +197,8 @@ public class AAIUpdateTasks { if (vnf.getModelInfoGenericVnf() != null) { multiStageDesign = vnf.getModelInfoGenericVnf().getMultiStageDesign(); } - if (multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) { + boolean aLaCarte = (boolean) execution.getVariable(ALACARTE); + if (aLaCarte && multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) { aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule,vnf,OrchestrationStatus.PENDING_ACTIVATION); } else { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java index d13c5db871..615b7279dc 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java @@ -37,6 +37,7 @@ import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -95,10 +96,13 @@ public class ConfigurationScaleOut { for (Map.Entry<String,String> entry : param.entrySet()) { key = entry.getKey(); paramValue = entry.getValue(); - configScaleOutParam = JsonPath.parse(sdncVfModuleQueryResponse).read(paramValue); - if(configScaleOutParam != null){ - paramsMap.put(key, configScaleOutParam); + try{ + configScaleOutParam = JsonPath.parse(sdncVfModuleQueryResponse).read(paramValue); + }catch(ClassCastException e){ + configScaleOutParam = null; + msoLogger.warnSimple("Incorrect JSON path. Path points to object rather than value causing: ", e); } + paramsMap.put(key, configScaleOutParam); } } } @@ -107,7 +111,6 @@ public class ConfigurationScaleOut { configPayload.setConfigurationParameters(paramsMap); configPayload.setRequestParameters(requestParameters); configScaleOutPayloadString = mapper.writeValueAsString(configPayload); - configScaleOutPayloadString = configScaleOutPayloadString.replaceAll("\"", "\\\\\""); execution.setVariable(ACTION, actionCategory); execution.setVariable(MSO_REQUEST_ID, gBBInput.getRequestContext().getMsoRequestId()); @@ -122,6 +125,9 @@ public class ConfigurationScaleOut { } public void callAppcClient(BuildingBlockExecution execution) { + msoLogger.trace("Start runAppcCommand "); + String appcCode = "1002"; + String appcMessage = ""; try{ Action commandAction = Action.valueOf(execution.getVariable(ACTION)); String msoRequestId = execution.getVariable(MSO_REQUEST_ID); @@ -135,10 +141,22 @@ public class ConfigurationScaleOut { HashMap<String, String> payloadInfo = new HashMap<>(); payloadInfo.put(VNF_NAME, execution.getVariable(VNF_NAME)); payloadInfo.put(VFMODULE_ID,execution.getVariable(VFMODULE_ID)); + msoLogger.debug("Running APP-C action: " + commandAction.toString()); + msoLogger.debug("VNFID: " + vnfId); //PayloadInfo contains extra information that adds on to payload before making request to appc appCClient.runAppCCommand(commandAction, msoRequestId, vnfId, payloadString, payloadInfo, controllerType); - }catch(Exception ex){ - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + appcCode = appCClient.getErrorCode(); + appcMessage = appCClient.getErrorMessage(); + + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "Caught exception in runAppcCommand in ConfigurationScaleOut", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "APPC Error", e); + appcMessage = e.getMessage(); + } + msoLogger.error("Error Message: " + appcMessage); + msoLogger.error("ERROR CODE: " + appcCode); + msoLogger.trace("End of runAppCommand "); + if (appcCode != null && !appcCode.equals("0")) { + exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java index 61162f4d85..2dae820e95 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java @@ -32,6 +32,7 @@ import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.catalog.beans.ControllerSelectionReference; +import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -78,7 +79,9 @@ public class GenericVnfHealthCheck { } public void callAppcClient(BuildingBlockExecution execution) { - + msoLogger.trace("Start runAppcCommand "); + String appcCode = "1002"; + String appcMessage = ""; try { Action action = null; action = Action.valueOf(execution.getVariable("action")); @@ -95,11 +98,23 @@ public class GenericVnfHealthCheck { payloadInfo.put("vfModuleId",execution.getVariable("vfModuleId")); payloadInfo.put("oamIpAddress",execution.getVariable("oamIpAddress")); payloadInfo.put("vnfHostIpAddress",execution.getVariable("vnfHostIpAddress")); + + msoLogger.debug("Running APP-C action: " + action.toString()); + msoLogger.debug("VNFID: " + vnfId); //PayloadInfo contains extra information that adds on to payload before making request to appc appCClient.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType); + appcCode = appCClient.getErrorCode(); + appcMessage = appCClient.getErrorMessage(); - } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "Caught exception in runAppcCommand in GenericVnfHealthCheck", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "APPC Error", e); + appcMessage = e.getMessage(); + } + msoLogger.error("Error Message: " + appcMessage); + msoLogger.error("ERROR CODE: " + appcCode); + msoLogger.trace("End of runAppCommand "); + if (appcCode != null && !appcCode.equals("0")) { + exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); + } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java index 88ae3746ab..b0063c1da1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java @@ -45,6 +45,7 @@ public class OrchestrationStatusValidator { private static final String UNKNOWN_RESOURCE_TYPE = "Building Block (%s) not set up correctly in Orchestration_Status_Validation table in CatalogDB. ResourceType=(%s), TargetAction=(%s)"; private static final String ORCHESTRATION_VALIDATION_FAIL = "Orchestration Status Validation failed. ResourceType=(%s), TargetAction=(%s), OrchestrationStatus=(%s)"; private static final String ORCHESTRATION_STATUS_VALIDATION_RESULT = "orchestrationStatusValidationResult"; + private static final String ALACARTE = "aLaCarte"; private static final String MULTI_STAGE_DESIGN_OFF = "false"; private static final String MULTI_STAGE_DESIGN_ON = "true"; @@ -62,8 +63,10 @@ public class OrchestrationStatusValidator { execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, null); - String buildingBlockFlowName = execution.getFlowToBeCalled(); + boolean aLaCarte = (boolean) execution.getVariable(ALACARTE); + String buildingBlockFlowName = execution.getFlowToBeCalled(); + BuildingBlockDetail buildingBlockDetail = catalogDbClient.getBuildingBlockDetail(buildingBlockFlowName); if (buildingBlockDetail == null) { @@ -112,7 +115,7 @@ public class OrchestrationStatusValidator { } OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = catalogDbClient.getOrchestrationStatusStateTransitionDirective(buildingBlockDetail.getResourceType(), orchestrationStatus, buildingBlockDetail.getTargetAction()); - if(ResourceType.VF_MODULE.equals(buildingBlockDetail.getResourceType()) && OrchestrationAction.CREATE.equals(buildingBlockDetail.getTargetAction()) && + if(aLaCarte && ResourceType.VF_MODULE.equals(buildingBlockDetail.getResourceType()) && OrchestrationAction.CREATE.equals(buildingBlockDetail.getTargetAction()) && OrchestrationStatus.PENDING_ACTIVATION.equals(orchestrationStatus)) { org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); orchestrationStatusStateTransitionDirective = processPossibleSecondStageofVfModuleCreate(execution, previousOrchestrationStatusValidationResult, @@ -138,11 +141,11 @@ public class OrchestrationStatusValidator { private OrchestrationStatusStateTransitionDirective processPossibleSecondStageofVfModuleCreate(BuildingBlockExecution execution, OrchestrationStatusValidationDirective previousOrchestrationStatusValidationResult, org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf, OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective) { if (previousOrchestrationStatusValidationResult != null && previousOrchestrationStatusValidationResult.equals(OrchestrationStatusValidationDirective.SILENT_SUCCESS)) { - String multiStageDesign = "false"; + String multiStageDesign = MULTI_STAGE_DESIGN_OFF; if (genericVnf.getModelInfoGenericVnf() != null) { multiStageDesign = genericVnf.getModelInfoGenericVnf().getMultiStageDesign(); } - if (multiStageDesign != null && multiStageDesign.equalsIgnoreCase("true")) { + if (multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) { orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); } } 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 ee5f2e806a..e9dcdade9f 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 @@ -81,6 +81,7 @@ public class WorkflowAction { private static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage"; private static final String SERVICE_INSTANCES = "serviceInstances"; + private static final String VF_MODULES = "vfModules"; private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI = "WorkflowAction was unable to verify if the instance name already exist in AAI."; private static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow"; private static final String G_ACTION = "requestAction"; @@ -104,7 +105,7 @@ public class WorkflowAction { private static final String USERPARAMSERVICE = "service"; private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances"; private static final String HOMINGSOLUTION = "Homing_Solution"; - private static final String FABRIC_CONFIGURATION = "FabricConfiguration"; + private static final String FABRIC_CONFIGURATION = "FabricConfiguration"; private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); @Autowired @@ -162,19 +163,6 @@ public class WorkflowAction { execution.setVariable("resourceId", resourceId); execution.setVariable("resourceType", resourceType); - if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { - List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters() - .getUserParams(); - for (Map<String, Object> params : userParams) { - if (params.containsKey(HOMINGSOLUTION)) { - execution.setVariable("homing", true); - execution.setVariable("callHoming", true); - execution.setVariable("homingSolution", params.get(HOMINGSOLUTION)); - execution.setVariable("homingService", params.get(HOMINGSOLUTION)); - } - } - } - if (aLaCarte) { if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte); @@ -269,9 +257,10 @@ public class WorkflowAction { logger.info("Sorting for Vlan Tagging"); flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); } + // By default, enable homing at VNF level for CREATEINSTANCE and ASSIGNINSTANCE if (resourceType == WorkflowType.SERVICE - && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)) - && !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType())).collect(Collectors.toList()).isEmpty()) { + && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)) + && !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType())).collect(Collectors.toList()).isEmpty()) { execution.setVariable("homing", true); execution.setVariable("calledHoming", false); } @@ -282,6 +271,20 @@ public class WorkflowAction { } } + // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, enable it. + if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { + List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams(); + for (Map<String, Object> params : userParams) { + if (params.containsKey(HOMINGSOLUTION)) { + if (params.get(HOMINGSOLUTION).equals("none")) { + execution.setVariable("homing", false); + } else { + execution.setVariable("homing", true); + } + } + } + } + if (flowsToExecute.isEmpty()) { throw new IllegalStateException("Macro did not come up with a valid execution path."); } @@ -665,35 +668,38 @@ public class WorkflowAction { } protected Resource extractResourceIdAndTypeFromUri(String uri) { - Pattern patt = Pattern.compile( - "[vV]\\d+.*?(?:(?:/(?<type>" + supportedTypes + ")(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?)?$"); - Matcher m = patt.matcher(uri); - Boolean generated = false; - - if (m.find()) { - logger.debug("found match on {} : {} " , uri , m); - String type = m.group("type"); - String id = m.group("id"); - String action = m.group("action"); - if (type == null) { - throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri); - } - if (action == null) { - if (type.equals(SERVICE_INSTANCES) && (id == null || id.equals("assign"))) { - id = UUID.randomUUID().toString(); - generated = true; - } - } else { - if (action.matches(supportedTypes)) { - id = UUID.randomUUID().toString(); - generated = true; - type = action; - } - } - return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated); - } else { - throw new IllegalArgumentException("Uri could not be parsed: " + uri); - } + Pattern patt = Pattern.compile( + "[vV]\\d+.*?(?:(?:/(?<type>" + supportedTypes + ")(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?)?$"); + Matcher m = patt.matcher(uri); + Boolean generated = false; + + if (m.find()) { + logger.debug("found match on {} : {} " , uri , m); + String type = m.group("type"); + String id = m.group("id"); + String action = m.group("action"); + if (type == null) { + throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri); + } + if (action == null) { + if (type.equals(SERVICE_INSTANCES) && (id == null || id.equals("assign"))) { + id = UUID.randomUUID().toString(); + generated = true; + }else if (type.equals(VF_MODULES) && id.equals("scaleOut")) { + id = UUID.randomUUID().toString(); + generated = true; + } + } else { + if (action.matches(supportedTypes)) { + id = UUID.randomUUID().toString(); + generated = true; + type = action; + } + } + return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated); + } else { + throw new IllegalArgumentException("Uri could not be parsed: " + uri); + } } protected String validateResourceIdInAAI(String generatedResourceId, WorkflowType type, String instanceName, 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 bf66283b17..6c20938780 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 @@ -184,6 +184,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ @Test public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleNoMultiStageTest() throws Exception { + execution.setVariable("aLaCarte", true); ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); modelInfoGenericVnf.setMultiStageDesign("false"); genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); @@ -194,7 +195,20 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ } @Test + public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleMultiStageButNotAlacarteTest() throws Exception { + execution.setVariable("aLaCarte", false); + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); + modelInfoGenericVnf.setMultiStageDesign("true"); + genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); + doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED); + aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution); + verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED); + assertEquals("", vfModule.getHeatStackId()); + } + + @Test public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleWithMultiStageTest() throws Exception { + execution.setVariable("aLaCarte", true); ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); modelInfoGenericVnf.setMultiStageDesign("true"); genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); @@ -206,6 +220,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ @Test public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleExceptionTest() throws Exception { + execution.setVariable("aLaCarte", true); doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED); expectedException.expect(BpmnError.class); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java index 00a91f0ce2..ad848a4d49 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java @@ -93,9 +93,9 @@ public class ConfigurationScaleOutTest extends BaseTaskTest { controllerSelectionReference.setActionCategory("testAction"); controllerSelectionReference.setVnfType("testVnfType"); String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientGetResponse.json"))); - String expectedPayload = "{\\\"request-parameters\\\":{\\\"vnf-host-ip-address\\\":\\\"10.222.22.2\\\"," - + "\\\"vf-module-id\\\":\\\"testVfModuleId1\\\"},\\\"configuration-parameters\\\"" - + ":{\\\"vnf-id\\\":\\\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\\\",\\\"availability-zone\\\":\\\"AZ-MN02\\\"}}"; + String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\"," + + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\"" + + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}"; execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse); doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.ConfigScaleOut.toString()); @@ -115,9 +115,9 @@ public class ConfigurationScaleOutTest extends BaseTaskTest { Action action = Action.ConfigScaleOut; String vnfId = genericVnf.getVnfId(); String controllerType = "testType"; - String payload = "{\\\"request-parameters\\\":{\\\"vnf-host-ip-address\\\":\\\"10.222.22.2\\\"," - + "\\\"vf-module-id\\\":\\\"testVfModuleId1\\\"},\\\"configuration-parameters\\\"" - + ":{\\\"vnf-id\\\":\\\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\\\",\\\"availability-zone\\\":\\\"AZ-MN02\\\"}}"; + String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\"," + + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\"" + + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}"; HashMap<String, String> payloadInfo = new HashMap<String, String>(); payloadInfo.put("vnfName", "testVnfName"); payloadInfo.put("vfModuleId", "testVfModuleId"); @@ -135,5 +135,56 @@ public class ConfigurationScaleOutTest extends BaseTaskTest { configurationScaleOut.callAppcClient(execution); verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); } + @Test + public void setParamsForConfigurationScaleOutBadPathTest() throws Exception { + ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference(); + controllerSelectionReference.setControllerName("testName"); + controllerSelectionReference.setActionCategory("testAction"); + controllerSelectionReference.setVnfType("testVnfType"); + String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientResponseIncorrectPath.json"))); + String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\"," + + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\"" + + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":null}}"; + execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse); + + doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.ConfigScaleOut.toString()); + + configurationScaleOut.setParamsForConfigurationScaleOut(execution); + + assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId")); + assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName")); + assertEquals("ConfigScaleOut", execution.getVariable("action")); + assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId")); + assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType")); + assertEquals(vfModule.getVfModuleId(), execution.getVariable("vfModuleId")); + assertEquals(expectedPayload, execution.getVariable("payload")); + } + @Test + public void callAppcClientExceptionTest() throws Exception { + expectedException.expect(BpmnError.class); + Action action = Action.ConfigScaleOut; + String vnfId = genericVnf.getVnfId(); + String controllerType = "testType"; + String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\"," + + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\"" + + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}"; + HashMap<String, String> payloadInfo = new HashMap<String, String>(); + payloadInfo.put("vnfName", "testVnfName"); + payloadInfo.put("vfModuleId", "testVfModuleId"); + + execution.setVariable("action", Action.ConfigScaleOut.toString()); + execution.setVariable("msoRequestId", msoRequestId); + execution.setVariable("controllerType", controllerType); + execution.setVariable("vnfId", "testVnfId1"); + execution.setVariable("vnfName", "testVnfName"); + execution.setVariable("vfModuleId", "testVfModuleId"); + execution.setVariable("payload", payload); + + + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed")); + doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); + configurationScaleOut.callAppcClient(execution); + verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java index af390d1d76..e17859969d 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java @@ -112,4 +112,34 @@ public class GenericVnfHealthCheckTest extends BaseTaskTest { genericVnfHealthCheck.callAppcClient(execution); verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); } + + @Test + public void callAppcClientExceptionTest() throws Exception { + expectedException.expect(BpmnError.class); + Action action = Action.HealthCheck; + String vnfId = genericVnf.getVnfId(); + String payload = "{\"testName\":\"testValue\",}"; + String controllerType = "testType"; + HashMap<String, String> payloadInfo = new HashMap<String, String>(); + payloadInfo.put("vnfName", "testVnfName"); + payloadInfo.put("vfModuleId", "testVfModuleId"); + payloadInfo.put("oamIpAddress", "testOamIpAddress"); + payloadInfo.put("vnfHostIpAddress", "testOamIpAddress"); + execution.setVariable("action", Action.HealthCheck.toString()); + execution.setVariable("msoRequestId", msoRequestId); + execution.setVariable("controllerType", controllerType); + execution.setVariable("vnfId", "testVnfId1"); + execution.setVariable("vnfName", "testVnfName"); + execution.setVariable("vfModuleId", "testVfModuleId"); + execution.setVariable("oamIpAddress", "testOamIpAddress"); + execution.setVariable("vnfHostIpAddress", "testOamIpAddress"); + execution.setVariable("payload", payload); + + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed")); + doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); + + + genericVnfHealthCheck.callAppcClient(execution); + verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java index 5496eed11d..60d456e2b5 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java @@ -63,7 +63,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { public void test_validateOrchestrationStatus() throws Exception { String flowToBeCalled = "AssignServiceInstanceBB"; setServiceInstance().setOrchestrationStatus(OrchestrationStatus.PRECREATED); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); @@ -103,6 +103,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { si.setConfigurations(configurations); execution.setVariable("flowToBeCalled", flowToBeCalled); + execution.setVariable("aLaCarte", true); BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); buildingBlockDetail.setBuildingBlockName("UnassignFabricConfigurationBB"); @@ -200,6 +201,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "UnassignServiceInstanceBB"; execution.setVariable("flowToBeCalled", flowToBeCalled); + execution.setVariable("aLaCarte", true); BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); buildingBlockDetail.setBuildingBlockName("UnassignServiceInstanceBB"); @@ -221,7 +223,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "CreateVfModuleBB"; execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); GenericVnf genericVnf = buildGenericVnf(); @@ -258,7 +260,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "CreateVfModuleBB"; execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.CONTINUE); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); GenericVnf genericVnf = buildGenericVnf(); @@ -294,7 +296,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "CreateVfModuleBB"; execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); GenericVnf genericVnf = buildGenericVnf(); @@ -330,7 +332,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "CreateVfModuleBB"; execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); GenericVnf genericVnf = buildGenericVnf(); @@ -366,7 +368,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "CreateVfModuleBB"; execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); GenericVnf genericVnf = buildGenericVnf(); @@ -396,4 +398,40 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); } + + @Test + public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongAlacarteValueVfModule() throws Exception { + String flowToBeCalled = "CreateVfModuleBB"; + + execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS); + execution.setVariable("aLaCarte", false); + execution.setVariable("flowToBeCalled", flowToBeCalled); + + GenericVnf genericVnf = buildGenericVnf(); + ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf(); + modelInfoGenericVnf.setMultiStageDesign("true"); + setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); + setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + + BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); + buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); + buildingBlockDetail.setId(1); + buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); + buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + + doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); + orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); + orchestrationStatusStateTransitionDirective.setId(1); + orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); + orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE); + + doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE); + + orchestrationStatusValidator.validateOrchestrationStatus(execution); + + assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); + } } 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 14398710f3..76a807056c 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 @@ -821,7 +821,7 @@ public class WorkflowActionTest extends BaseTaskTest { String uri5 = "'/v6/serviceInstances/123/vnfs"; String uri6 = "/v6/serviceInstances/123/vnfs/1234/someAction"; String uri7 = "/v6/serviceInstances/123/vnfs/1234/vfModules/5678/replace"; - + String uri8 = "/v6/serviceInstances/123/vnfs/1234/vfModules/scaleOut"; Resource expected1 = new Resource(WorkflowType.SERVICE, "123", true); Resource expected2 = new Resource(WorkflowType.VNF, "1234", false); Resource expected3 = new Resource(WorkflowType.VNF, "1234", false); @@ -847,6 +847,10 @@ public class WorkflowActionTest extends BaseTaskTest { result = workflowAction.extractResourceIdAndTypeFromUri(uri7); assertEquals(expected4.getResourceId(),result.getResourceId()); assertEquals(expected4.getResourceType(),result.getResourceType()); + result = workflowAction.extractResourceIdAndTypeFromUri(uri8); + assertEquals(UUID.randomUUID().toString().length(),result.getResourceId().length()); + assertEquals("VfModule", result.getResourceType().toString()); + } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientResponseIncorrectPath.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientResponseIncorrectPath.json new file mode 100644 index 0000000000..7e263b4465 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientResponseIncorrectPath.json @@ -0,0 +1,29 @@ +{ + "vnf-topology": { + "tenant": "0422ffb57ba042c0800a29dc85ca70f8", + "vnf-topology-identifier-structure": { + "vnf-id": "66dac89b-2a5b-4cb9-b22e-a7e4488fb3db", + "vnf-type": "InfraMSO_vSAMP10a_Service/InfraMSO_vSAMP10a-2 0", + "vnf-name": "MSO-DEV-VNF-1806HF1-InfraMSO_vSAMP10a-1XXX-GR_21" + }, + "aic-clli": "AUSTTXGR", + "vnf-resource-assignments": { + "availability-zones": { + "availability-zone": [ + { + "test":"AZ-MN02" + } + ], + "max-count": 1 + } + }, + "aic-cloud-region": "mtn6", + "onap-model-information": { + "model-customization-uuid": "034226ae-879a-46b5-855c-d02babcb6cb6", + "model-uuid": "cb79c25f-b30d-4d95-afb5-97be4021f3db", + "model-invariant-uuid": "e93d3a7a-446d-486b-ae48-d474a9156064", + "model-name": "InfraMSO_vSAMP10a-2", + "model-version": "1.0" + } + } +}
\ No newline at end of file |