Search in sources :

Example 51 with BuildingBlock

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

the class WorkflowActionBBTasksUpdateReqDbTest method getUpdatedRequestTest.

@Test
public void getUpdatedRequestTest() throws Exception {
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
    BuildingBlock bb1 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB");
    ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(bb1);
    flowsToExecute.add(ebb1);
    BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB");
    ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2);
    flowsToExecute.add(ebb2);
    String requestId = "requestId";
    execution.setVariable("mso-request-id", requestId);
    execution.setVariable("flowsToExecute", flowsToExecute);
    int currentSequence = 2;
    String expectedStatusMessage = "Execution of CreateNetworkBB has completed successfully, next invoking ActivateNetworkBB (Execution Path progress: BBs completed = 1; BBs remaining = 1).";
    Long expectedLong = new Long(52);
    InfraActiveRequests mockedRequest = new InfraActiveRequests();
    doReturn(mockedRequest).when(requestsDbClient).getInfraActiveRequestbyRequestId(isA(String.class));
    InfraActiveRequests actual = workflowActionBBTasks.getUpdatedRequest(execution, currentSequence);
    assertEquals(expectedStatusMessage, actual.getFlowStatus());
    assertEquals(expectedLong, actual.getProgress());
}
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) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 52 with BuildingBlock

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

the class WorkflowActionBBTasksTest method postProcessingExecuteBBActivateVfModuleNotReplaceInstanceTest.

@Test
public void postProcessingExecuteBBActivateVfModuleNotReplaceInstanceTest() throws CloneNotSupportedException {
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setServiceInstanceId("1");
    workflowResourceIds.setVnfId("1");
    BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
    ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);
    ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds);
    ebbActivateVfModule.setResourceId("1");
    ServiceInstance service = new ServiceInstance();
    service.setServiceInstanceName("name");
    service.setModelVersionId("1");
    doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1");
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfName("name");
    vnf.setModelCustomizationId("1");
    doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1");
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleName("name");
    vfModule.setModelCustomizationId("1");
    doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1");
    List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
    org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
    vnfc.setModelInvariantId("1");
    vnfc.setVnfcName("name");
    vnfc.setModelCustomizationId("2");
    vnfcs.add(vnfc);
    doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
    CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization();
    ConfigurationResource configuration = new ConfigurationResource();
    configuration.setToscaNodeType("FabricConfiguration");
    configuration.setModelUUID("1");
    vfModuleCustomization.setConfigurationResource(configuration);
    doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2");
    prepareDelegateExecution();
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    flowsToExecute.add(ebbActivateVfModule);
    execution.setVariable("requestAction", "createInstance");
    execution.setVariable("completed", true);
    ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class);
    ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class);
    ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
    workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute);
    verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), bbCaptor.capture(), listCaptor.capture());
    assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed"));
    assertEquals(2, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size());
    assertEquals("2", ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).get(1)).getConfigurationResourceKeys().getCvnfcCustomizationUUID());
    assertEquals("AddFabricConfigurationBB", ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).get(1)).getBuildingBlock().getBpmnFlowName());
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) VfModule(org.onap.aai.domain.yang.VfModule) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ArrayList(java.util.ArrayList) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 53 with BuildingBlock

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

the class WorkflowActionBBTasksTest method postProcessingExecuteBBActivateVfModuleReplaceInstanceHasNoConfigurationTest.

@Test
public void postProcessingExecuteBBActivateVfModuleReplaceInstanceHasNoConfigurationTest() throws CloneNotSupportedException {
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setServiceInstanceId("1");
    workflowResourceIds.setVnfId("1");
    BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
    ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);
    ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds);
    ebbActivateVfModule.setResourceId("1");
    ServiceInstance service = new ServiceInstance();
    service.setServiceInstanceName("name");
    service.setModelVersionId("1");
    doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1");
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfName("name");
    vnf.setModelCustomizationId("1");
    doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1");
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleName("name");
    vfModule.setModelCustomizationId("1");
    doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1");
    List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
    org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
    vnfc.setModelInvariantId("1");
    vnfc.setVnfcName("name");
    vnfc.setModelCustomizationId("2");
    vnfcs.add(vnfc);
    doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
    CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization();
    ConfigurationResource configuration = new ConfigurationResource();
    configuration.setToscaNodeType("FabricConfiguration");
    configuration.setModelUUID("1");
    vfModuleCustomization.setConfigurationResource(configuration);
    doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2");
    prepareDelegateExecution();
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    flowsToExecute.add(ebbActivateVfModule);
    ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class);
    ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class);
    ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
    execution.setVariable("requestAction", "replaceInstance");
    execution.setVariable("completed", true);
    workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute);
    verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), bbCaptor.capture(), listCaptor.capture());
    assertEquals(true, executionCaptor.getAllValues().get(0).getVariable("completed"));
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) VfModule(org.onap.aai.domain.yang.VfModule) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ArrayList(java.util.ArrayList) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 54 with BuildingBlock

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

the class WorkflowActionBBTasksTest method rollbackExecutionRollbackInPlaceSoftwareUpdateTest.

@Test
public void rollbackExecutionRollbackInPlaceSoftwareUpdateTest() {
    execution.setVariable("isRollback", false);
    execution.setVariable("handlingCode", "Rollback");
    execution.setVariable("requestAction", EMPTY_STRING);
    execution.setVariable("resourceName", EMPTY_STRING);
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity");
    ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
    flowsToExecute.add(ebb1);
    BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("VNFCheckInMaintFlagActivity");
    ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
    flowsToExecute.add(ebb2);
    BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("VNFSetInMaintFlagActivity");
    ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
    flowsToExecute.add(ebb3);
    BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("VNFCheckClosedLoopDisabledFlagActivity");
    ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
    flowsToExecute.add(ebb4);
    BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("VNFSetClosedLoopDisabledFlagActivity");
    ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5);
    flowsToExecute.add(ebb5);
    BuildingBlock buildingBlock6 = new BuildingBlock().setBpmnFlowName("VNFLockActivity");
    ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock6);
    flowsToExecute.add(ebb6);
    BuildingBlock buildingBlock7 = new BuildingBlock().setBpmnFlowName("VNFUpgradePreCheckActivity");
    ExecuteBuildingBlock ebb7 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock7);
    flowsToExecute.add(ebb7);
    BuildingBlock buildingBlock8 = new BuildingBlock().setBpmnFlowName("VNFQuiesceTrafficActivity");
    ExecuteBuildingBlock ebb8 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock8);
    flowsToExecute.add(ebb8);
    BuildingBlock buildingBlock9 = new BuildingBlock().setBpmnFlowName("VNFStopActivity");
    ExecuteBuildingBlock ebb9 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock9);
    flowsToExecute.add(ebb9);
    BuildingBlock buildingBlock10 = new BuildingBlock().setBpmnFlowName("VNFSnapShotActivity");
    ExecuteBuildingBlock ebb10 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock10);
    flowsToExecute.add(ebb10);
    execution.setVariable("flowsToExecute", flowsToExecute);
    execution.setVariable("gCurrentSequence", 10);
    workflowActionBBTasks.rollbackExecutionPath(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEquals("VNFStartActivity", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
    assertEquals("VNFResumeTrafficActivity", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
    assertEquals("VNFUnlockActivity", ebbs.get(2).getBuildingBlock().getBpmnFlowName());
    assertEquals("VNFUnsetClosedLoopDisabledFlagActivity", ebbs.get(3).getBuildingBlock().getBpmnFlowName());
    assertEquals("VNFUnsetInMaintFlagActivity", ebbs.get(4).getBuildingBlock().getBpmnFlowName());
    assertEquals(0, execution.getVariable("gCurrentSequence"));
    assertEquals(5, 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 55 with BuildingBlock

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

the class WorkflowActionBBTasksTest method rollbackExecutionRollbackConfigModifyTest.

@Test
public void rollbackExecutionRollbackConfigModifyTest() {
    execution.setVariable("isRollback", false);
    execution.setVariable("handlingCode", "Rollback");
    execution.setVariable("requestAction", EMPTY_STRING);
    execution.setVariable("resourceName", EMPTY_STRING);
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity");
    ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
    flowsToExecute.add(ebb1);
    BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("VNFCheckInMaintFlagActivity");
    ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
    flowsToExecute.add(ebb2);
    BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("VNFSetInMaintFlagActivity");
    ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
    flowsToExecute.add(ebb3);
    BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("VNFCheckClosedLoopDisabledFlagActivity");
    ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
    flowsToExecute.add(ebb4);
    BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("VNFSetClosedLoopDisabledFlagActivity");
    ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5);
    flowsToExecute.add(ebb5);
    BuildingBlock buildingBlock6 = new BuildingBlock().setBpmnFlowName("VNFHealthCheckActivity");
    ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock6);
    flowsToExecute.add(ebb6);
    execution.setVariable("flowsToExecute", flowsToExecute);
    execution.setVariable("gCurrentSequence", 6);
    workflowActionBBTasks.rollbackExecutionPath(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEquals("VNFUnsetClosedLoopDisabledFlagActivity", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
    assertEquals("VNFUnsetInMaintFlagActivity", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
    assertEquals(0, execution.getVariable("gCurrentSequence"));
    assertEquals(2, 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)

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