diff options
Diffstat (limited to 'bpmn')
7 files changed, 418 insertions, 6 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java index 29abe4413b..0b2ef928ad 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -25,11 +25,11 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers; -import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader; -import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput; -import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; import org.onap.so.client.PreconditionFailedException; import org.onap.so.client.RestPropertiesLoader; import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java index a83337fc5b..5271bb3c53 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java @@ -22,13 +22,17 @@ package org.onap.so.bpmn.core.domain; import static org.junit.Assert.*; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Test; public class VnfResourceTest { - + + private final static String ALL_VF_MODULES_JSON = + "{\"ArrayList\":[{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0},{\"resourceType\":\"MODULE\",\"resourceInstance\":{},\"homingSolution\":{\"license\":{},\"rehome\":false},\"vfModuleName\":\"vfModuleName\",\"vfModuleType\":\"vfModuleType\",\"heatStackId\":\"heatStackId\",\"hasVolumeGroup\":true,\"isBase\":true,\"vfModuleLabel\":\"vfModuleLabel\",\"initialCount\":0}]}"; + private VnfResource vnf= new VnfResource(); List<ModuleResource> moduleResources; @@ -63,4 +67,34 @@ public class VnfResourceTest { assertTrue(vnfResource != null); } + @Test + public void testVfModules() { + + moduleResources = new ArrayList<>(); + + ModuleResource moduleresource = new ModuleResource(); + moduleresource.setVfModuleName("vfModuleName"); + moduleresource.setHeatStackId("heatStackId"); + moduleresource.setIsBase(true); + moduleresource.setVfModuleLabel("vfModuleLabel"); + moduleresource.setInitialCount(0); + moduleresource.setVfModuleType("vfModuleType"); + moduleresource.setHasVolumeGroup(true); + + moduleResources.add(moduleresource); + + vnf.setModules(moduleResources); + assertEquals(vnf.getVfModules(), moduleResources); + + List<ModuleResource> moduleResources = vnf.getAllVfModuleObjects(); + assertEquals(1, moduleResources.size()); + + vnf.addVfModule(moduleresource); + moduleResources = vnf.getAllVfModuleObjects(); + assertEquals(2, moduleResources.size()); + + assertEquals(ALL_VF_MODULES_JSON, vnf.getAllVfModulesJson()); + + } + } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn new file mode 100644 index 0000000000..92ac5f9f5b --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn @@ -0,0 +1,116 @@ +<?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_1556kf5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4"> + <bpmn:process id="ConfigDeployVnfBB" name="ConfigDeployVnfBB" isExecutable="true"> + <bpmn:startEvent id="Start" name="Start"> + <bpmn:outgoing>SequenceFlow_0pd4jka</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="UpdateAAIConfigured" name="Update AAI Configured" camunda:expression="${ConfigDeployVnf.updateAAIConfigured(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1tb7fs1</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_00u29dm</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:endEvent id="End" name="End"> + <bpmn:incoming>SequenceFlow_00u29dm</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0pd4jka" sourceRef="Start" targetRef="UpdateAAIConfigure" /> + <bpmn:sequenceFlow id="SequenceFlow_03xbj4e" sourceRef="AbstractCDSBB" targetRef="ExclusiveGateway_0duh80v" /> + <bpmn:sequenceFlow id="SequenceFlow_00u29dm" sourceRef="UpdateAAIConfigured" targetRef="End" /> + <bpmn:callActivity id="AbstractCDSBB" name="Abstract CDS (CDS Call)" calledElement="AbstractCDSProcessingBB"> + <bpmn:extensionElements> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="executionObject" target="executionObject" /> + <camunda:out source="CDSStatus" target="CDSStatus" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0kruy8t</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_03xbj4e</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:serviceTask id="UpdateAAIConfigure" name="Update AAI Configure" camunda:expression="${ConfigDeployVnf.updateAAIConfigure(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0pd4jka</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0moyu92</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0moyu92" sourceRef="UpdateAAIConfigure" targetRef="PreProcessAbstractCDSProcessing" /> + <bpmn:sequenceFlow id="SequenceFlow_0kruy8t" sourceRef="PreProcessAbstractCDSProcessing" targetRef="AbstractCDSBB" /> + <bpmn:serviceTask id="PreProcessAbstractCDSProcessing" name="PreProcess Abstract CDS Processing" camunda:expression="${ConfigDeployVnf.preProcessAbstractCDSProcessing(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0moyu92</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0kruy8t</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_0duh80v" default="SequenceFlow_0o50k2d"> + <bpmn:incoming>SequenceFlow_03xbj4e</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1tb7fs1</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0o50k2d</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1tb7fs1" name="success" sourceRef="ExclusiveGateway_0duh80v" targetRef="UpdateAAIConfigured"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0o50k2d" sourceRef="ExclusiveGateway_0duh80v" targetRef="EndEvent_0wwnq4u" /> + <bpmn:endEvent id="EndEvent_0wwnq4u"> + <bpmn:incoming>SequenceFlow_0o50k2d</bpmn:incoming> + <bpmn:errorEventDefinition errorRef="Error_0zsv500" /> + </bpmn:endEvent> + </bpmn:process> + <bpmn:error id="Error_0zsv500" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ConfigDeployVnfBB"> + <bpmndi:BPMNEdge id="SequenceFlow_0pd4jka_di" bpmnElement="SequenceFlow_0pd4jka"> + <di:waypoint x="542" y="248" /> + <di:waypoint x="607" y="248" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_03xbj4e_di" bpmnElement="SequenceFlow_03xbj4e"> + <di:waypoint x="1039" y="248" /> + <di:waypoint x="1089" y="248" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_00u29dm_di" bpmnElement="SequenceFlow_00u29dm"> + <di:waypoint x="1327" y="248" /> + <di:waypoint x="1399" y="248" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start"> + <dc:Bounds x="506" y="230" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="512" y="273" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0c9apxl_di" bpmnElement="UpdateAAIConfigured"> + <dc:Bounds x="1227" y="208" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0p7ssqo_di" bpmnElement="End"> + <dc:Bounds x="1399" y="230" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1407" y="273" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0vg7uiv_di" bpmnElement="AbstractCDSBB"> + <dc:Bounds x="939" y="208" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_05zt0do_di" bpmnElement="UpdateAAIConfigure"> + <dc:Bounds x="607" y="208" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0moyu92_di" bpmnElement="SequenceFlow_0moyu92"> + <di:waypoint x="707" y="248" /> + <di:waypoint x="770" y="248" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0kruy8t_di" bpmnElement="SequenceFlow_0kruy8t"> + <di:waypoint x="870" y="248" /> + <di:waypoint x="939" y="248" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0m4kmps_di" bpmnElement="PreProcessAbstractCDSProcessing"> + <dc:Bounds x="770" y="208" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0duh80v_di" bpmnElement="ExclusiveGateway_0duh80v" isMarkerVisible="true"> + <dc:Bounds x="1089" y="223" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1tb7fs1_di" bpmnElement="SequenceFlow_1tb7fs1"> + <di:waypoint x="1139" y="248" /> + <di:waypoint x="1227" y="248" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1163" y="230" width="41" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0o50k2d_di" bpmnElement="SequenceFlow_0o50k2d"> + <di:waypoint x="1114" y="273" /> + <di:waypoint x="1114" y="348" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_1p3d0t4_di" bpmnElement="EndEvent_0wwnq4u"> + <dc:Bounds x="1096" y="348" width="36" height="36" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> 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 bc6770cc81..82b61c17b5 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 @@ -538,4 +538,26 @@ public class AAIUpdateTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void updateOrchestrationStausConfigDeployConfigureVnf(BuildingBlockExecution execution){ + try{ + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURE); + + }catch(Exception ex){ + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + + } + + public void updateOrchestrationStausConfigDeployConfiguredVnf(BuildingBlockExecution execution){ + try{ + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURED); + + }catch(Exception ex){ + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java new file mode 100644 index 0000000000..1bc7c0f574 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java @@ -0,0 +1,130 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2019 TechMahindra +*================================================================================= +* 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.flowspecific.tasks; + +import java.util.UUID; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.cds.beans.ConfigDeployPropertiesForVnf; +import org.onap.so.client.cds.beans.ConfigDeployRequestVnf; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * + * Get vnf related data and config Deploy + * + */ +@Component +public class ConfigDeployVnf { + private static final Logger logger = LoggerFactory.getLogger(ConfigDeployVnf.class); + private final static String ORIGINATOR_ID = "SO"; + private final static String ACTION_NAME = "config-deploy"; + private final static String MODE = "async"; + + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private ExtractPojosForBB extractPojosForBB; + @Autowired + private AAIUpdateTasks aaiUpdateTask; + + /** + * Update vnf orch status to configure in AAI + * + * @param execution + */ + public void updateAAIConfigure(BuildingBlockExecution execution) { + aaiUpdateTask.updateOrchestrationStausConfigDeployConfigureVnf(execution); + + } + /** + * Getting the vnf object and set in execution object + * + * @param execution + * + * + */ + public void preProcessAbstractCDSProcessing(BuildingBlockExecution execution) { + + + logger.info("Start preProcessAbstractCDSProcessing"); + try { + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + + ConfigDeployPropertiesForVnf configDeployPropertiesForVnf = new ConfigDeployPropertiesForVnf(); + configDeployPropertiesForVnf.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + configDeployPropertiesForVnf.setServiceModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid()); + configDeployPropertiesForVnf.setVnfCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid()); + configDeployPropertiesForVnf.setVnfId(vnf.getVnfId()); + configDeployPropertiesForVnf.setVnfName(vnf.getVnfName()); + + ConfigDeployRequestVnf configDeployRequestVnf = new ConfigDeployRequestVnf(); + + configDeployRequestVnf.setResolutionKey(vnf.getVnfName()); + configDeployRequestVnf.setConfigDeployPropertiesForVnf(configDeployPropertiesForVnf); + + String blueprintName = vnf.getBlueprintName(); + String blueprintVersion = vnf.getBlueprintVersion(); + AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean(); + + abstractCDSPropertiesBean.setBlueprintName(blueprintName); + abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion); + abstractCDSPropertiesBean.setRequestObject(configDeployRequestVnf.toString()); + + + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + + abstractCDSPropertiesBean.setOriginatorId( ORIGINATOR_ID); + abstractCDSPropertiesBean.setRequestId(gBBInput.getRequestContext().getMsoRequestId()); + abstractCDSPropertiesBean.setSubRequestId(UUID.randomUUID().toString()); + abstractCDSPropertiesBean.setActionName(ACTION_NAME); + abstractCDSPropertiesBean.setMode(MODE); + + execution.setVariable("executionObject", abstractCDSPropertiesBean); + + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + /** + * Update vnf orch status to configured in AAI + * + * @param execution + */ + public void updateAAIConfigured(BuildingBlockExecution execution) { + aaiUpdateTask.updateOrchestrationStausConfigDeployConfiguredVnf(execution); + + } +}
\ No newline at end of file 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 78d08aa1f1..05af58040a 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 @@ -655,4 +655,17 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ aaiUpdateTasks.updateManagementV6AddressVnf(execution); verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf); } + + @Test + public void updateOrchestrationStatusVnfConfigureTest() throws Exception { + doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURE); + + aaiUpdateTasks.updateOrchestrationStausConfigDeployConfigureVnf(execution); + } + @Test + public void updateOrchestrationStatusVnfConfiguredTest() throws Exception { + doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURED); + + aaiUpdateTasks.updateOrchestrationStausConfigDeployConfiguredVnf(execution); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java new file mode 100644 index 0000000000..e5aa702dad --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java @@ -0,0 +1,97 @@ + +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2019 TechMahindra +*================================================================================= +* 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.flowspecific.tasks; + +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.aai.tasks.AAIUpdateTasks; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.exception.BBObjectNotFoundException; + +public class ConfigDeployVnfTest extends BaseTaskTest { + + @InjectMocks + private ConfigDeployVnf configDeployVnf = new ConfigDeployVnf(); + @Mock + AAIUpdateTasks aAIUpdateTasks = new AAIUpdateTasks(); + + + private GenericVnf genericVnf; + private ServiceInstance serviceInstance; + private RequestContext requestContext; + private String msoRequestId; + + @Before + public void before() throws BBObjectNotFoundException { + genericVnf = setGenericVnf(); + serviceInstance = setServiceInstance(); + msoRequestId = UUID.randomUUID().toString(); + requestContext = setRequestContext(); + requestContext.setMsoRequestId(msoRequestId); + gBBInput.setRequestContext(requestContext); + + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance); + } + + + + @Test + public void preProcessAbstractCDSProcessingTest() throws Exception { + + configDeployVnf.preProcessAbstractCDSProcessing(execution); + + assertTrue(true); + } + + @Test + public void updateAAIConfigureTaskTest() throws Exception { + + configDeployVnf.updateAAIConfigure(execution); + assertTrue(true); + } + + @Test + public void updateAAIConfiguredTaskTest() throws Exception { + configDeployVnf.updateAAIConfigured(execution); + assertTrue(true); + } + +} |