Search in sources :

Example 26 with BuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.

the class SkipCDSBuildingBlockListenerTest method before.

@Before
public void before() {
    executeBuildingBlock = new ExecuteBuildingBlock();
    buildingBlock = new BuildingBlock();
    ArrayList<Resource> resources = new ArrayList<>();
    Resource service = new Resource(WorkflowType.SERVICE, SERVICE_MODEL_VERSION_ID, false, null);
    service.setModelVersionId(SERVICE_MODEL_VERSION_ID);
    resources.add(service);
    Resource vnf = new Resource(WorkflowType.VNF, VNF_MODEL_CUSTOMIZATION_ID, false, null);
    vnf.setModelCustomizationId(VNF_MODEL_CUSTOMIZATION_ID);
    resources.add(vnf);
    Resource vfModule = new Resource(WorkflowType.VFMODULE, VF_MODULE_CUSTOMIZATION_ID, false, null);
    vfModule.setModelCustomizationId(VF_MODULE_CUSTOMIZATION_ID);
    resources.add(vfModule);
    Resource pnf = new Resource(WorkflowType.PNF, PNF_CUSTOMIZATION_ID, false, null);
    pnf.setModelCustomizationId(PNF_CUSTOMIZATION_ID);
    resources.add(pnf);
    buildingBlockExecution.setVariable("resources", resources);
    vnfCust = new VnfResourceCustomization();
    vfCust = new VfModuleCustomization();
    pnfResourceCustomization = new PnfResourceCustomization();
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ArrayList(java.util.ArrayList) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Before(org.junit.Before)

Example 27 with BuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.

the class WorkflowActionBBTasksTest method rollbackExecutionPathUnfinishedFlowTest.

@Test
public void rollbackExecutionPathUnfinishedFlowTest() {
    execution.setVariable("handlingCode", "Rollback");
    execution.setVariable("isRollback", false);
    execution.setVariable("requestAction", EMPTY_STRING);
    execution.setVariable("resourceName", EMPTY_STRING);
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
    ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
    flowsToExecute.add(ebb1);
    BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
    ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
    flowsToExecute.add(ebb2);
    BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
    ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
    flowsToExecute.add(ebb3);
    execution.setVariable("flowsToExecute", flowsToExecute);
    execution.setVariable("gCurrentSequence", 2);
    doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
    workflowActionBBTasks.rollbackExecutionPath(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeleteVfModuleBB");
    assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "UnassignVfModuleBB");
    assertEquals(0, execution.getVariable("gCurrentSequence"));
    assertEquals(0, execution.getVariable("retryCount"));
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ArrayList(java.util.ArrayList) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ArrayList(java.util.ArrayList) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 28 with BuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.

the class WorkflowActionBBTasksTest method rollbackExecutionRollbackToCreatedTest.

@Test
public void rollbackExecutionRollbackToCreatedTest() {
    execution.setVariable("isRollback", false);
    execution.setVariable("handlingCode", "RollbackToCreated");
    execution.setVariable("requestAction", EMPTY_STRING);
    execution.setVariable("resourceName", EMPTY_STRING);
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
    ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
    flowsToExecute.add(ebb1);
    BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
    ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
    flowsToExecute.add(ebb2);
    BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
    ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
    flowsToExecute.add(ebb3);
    execution.setVariable("flowsToExecute", flowsToExecute);
    execution.setVariable("gCurrentSequence", 3);
    workflowActionBBTasks.rollbackExecutionPath(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEquals("DeactivateVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
    assertEquals(0, execution.getVariable("gCurrentSequence"));
    assertEquals(1, ebbs.size());
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ArrayList(java.util.ArrayList) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ArrayList(java.util.ArrayList) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 29 with BuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.

the class WorkflowActionBBTasksTest method rollbackExecutionPathTest.

@Test
public void rollbackExecutionPathTest() {
    execution.setVariable("handlingCode", "Rollback");
    execution.setVariable("isRollback", false);
    execution.setVariable("requestAction", EMPTY_STRING);
    execution.setVariable("resourceName", EMPTY_STRING);
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
    ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
    flowsToExecute.add(ebb1);
    BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
    ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
    flowsToExecute.add(ebb2);
    BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
    ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
    flowsToExecute.add(ebb3);
    execution.setVariable("flowsToExecute", flowsToExecute);
    execution.setVariable("gCurrentSequence", 3);
    doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
    workflowActionBBTasks.rollbackExecutionPath(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeactivateVfModuleBB");
    assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "DeleteVfModuleBB");
    assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(), "UnassignVfModuleBB");
    assertEquals(0, execution.getVariable("gCurrentSequence"));
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ArrayList(java.util.ArrayList) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ArrayList(java.util.ArrayList) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 30 with BuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.

the class GeneratePayloadForCds method buildCdsPropertiesBean.

/**
 * Build properties like (blueprint name, version, action etc..) along with the request payload for vnf, vf-module
 * and service.
 *
 * @param execution - A building block execution object.
 * @return AbstractCDSPropertiesBean - A POJO which contains CDS related information.
 * @throws PayloadGenerationException - Throw an exception if it fails to build payload for CDS.
 */
public AbstractCDSPropertiesBean buildCdsPropertiesBean(BuildingBlockExecution execution) throws PayloadGenerationException {
    ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
    BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
    final String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId();
    final String scope = buildingBlock.getBpmnScope();
    final String action = buildingBlock.getBpmnAction();
    CDSRequestProvider requestProvider = getRequestProviderByScope(scope);
    requestProvider.setExecutionObject(execution);
    final String requestPayload = requestProvider.buildRequestPayload(action).orElseThrow(() -> new PayloadGenerationException("Failed to build payload for CDS"));
    return prepareAndSetCdsPropertyBean(requestProvider, requestPayload, requestId, action, DEFAULT_SYNC_MODE);
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) PayloadGenerationException(org.onap.so.client.exception.PayloadGenerationException)

Aggregations

BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)66 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)64 Test (org.junit.Test)51 ArrayList (java.util.ArrayList)30 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)30 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)28 File (java.io.File)24 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)22 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)22 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)19 List (java.util.List)18 Service (org.onap.so.db.catalog.beans.Service)18 BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys)15 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)15 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)12 GenericVnf (org.onap.aai.domain.yang.GenericVnf)11 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)11 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)11 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)10 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)10