use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.
the class WorkflowActionTest method selectExecutionListServiceMacroCreateWithMultipleSameModelVnfAndVfModules.
@Test
public void selectExecutionListServiceMacroCreateWithMultipleSameModelVnfAndVfModules() throws Exception {
String gAction = "createInstance";
String resource = "Service";
String bpmnRequest = readBpmnRequestFromFile(MACRO_CREATE_SERVICE_MULTIPLE_SAME_MODEL_VNF_VFMODULE);
initExecution(gAction, bpmnRequest, false);
execution.setVariable("requestUri", "v7/serviceInstances");
execution.setVariable("serviceInstanceId", UUID.randomUUID().toString());
// Service-Macro-Create
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "ControllerExecutionBB", "AssignPnfBB", "WaitForPnfReadyBB", "ControllerExecutionBB", "ControllerExecutionBB", "ActivatePnfBB", "CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ControllerExecutionBB", "ActivateVnfBB", "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
orchFlows.get(6).setBpmnAction("config-assign");
orchFlows.get(6).setBpmnScope("vnf");
orchFlows.get(9).setBpmnAction("config-assign");
orchFlows.get(9).setBpmnScope("pnf");
orchFlows.get(10).setBpmnAction("config-deploy");
orchFlows.get(10).setBpmnScope("pnf");
orchFlows.get(18).setBpmnAction("config-deploy");
orchFlows.get(18).setBpmnScope("vnf");
northBoundRequest.setOrchestrationFlowList(orchFlows);
Service service = new Service();
service.setModelUUID("f2444885-3c76-4ddc-8668-7741c0631495");
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
vfModuleCustomization.setModelCustomizationUUID("3bd19000-6d21-49f1-9eb3-ea76a6eac5e0");
vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
vfModule.setVolumeHeatTemplate(new HeatTemplate());
vfModuleCustomization.setVfModule(vfModule);
VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
vfModuleCustomization2.setModelCustomizationUUID("83677d89-428a-407b-b4ec-738e68275d84");
vfModuleCustomization2.setHeatEnvironment(new HeatEnvironment());
org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
vfModule2.setModuleHeatTemplate(new HeatTemplate());
vfModuleCustomization2.setVfModule(vfModule2);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "DEFAULT")).thenReturn(northBoundRequest);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("3bd19000-6d21-49f1-9eb3-ea76a6eac5e0")).thenReturn(vfModuleCustomization);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("83677d89-428a-407b-b4ec-738e68275d84")).thenReturn(vfModuleCustomization2);
when(catalogDbClient.getServiceByID("f2444885-3c76-4ddc-8668-7741c0631495")).thenReturn(service);
Resource serviceResource = new Resource(WorkflowType.SERVICE, "f2444885-3c76-4ddc-8668-7741c0631495", false, null);
Resource vnfResource1 = new Resource(WorkflowType.VNF, "0d0ba1ee-6b7f-47fe-8266-2967993b2c08", false, serviceResource);
vnfResource1.setInstanceName("vnf-instanceName-1");
Resource vfmResource1 = new Resource(WorkflowType.VFMODULE, "3bd19000-6d21-49f1-9eb3-ea76a6eac5e0", false, vnfResource1);
vfmResource1.setInstanceName("demo-network-1");
Resource vfmResource2 = new Resource(WorkflowType.VFMODULE, "83677d89-428a-407b-b4ec-738e68275d84", false, vnfResource1);
vfmResource2.setInstanceName("demo-1");
Resource vnfResource2 = new Resource(WorkflowType.VNF, "0d0ba1ee-6b7f-47fe-8266-2967993b2c08", false, serviceResource);
vnfResource2.setInstanceName("vnf-instanceName-2");
Resource vfmResource3 = new Resource(WorkflowType.VFMODULE, "83677d89-428a-407b-b4ec-738e68275d84", false, vnfResource2);
vfmResource3.setInstanceName("demo-2");
Resource vfmResource4 = new Resource(WorkflowType.VFMODULE, "83677d89-428a-407b-b4ec-738e68275d84", false, vnfResource2);
vfmResource4.setInstanceName("demo-3");
when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), any())).thenReturn(Arrays.asList(serviceResource, vnfResource1, vnfResource2, vfmResource1, vfmResource2, vfmResource3, vfmResource4));
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
Map<String, List<ExecuteBuildingBlock>> flowNamesToEbbList = ebbs.stream().collect(Collectors.groupingBy(e -> e.getBuildingBlock().getBpmnFlowName()));
assertEquals(1, flowNamesToEbbList.get("AssignServiceInstanceBB").size());
assertEquals(2, flowNamesToEbbList.get("AssignVnfBB").size());
assertEquals(4, flowNamesToEbbList.get("AssignVfModuleBB").size());
assertEquals(4, flowNamesToEbbList.get("ControllerExecutionBB").size());
assertEquals(4, flowNamesToEbbList.get("CreateVfModuleBB").size());
assertEquals(4, flowNamesToEbbList.get("ActivateVfModuleBB").size());
assertEquals(2, flowNamesToEbbList.get("ActivateVnfBB").size());
assertEquals(1, flowNamesToEbbList.get("ActivateServiceInstanceBB").size());
String vnfInstanceId1 = flowNamesToEbbList.get("AssignVnfBB").get(0).getWorkflowResourceIds().getVnfId();
String vnfInstanceId2 = flowNamesToEbbList.get("AssignVnfBB").get(1).getWorkflowResourceIds().getVnfId();
// should be 3 = 1 AssignVfModuleBB + 1 CreateVfModuleBB + 1 ActivateVfModuleBB
boolean allEbbsForVfModule1HaveCorrectParentVnfId = 3 == ebbs.stream().map(ExecuteBuildingBlock::getWorkflowResourceIds).filter(w -> "demo-network-1".equals(w.getVfModuleInstanceName()) && vnfInstanceId1.equals(w.getVnfId())).count();
boolean allEbbsForVfModule2HaveCorrectParentVnfId = 3 == ebbs.stream().map(ExecuteBuildingBlock::getWorkflowResourceIds).filter(w -> "demo-1".equals(w.getVfModuleInstanceName()) && vnfInstanceId1.equals(w.getVnfId())).count();
boolean allEbbsForVfModule3HaveCorrectParentVnfId = 3 == ebbs.stream().map(ExecuteBuildingBlock::getWorkflowResourceIds).filter(w -> "demo-2".equals(w.getVfModuleInstanceName()) && vnfInstanceId2.equals(w.getVnfId())).count();
boolean allEbbsForVfModule4HaveCorrectParentVnfId = 3 == ebbs.stream().map(ExecuteBuildingBlock::getWorkflowResourceIds).filter(w -> "demo-3".equals(w.getVfModuleInstanceName()) && vnfInstanceId2.equals(w.getVnfId())).count();
assertTrue(allEbbsForVfModule1HaveCorrectParentVnfId);
assertTrue(allEbbsForVfModule2HaveCorrectParentVnfId);
assertTrue(allEbbsForVfModule3HaveCorrectParentVnfId);
assertTrue(allEbbsForVfModule4HaveCorrectParentVnfId);
boolean controllerExecutionBBsforVnf1HaveCorrectVnfId = flowNamesToEbbList.get("ControllerExecutionBB").stream().filter(e -> vnfInstanceId1.equals(e.getWorkflowResourceIds().getVnfId())).map(ExecuteBuildingBlock::getBuildingBlock).map(BuildingBlock::getBpmnAction).collect(Collectors.toSet()).containsAll(Set.of("config-assign", "config-deploy"));
assertTrue(controllerExecutionBBsforVnf1HaveCorrectVnfId);
boolean controllerExecutionBBsforVnf2HaveCorrectVnfId = flowNamesToEbbList.get("ControllerExecutionBB").stream().filter(e -> vnfInstanceId2.equals(e.getWorkflowResourceIds().getVnfId())).map(ExecuteBuildingBlock::getBuildingBlock).map(BuildingBlock::getBpmnAction).collect(Collectors.toSet()).containsAll(Set.of("config-assign", "config-deploy"));
assertTrue(controllerExecutionBBsforVnf2HaveCorrectVnfId);
}
use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.
the class WorkflowActionTest method sortExecutionPathByObjectForVlanTaggingDeleteTest.
@Test
public void sortExecutionPathByObjectForVlanTaggingDeleteTest() throws Exception {
List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
BuildingBlock bb = new BuildingBlock().setBpmnFlowName("DeactivateNetworkBB").setKey("0");
ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb);
executeFlows.add(ebb);
BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("DeactivateNetworkBB").setKey("1");
ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2);
executeFlows.add(ebb2);
BuildingBlock bb3 = new BuildingBlock().setBpmnFlowName("DeleteNetworkBB").setKey("0");
ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(bb3);
executeFlows.add(ebb3);
BuildingBlock bb4 = new BuildingBlock().setBpmnFlowName("DeleteNetworkBB").setKey("1");
ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(bb4);
executeFlows.add(ebb4);
BuildingBlock bb5 = new BuildingBlock().setBpmnFlowName("UnassignNetworkBB").setKey("0");
ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(bb5);
executeFlows.add(ebb5);
BuildingBlock bb6 = new BuildingBlock().setBpmnFlowName("UnassignNetworkBB").setKey("1");
ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(bb6);
executeFlows.add(ebb6);
List<ExecuteBuildingBlock> sorted = workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows, "deleteInstance");
assertEqualsBulkFlowName(sorted, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB", "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB");
}
use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.
the class WorkflowActionBBTasksTest method rollbackExecutionRollbackToAssignedTest.
@Test
public void rollbackExecutionRollbackToAssignedTest() {
execution.setVariable("isRollback", false);
execution.setVariable("handlingCode", "RollbackToAssigned");
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);
workflowActionBBTasks.rollbackExecutionPath(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEquals("DeleteVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
assertEquals(0, execution.getVariable("gCurrentSequence"));
assertEquals(1, ebbs.size());
}
use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.
the class WorkflowActionBBTasksTest method getExecuteBBForConfigTest.
@Test
public void getExecuteBBForConfigTest() throws CloneNotSupportedException {
BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);
WorkflowResourceIds resourceIdsActivateVfModule = new WorkflowResourceIds();
resourceIdsActivateVfModule.setServiceInstanceId("test-service-inbstance-id");
resourceIdsActivateVfModule.setVnfId("test-vnf-id");
resourceIdsActivateVfModule.setVfModuleId("test-vf-module-id");
resourceIdsActivateVfModule.setConfigurationId("");
RequestDetails requestDetails = new RequestDetails();
ebbActivateVfModule.setApiVersion("7");
ebbActivateVfModule.setaLaCarte(true);
ebbActivateVfModule.setRequestAction("createInstance");
ebbActivateVfModule.setVnfType("test-vnf-type");
ebbActivateVfModule.setRequestId("f6c00ae2-a205-4cbd-b055-02e553efde12");
ebbActivateVfModule.setRequestDetails(requestDetails);
ebbActivateVfModule.setWorkflowResourceIds(resourceIdsActivateVfModule);
ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
configurationResourceKeys.setCvnfcCustomizationUUID("07d64cd2-4427-4156-b11d-d14b96b3e4cb");
configurationResourceKeys.setVfModuleCustomizationUUID("50b61075-6ebb-4aab-a9fc-bedad9a2aa76");
configurationResourceKeys.setVnfResourceCustomizationUUID("a1d0e36e-34a9-431b-b5ba-4bbb72f63c7c");
configurationResourceKeys.setVnfcName("rdm54bvbgw5001vm018pim001");
ExecuteBuildingBlock ebbAddFabricConfig = workflowActionBBTasks.getExecuteBBForConfig("AddFabricConfigurationBB", ebbActivateVfModule, "cc7e12f9-967c-4362-8d14-e5b2bf0608a4", configurationResourceKeys);
assertEquals("7", ebbAddFabricConfig.getApiVersion());
assertTrue(ebbAddFabricConfig.isaLaCarte());
assertEquals("createInstance", ebbAddFabricConfig.getRequestAction());
assertEquals("test-vnf-type", ebbAddFabricConfig.getVnfType());
assertEquals("f6c00ae2-a205-4cbd-b055-02e553efde12", ebbAddFabricConfig.getRequestId());
assertEquals(requestDetails, ebbAddFabricConfig.getRequestDetails());
assertEquals("cc7e12f9-967c-4362-8d14-e5b2bf0608a4", ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId());
assertEquals("test-service-inbstance-id", ebbAddFabricConfig.getWorkflowResourceIds().getServiceInstanceId());
assertEquals("test-vnf-id", ebbAddFabricConfig.getWorkflowResourceIds().getVnfId());
assertEquals("test-vf-module-id", ebbAddFabricConfig.getWorkflowResourceIds().getVfModuleId());
assertThat(ebbAddFabricConfig.getConfigurationResourceKeys()).isEqualTo(configurationResourceKeys);
assertThat(ebbAddFabricConfig.getWorkflowResourceIds()).isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds());
assertThat(ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId()).isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds().getConfigurationId());
}
use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.
the class WorkflowActionBBTasksTest method rollbackExecutionRollbackToCreatedWithFabricTest.
@Test
public void rollbackExecutionRollbackToCreatedWithFabricTest() {
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);
BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
flowsToExecute.add(ebb4);
execution.setVariable("flowsToExecute", flowsToExecute);
execution.setVariable("gCurrentSequence", 4);
workflowActionBBTasks.rollbackExecutionPath(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEquals(0, execution.getVariable("gCurrentSequence"));
assertEquals(2, ebbs.size());
assertEquals("DeleteFabricConfigurationBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
assertEquals("DeactivateVfModuleBB", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
}
Aggregations