diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks')
6 files changed, 359 insertions, 33 deletions
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 4d5494d18c..8a6c4c2796 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 @@ -5,13 +5,14 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (c) 2019 Samsung + * Modifications Copyright (c) 2019 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. @@ -22,39 +23,23 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; -import java.util.List; -import java.util.Map; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.*; 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.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.client.orchestration.AAICollectionResources; -import org.onap.so.client.orchestration.AAIConfigurationResources; -import org.onap.so.client.orchestration.AAINetworkResources; -import org.onap.so.client.orchestration.AAIPnfResources; -import org.onap.so.client.orchestration.AAIServiceInstanceResources; -import org.onap.so.client.orchestration.AAIVfModuleResources; -import org.onap.so.client.orchestration.AAIVnfResources; -import org.onap.so.client.orchestration.AAIVolumeGroupResources; +import org.onap.so.client.orchestration.*; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.List; +import java.util.Map; @Component public class AAIUpdateTasks { @@ -340,7 +325,6 @@ public class AAIUpdateTasks { * BPMN access method to update status of VfModule to Created in AAI * * @param execution - * */ public void updateOrchestrationStatusCreatedVfModule(BuildingBlockExecution execution) { try { @@ -357,7 +341,6 @@ public class AAIUpdateTasks { * BPMN access method to update aaiDeactivateVfModuleRollback to true for deactivating the VfModule * * @param execution - * @throws buildAndThrowWorkflowException */ public void updateOrchestrationStatusDeactivateVfModule(BuildingBlockExecution execution) { execution.setVariable("aaiDeactivateVfModuleRollback", false); @@ -794,7 +777,6 @@ public class AAIUpdateTasks { logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusConfigDeployConfigureVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } - } /** @@ -806,11 +788,55 @@ public class AAIUpdateTasks { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURED); - } catch (Exception ex) { logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusConfigDeployConfiguredVnf", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } + } + /** + * BPMN access method to update status of VNF/VF-Module based on SO scope and action. + * + * @param execution - BuildingBlockExecution + * @param scope - SO scope (vnf/vfModule) + * @param action - action (configAssign/configDeploy/configUndeploy etc..) + */ + public void updateOrchestrationStatusForCds(BuildingBlockExecution execution, String scope, String action) { + try { + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + OrchestrationStatus status = getOrchestrationStatus(action); + switch (scope) { + case "vnf": + aaiVnfResources.updateOrchestrationStatusVnf(vnf, status); + break; + case "vfModule": + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, status); + break; + default: + throw new IllegalArgumentException( + "Invalid scope to update orchestration status for CDS : " + action); + } + } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusForCds", ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + private OrchestrationStatus getOrchestrationStatus(String action) { + /** + * At this state, OrcherstationStatus enum associated with configAssign and configDeploy. I am not sure which is + * the correct approach. 1. Are we going to map each specific action to OrchestrationStauts ? 2. We will have + * only one generic status for all actions ? + */ + + switch (action) { + case "configAssign": + return OrchestrationStatus.ASSIGNED; + case "configDeploy": + return OrchestrationStatus.CONFIGURED; + default: + throw new IllegalArgumentException("Invalid action to set Orchestration status: " + action); + } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java index 6b0cbc0396..0f65b4b3d4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java @@ -31,11 +31,14 @@ import org.springframework.stereotype.Component; * This implementation of {@ref ControllerRunnable} is used for Self service, i.e, blueprint based Controller. */ @Component -public class CdsControllerDE extends AbstractCDSProcessingBBUtils implements ControllerRunnable<DelegateExecution> { +public class CdsControllerDE implements ControllerRunnable<DelegateExecution> { @Autowired(required = false) private List<ControllerPreparable<DelegateExecution>> prepareList; + @Autowired + private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils; + @Override public Boolean understand(ControllerContext<DelegateExecution> context) { return context.getControllerActor().equalsIgnoreCase("cds"); @@ -55,7 +58,7 @@ public class CdsControllerDE extends AbstractCDSProcessingBBUtils implements Con @Override public void run(ControllerContext<DelegateExecution> context) { DelegateExecution execution = context.getExecution(); - constructExecutionServiceInputObject(execution); - sendRequestToCDSClient(execution); + abstractCDSProcessingBBUtils.constructExecutionServiceInputObject(execution); + abstractCDSProcessingBBUtils.sendRequestToCDSClient(execution); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java new file mode 100644 index 0000000000..f568026aa5 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.flowspecific.tasks; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.cds.AbstractCDSProcessingBBUtils; +import org.onap.so.client.cds.GeneratePayloadForCds; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +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; + +/** + * For Vnf/Vf-Module/Service BuildingBlockExecution is being used. + * + * @param - BuildingBlockExecution + */ +@Component +public class GenericCDSProcessingBB implements ControllerRunnable<BuildingBlockExecution> { + private static final Logger logger = LoggerFactory.getLogger(GenericCDSProcessingBB.class); + private static final String EXECUTION_OBJECT = "executionObject"; + public static final String CDS_ACTOR = "cds"; + public static final String VNF_SCOPE = "vnf"; + public static final String VF_MODULE_SCOPE = "vf-module"; + + @Autowired + private ExceptionBuilder exceptionBuilder; + + @Autowired + private ExtractPojosForBB extractPojosForBB; + + @Autowired + private AbstractCDSProcessingBBUtils cdsDispather; + + @Autowired + private GeneratePayloadForCds generatePayloadForCds; + + @Override + public Boolean understand(ControllerContext<BuildingBlockExecution> context) { + String scope = context.getControllerScope(); + return CDS_ACTOR.equalsIgnoreCase(context.getControllerActor()) + && (VNF_SCOPE.equalsIgnoreCase(scope) || VF_MODULE_SCOPE.equalsIgnoreCase(scope)); + } + + @Override + public Boolean ready(ControllerContext<BuildingBlockExecution> context) { + return true; + } + + @Override + public void prepare(ControllerContext<BuildingBlockExecution> context) { + BuildingBlockExecution buildingBlockExecution = context.getExecution(); + try { + AbstractCDSPropertiesBean abstractCDSPropertiesBean = + generatePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution); + buildingBlockExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean); + } catch (Exception ex) { + logger.error("An exception occurred when creating payload for CDS request", ex); + exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 7000, ex); + } + } + + @Override + public void run(ControllerContext<BuildingBlockExecution> context) { + BuildingBlockExecution obj = context.getExecution(); + cdsDispather.constructExecutionServiceInputObject(obj); + cdsDispather.sendRequestToCDSClient(obj); + } +} 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 2284c4af1a..9ee0104a5f 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 @@ -94,6 +94,7 @@ import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.util.CollectionUtils; @Component public class WorkflowAction { @@ -410,15 +411,17 @@ public class WorkflowAction { } } - if (flowsToExecute == null || flowsToExecute.isEmpty()) { + if (CollectionUtils.isEmpty(flowsToExecute)) { throw new IllegalStateException("Macro did not come up with a valid execution path."); } + List<String> flowNames = new ArrayList<>(); logger.info("List of BuildingBlocks to execute:"); - for (ExecuteBuildingBlock ebb : flowsToExecute) { + + flowsToExecute.forEach(ebb -> { logger.info(ebb.getBuildingBlock().getBpmnFlowName()); flowNames.add(ebb.getBuildingBlock().getBpmnFlowName()); - } + }); if (!isResume) { bbInputSetupUtils.persistFlowExecutionPath(requestId, flowsToExecute); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java index 79bce8a1f4..142cb53ed8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java @@ -26,8 +26,10 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mock; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable; +import org.onap.so.client.cds.AbstractCDSProcessingBBUtils; import org.onap.so.client.exception.ExceptionBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; @@ -35,7 +37,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {CdsControllerDE.class, ExceptionBuilder.class}) +@ContextConfiguration(classes = {CdsControllerDE.class, ExceptionBuilder.class, AbstractCDSProcessingBBUtils.class}) public class CdsControllerDETest { @Autowired @@ -47,6 +49,9 @@ public class CdsControllerDETest { @MockBean private ControllerPreparable<DelegateExecution> preparable; + @Mock + private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils; + @Before public void setUp() { when(controllerContext.getControllerActor()).thenReturn("cds"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBBTest.java new file mode 100644 index 0000000000..24bbc78afb --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBBTest.java @@ -0,0 +1,197 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 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. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.flowspecific.tasks; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Test; +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.common.DelegateExecutionImpl; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.cds.*; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.Resources; +import org.onap.so.serviceinstancebeans.Service; +import org.onap.so.serviceinstancebeans.Vnfs; +import org.springframework.beans.factory.annotation.Autowired; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.*; + +public class GenericCDSProcessingBBTest extends BaseTaskTest { + + private static final String VNF_SCOPE = "vnf"; + private static final String TEST_VNF_MODEL_CUSTOMIZATION_UUID = "23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce4"; + private static final String DEPLOY_ACTION_FOR_CDS = "configDeploy"; + private static final String GENERAL_BLOCK_EXECUTION_MAP_KEY = "gBBInput"; + private static final String BUILDING_BLOCK = "buildingBlock"; + private static final String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e"; + private static final String EXECUTION_OBJECT = "executionObject"; + private static final String BLUEPRINT_NAME = "test"; + private static final String BLUEPRINT_VERSION = "1.0.0"; + + @InjectMocks + private GenericCDSProcessingBB controllerRunnable; + + @Mock + private AbstractCDSProcessingBBUtils cdsDispather; + + @Mock + private GeneratePayloadForCds generatePayloadForCds; + + private BuildingBlockExecution buildingBlockExecution; + + private ExecuteBuildingBlock executeBuildingBlock; + + @Before + public void setUp() { + buildingBlockExecution = createBuildingBlockExecution(); + executeBuildingBlock = new ExecuteBuildingBlock(); + } + + @Test + public void testExecutionObjectCreationForVnf() throws Exception { + // given + ControllerContext<BuildingBlockExecution> controllerContext = new ControllerContext<>(); + controllerContext.setExecution(buildingBlockExecution); + controllerContext.setControllerActor("CDS"); + controllerContext.setControllerScope("vnf"); + setScopeAndAction(VNF_SCOPE, DEPLOY_ACTION_FOR_CDS); + AbstractCDSPropertiesBean cdsBean = prepareCDSBean(); + + doReturn(cdsBean).when(generatePayloadForCds).buildCdsPropertiesBean(buildingBlockExecution); + doNothing().when(cdsDispather).constructExecutionServiceInputObject(buildingBlockExecution); + doNothing().when(cdsDispather).sendRequestToCDSClient(buildingBlockExecution); + + // when + Boolean isUnderstandable = controllerRunnable.understand(controllerContext); + Boolean isReady = controllerRunnable.ready(controllerContext); + controllerRunnable.prepare(controllerContext); + controllerRunnable.run(controllerContext); + + // verify + assertEquals(isUnderstandable, true); + assertEquals(isReady, true); + AbstractCDSPropertiesBean executionObject = buildingBlockExecution.getVariable(EXECUTION_OBJECT); + assertNotNull(executionObject); + assertThat(executionObject).isInstanceOf(AbstractCDSPropertiesBean.class); + assertEquals(BLUEPRINT_NAME, executionObject.getBlueprintName()); + assertEquals(BLUEPRINT_VERSION, executionObject.getBlueprintVersion()); + assertEquals(TEST_MSO_REQUEST_ID, executionObject.getRequestId()); + assertNotNull(executionObject.getRequestObject()); + } + + private AbstractCDSPropertiesBean prepareCDSBean() { + AbstractCDSPropertiesBean cdsBean = new AbstractCDSPropertiesBean(); + cdsBean.setBlueprintName(BLUEPRINT_NAME); + cdsBean.setBlueprintVersion(BLUEPRINT_VERSION); + cdsBean.setRequestId(TEST_MSO_REQUEST_ID); + cdsBean.setRequestObject("requestObject"); + + return cdsBean; + } + + private GeneralBuildingBlock createGeneralBuildingBlock() { + GeneralBuildingBlock generalBuildingBlock = new GeneralBuildingBlock(); + RequestContext requestContext = new RequestContext(); + RequestParameters requestParameters = new RequestParameters(); + requestParameters.setUserParams(createRequestParameters()); + requestContext.setRequestParameters(requestParameters); + requestContext.setMsoRequestId(TEST_MSO_REQUEST_ID); + generalBuildingBlock.setRequestContext(requestContext); + return generalBuildingBlock; + } + + private List<Map<String, Object>> createRequestParameters() { + List<Map<String, Object>> userParams = new ArrayList<>(); + Map<String, Object> userParamMap = new HashMap<>(); + userParamMap.put("service", getUserParams()); + userParams.add(userParamMap); + return userParams; + } + + private Service getUserParams() { + Service service = new Service(); + Resources resources = new Resources(); + resources.setVnfs(createVnfList()); + service.setResources(resources); + return service; + } + + private List<Vnfs> createVnfList() { + List<Map<String, String>> instanceParamsListSearchedVnf = new ArrayList<>(); + Map<String, String> instanceParam = new HashMap<>(); + instanceParam.put("sec_group", "sec_group"); + instanceParam.put("net_id", "acl-cloud-region"); + instanceParamsListSearchedVnf.add(instanceParam); + Vnfs searchedVnf = createVnf(instanceParamsListSearchedVnf); + List<Vnfs> vnfList = new ArrayList<>(); + vnfList.add(searchedVnf); + return vnfList; + } + + private Vnfs createVnf(List<Map<String, String>> instanceParamsList) { + Vnfs vnf = new Vnfs(); + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationId(TEST_VNF_MODEL_CUSTOMIZATION_UUID); + vnf.setModelInfo(modelInfo); + vnf.setInstanceParams(instanceParamsList); + return vnf; + } + + private BuildingBlockExecution createBuildingBlockExecution() { + DelegateExecution execution = new DelegateExecutionFake(); + execution.setVariable(GENERAL_BLOCK_EXECUTION_MAP_KEY, createGeneralBuildingBlock()); + return new DelegateExecutionImpl(execution); + } + + private void setScopeAndAction(String scope, String action) { + BuildingBlock buildingBlock = new BuildingBlock(); + buildingBlock.setBpmnScope(scope); + buildingBlock.setBpmnAction(action); + executeBuildingBlock.setBuildingBlock(buildingBlock); + buildingBlockExecution.setVariable(BUILDING_BLOCK, executeBuildingBlock); + } +} |