Search in sources :

Example 41 with BuildingBlock

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

the class BBInputSetupPopulateMethodsTest method test_getGBBMacro_populateVfModule_shouldBeCalled.

@Test
public void test_getGBBMacro_populateVfModule_shouldBeCalled() throws Exception {
    // given
    GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockWithVnf.json"), GeneralBuildingBlock.class);
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
    GenericVnf aaiVnf = new GenericVnf();
    aaiVnf.setModelCustomizationId("modelCustId");
    Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
    lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
    executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName(AssignFlows.VF_MODULE.toString()).setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
    doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(service).when(bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
    doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
    doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(any(String.class));
    // when
    SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
    // then
    verify(SPY_bbInputSetup, times(1)).populateVfModule(any(BBInputSetupParameter.class));
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) File(java.io.File) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) Test(org.junit.Test)

Example 42 with BuildingBlock

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

the class ExecuteBuildingBlockRainyDayTest method queryRainyDayTableRollbackToCreatedNoConfiguration.

@Test
public void queryRainyDayTableRollbackToCreatedNoConfiguration() throws Exception {
    customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
    serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
    vnf.setVnfType("vnft1");
    BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
    ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock);
    delegateExecution.setVariable("buildingBlock", executeBuildingBlock);
    delegateExecution.setVariable("aLaCarte", true);
    delegateExecution.setVariable("suppressRollback", false);
    delegateExecution.setVariable("WorkflowExceptionCode", "7000");
    RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
    rainyDayHandlerStatus.setErrorCode("7000");
    rainyDayHandlerStatus.setFlowName("AddFabricConfigurationBB");
    rainyDayHandlerStatus.setServiceType("st1");
    rainyDayHandlerStatus.setVnfType("vnft1");
    rainyDayHandlerStatus.setPolicy("RollbackToCreatedNoConfiguration");
    rainyDayHandlerStatus.setWorkStep(ASTERISK);
    rainyDayHandlerStatus.setSecondaryPolicy("Abort");
    doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AddFabricConfigurationBB", "st1", "vnft1", "7000", "*", "errorMessage", "*");
    executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true);
    assertEquals("RollbackToCreatedNoConfiguration", delegateExecution.getVariable("handlingCode"));
    assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), delegateExecution.getVariable("rollbackTargetState"));
}
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) RainyDayHandlerStatus(org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 43 with BuildingBlock

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

the class ExecuteBuildingBlockRainyDayTest method before.

@Before
public void before() {
    serviceInstance = setServiceInstance();
    customer = setCustomer();
    vnf = setGenericVnf();
    BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB");
    ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock);
    delegateExecution.setVariable("gBBInput", gBBInput);
    delegateExecution.setVariable("WorkflowException", new WorkflowException("", 7000, ""));
    delegateExecution.setVariable("buildingBlock", executeBuildingBlock);
    delegateExecution.setVariable("lookupKeyMap", lookupKeyMap);
    delegateExecution.setVariable("WorkflowException", new WorkflowException("processKey", 7000, "errorMessage"));
}
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) WorkflowException(org.onap.so.bpmn.core.WorkflowException) Before(org.junit.Before)

Example 44 with BuildingBlock

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

the class ExecuteActivityTest method buildBuildingBlock_Test.

@Test
public void buildBuildingBlock_Test() {
    BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
    assertEquals(bb.getBpmnFlowName(), "testActivityName");
    assertEquals(bb.getKey(), "");
}
Also used : BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) Test(org.junit.Test)

Example 45 with BuildingBlock

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

the class WorkflowActionBBTasks method rollbackExecutionPath.

/**
 * Rollback will only handle Create/Activate/Assign Macro flows. Execute layer will rollback the flow its currently
 * working on.
 */
public void rollbackExecutionPath(DelegateExecution execution) {
    final String action = (String) execution.getVariable(BBConstants.G_ACTION);
    final String resourceName = (String) execution.getVariable("resourceName");
    if (!(boolean) execution.getVariable("isRollback")) {
        List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
        List<ExecuteBuildingBlock> flowsToExecuteChangeBBs = flowsToExecute.stream().filter(buildingBlock -> buildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")).collect(Collectors.toList());
        List<ExecuteBuildingBlock> rollbackFlows = new ArrayList<>();
        int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
        int listSize = flowsToExecute.size();
        for (int i = listSize - 1; i >= 0; i--) {
            if (i > currentSequence - 1) {
                flowsToExecute.remove(i);
            } else {
                String flowName = flowsToExecute.get(i).getBuildingBlock().getBpmnFlowName();
                if (flowName.startsWith("Assign")) {
                    flowName = flowName.replaceFirst("Assign", "Unassign");
                } else if (flowName.startsWith("Create")) {
                    flowName = flowName.replaceFirst("Create", "Delete");
                } else if (flowName.startsWith("Activate")) {
                    flowName = flowName.replaceFirst("Activate", "Deactivate");
                } else if (flowName.startsWith("Add")) {
                    flowName = flowName.replaceFirst("Add", "Delete");
                } else if (flowName.startsWith("VNF")) {
                    if (flowName.startsWith("VNFSet")) {
                        flowName = flowName.replaceFirst("VNFSet", "VNFUnset");
                    } else if (flowName.startsWith("VNFLock")) {
                        flowName = flowName.replaceFirst("VNFLock", "VNFUnlock");
                    } else if (flowName.startsWith("VNFStop")) {
                        flowName = flowName.replaceFirst("VNFStop", "VNFStart");
                    } else if (flowName.startsWith("VNFQuiesce")) {
                        flowName = flowName.replaceFirst("VNFQuiesce", "VNFResume");
                    } else {
                        continue;
                    }
                } else {
                    continue;
                }
                flowsToExecute.get(i).getBuildingBlock().setBpmnFlowName(flowName);
                rollbackFlows.add(flowsToExecute.get(i));
            }
        }
        String handlingCode = (String) execution.getVariable(HANDLINGCODE);
        List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>(rollbackFlows);
        if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode) || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)) {
            for (ExecuteBuildingBlock rollbackFlow : rollbackFlows) {
                if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Unassign") && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) {
                    rollbackFlowsFiltered.remove(rollbackFlow);
                } else if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Delete") && ((!rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") && (ROLLBACKTOCREATED.equals(handlingCode) || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode))) || (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") && ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)))) {
                    rollbackFlowsFiltered.remove(rollbackFlow);
                }
            }
        }
        List<ExecuteBuildingBlock> rollbackFlowsFilteredNonChangeBBs = new ArrayList<>();
        if (action.equals(REPLACEINSTANCE) && resourceName.equals(VFMODULE)) {
            for (ExecuteBuildingBlock executeBuildingBlock : rollbackFlowsFiltered) {
                if (!executeBuildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")) {
                    rollbackFlowsFilteredNonChangeBBs.add(executeBuildingBlock);
                }
            }
            rollbackFlowsFiltered.clear();
            rollbackFlowsFiltered.addAll(flowsToExecuteChangeBBs);
            rollbackFlowsFiltered.addAll(rollbackFlowsFilteredNonChangeBBs);
        }
        workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
        execution.setVariable("isRollbackNeeded", !rollbackFlows.isEmpty());
        execution.setVariable("flowsToExecute", rollbackFlowsFiltered);
        execution.setVariable(HANDLINGCODE, "PreformingRollback");
        execution.setVariable("isRollback", true);
        execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0);
        execution.setVariable(RETRY_COUNT, 0);
    } else {
        workflowAction.buildAndThrowException(execution, "Rollback has already been called. Cannot rollback a request that is currently in the rollback state.");
    }
}
Also used : ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) BBConstants(org.onap.so.bpmn.common.BBConstants) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) Configuration(org.onap.aaiclient.client.aai.entities.Configuration) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) VfModule(org.onap.aai.domain.yang.VfModule) Vnfc(org.onap.aai.domain.yang.Vnfc) ArrayList(java.util.ArrayList) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) RequestsDbListenerRunner(org.onap.so.bpmn.common.listener.db.RequestsDbListenerRunner) FlowManipulatorListenerRunner(org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) EntityNotFoundException(javax.persistence.EntityNotFoundException) InstanceGroup(org.onap.aai.domain.yang.InstanceGroup) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) L3Network(org.onap.aai.domain.yang.L3Network) GenericVnf(org.onap.aai.domain.yang.GenericVnf) BBInputSetupUtils(org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils) RequestsDbClient(org.onap.so.db.request.client.RequestsDbClient) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) Logger(org.slf4j.Logger) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) Timestamp(java.sql.Timestamp) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) CatalogDbClient(org.onap.so.db.catalog.client.CatalogDbClient) WorkflowContextHolder(org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) Component(org.springframework.stereotype.Component) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) Environment(org.springframework.core.env.Environment) ModelType(org.onap.so.serviceinstancebeans.ModelType) Optional(java.util.Optional) WorkflowCallbackResponse(org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList)

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