Search in sources :

Example 46 with BuildingBlock

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

the class ExecuteBuildingBlockBuilder method buildExecuteBuildingBlock.

protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId, Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration, ReplaceInstanceRelatedInformation replaceInfo) {
    BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString()).setIsVirtualLink(isVirtualLink).setVirtualLinkKey(virtualLinkKey).setKey(Optional.ofNullable(resource).map(Resource::getResourceId).orElse(""));
    Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(buildingBlock::setBpmnAction);
    Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(buildingBlock::setBpmnScope);
    String oldVolumeGroupName = "";
    if (replaceInfo != null) {
        oldVolumeGroupName = replaceInfo.getOldVolumeGroupName();
    }
    if (resource != null && (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE) || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) {
        logger.debug("Setting resourceId to volume group id for volume group flow on replace");
        resourceId = workflowResourceIds.getVolumeGroupId();
    }
    ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion).setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock).setRequestDetails(requestDetails).setOldVolumeGroupName(oldVolumeGroupName);
    if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) {
        ConfigurationResourceKeys configurationResourceKeys = getConfigurationResourceKeys(resource, vnfcName);
        executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys);
    }
    return executeBuildingBlock;
}
Also used : BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)

Example 47 with BuildingBlock

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

the class WorkflowActionTest method sortExecutionPathByObjectForVlanTaggingCreateTest.

@Test
public void sortExecutionPathByObjectForVlanTaggingCreateTest() throws Exception {
    List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
    BuildingBlock bb = new BuildingBlock().setBpmnFlowName("AssignNetworkBB").setKey("0");
    ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb);
    executeFlows.add(ebb);
    BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("AssignNetworkBB").setKey("1");
    ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2);
    executeFlows.add(ebb2);
    BuildingBlock bb3 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB").setKey("0");
    ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(bb3);
    executeFlows.add(ebb3);
    BuildingBlock bb4 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB").setKey("1");
    ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(bb4);
    executeFlows.add(ebb4);
    BuildingBlock bb5 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB").setKey("0");
    ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(bb5);
    executeFlows.add(ebb5);
    BuildingBlock bb6 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB").setKey("1");
    ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(bb6);
    executeFlows.add(ebb6);
    List<ExecuteBuildingBlock> sorted = workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows, "createInstance");
    assertEqualsBulkFlowName(sorted, "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB");
}
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) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 48 with BuildingBlock

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

the class MultiStageSkipListenerTest method testProcessMultiStageSkip.

@Test
public void testProcessMultiStageSkip() {
    String vfModuleId = "vfModuleId";
    String vnfId = "vnfId";
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setServiceInstanceId("serviceInstanceId");
    workflowResourceIds.setVnfId(vnfId);
    BuildingBlock bb = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
    ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setResourceId(vfModuleId).setBuildingBlock(bb).setWorkflowResourceIds(workflowResourceIds);
    flowsToExecute.add(ebb);
    flowsToExecute.add(new ExecuteBuildingBlock());
    flowsToExecute.add(new ExecuteBuildingBlock());
    BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
    org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
    vfModule.setVfModuleId(vfModuleId);
    org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
    vnf.setModelCustomizationId("modelCustomizationUUID");
    VnfResourceCustomization vnfCust = new VnfResourceCustomization();
    vnfCust.setModelCustomizationUUID("modelCustomizationUUID");
    vnfCust.setMultiStageDesign("true");
    when(catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(vnf.getModelCustomizationId())).thenReturn(vnfCust);
    when(bbInputSetupUtils.getAAIVfModule(eq(vnfId), eq(vfModuleId))).thenReturn(null);
    when(bbInputSetupUtils.getAAIGenericVnf(eq(vnfId))).thenReturn(vnf);
    multiStageSkipListener.run(flowsToExecute, flowsToExecute.get(0), execution);
    assertEquals("Flows should only have Assign", flowsToExecute.size(), 1);
    assertEquals("Flows should only have Assign", flowsToExecute.get(0).getBuildingBlock().getBpmnFlowName(), "AssignVfModuleBB");
}
Also used : BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ArrayList(java.util.ArrayList) DelegateExecutionFake(org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Example 49 with BuildingBlock

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

the class SkipConfigVnfListenerTest method createExecuteBuildingBlock.

private ExecuteBuildingBlock createExecuteBuildingBlock() {
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelUuid(MODEL_UUID);
    RequestDetails requestDetails = new RequestDetails();
    requestDetails.setModelInfo(modelInfo);
    ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
    BuildingBlock buildingBlock = new BuildingBlock();
    buildingBlock.setKey(VNF_CUSTOMIZATION_UUID);
    executeBuildingBlock.setBuildingBlock(buildingBlock);
    executeBuildingBlock.setRequestDetails(requestDetails);
    return executeBuildingBlock;
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails)

Example 50 with BuildingBlock

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

the class WorkflowActionBBFailureTest method updateRequestStatusToFailedRollbackFabric.

@Test
public void updateRequestStatusToFailedRollbackFabric() {
    BuildingBlock bb = new BuildingBlock().setBpmnFlowName("UnassignFabricConfigurationBB");
    ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb);
    execution.setVariable("buildingBlock", ebb);
    execution.setVariable("mso-request-id", "123");
    execution.setVariable("isRollbackComplete", false);
    execution.setVariable("isRollback", true);
    InfraActiveRequests req = new InfraActiveRequests();
    req.setStatusMessage("PINC failure.");
    WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
    execution.setVariable("WorkflowException", wfe);
    doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
    doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
    workflowActionBBFailure.updateRequestStatusToFailed(execution);
    String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
    assertEquals("error in rollback", errorMsg);
    assertEquals("PINC failure. Warning: The vf-module is active but configuration was not removed completely for one or more VMs.", req.getStatusMessage());
    assertEquals(Status.FAILED.toString(), req.getRequestStatus());
}
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) WorkflowException(org.onap.so.bpmn.core.WorkflowException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

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