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());
}
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());
}
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"));
}
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());
}
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());
}
Aggregations