Search in sources :

Example 6 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.

the class WorkflowActionTest method selectExecutionListServiceMacroCreateWithUserParams.

@Test
public void selectExecutionListServiceMacroCreateWithUserParams() throws Exception {
    String gAction = "createInstance";
    String resource = "Service";
    String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON);
    initExecution(gAction, bpmnRequest, false);
    execution.setVariable("requestUri", "v6/serviceInstances/123");
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB", "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
    northBoundRequest.setOrchestrationFlowList(orchFlows);
    Service service = new Service();
    service.setModelUUID("3c40d244-808e-42ca-b09a-256d83d19d0a");
    VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
    vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
    HeatEnvironment volumeHeatEnv = new HeatEnvironment();
    vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
    org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
    HeatTemplate volumeHeatTemplate = new HeatTemplate();
    vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
    vfModuleCustomization.setVfModule(vfModule);
    VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
    vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
    HeatEnvironment heatEnvironment = new HeatEnvironment();
    vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
    org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
    HeatTemplate moduleHeatTemplate = new HeatTemplate();
    vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
    vfModuleCustomization2.setVfModule(vfModule2);
    VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
    vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
    when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString())).thenReturn(prepareListWithResources(false, false));
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
    when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f")).thenReturn(vfModuleCustomization);
    when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8")).thenReturn(vfModuleCustomization2);
    when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969")).thenReturn(vfModuleCustomization3);
    when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
    workflowAction.selectExecutionList(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB", "ActivateServiceInstanceBB");
    assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
    int randomUUIDLength = UUID.randomUUID().toString().length();
    assertEquals(randomUUIDLength, ebbs.get(1).getWorkflowResourceIds().getVnfId().length());
    assertEquals(randomUUIDLength, ebbs.get(2).getWorkflowResourceIds().getVolumeGroupId().length());
    assertEquals(randomUUIDLength, ebbs.get(3).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(4).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(5).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(6).getWorkflowResourceIds().getVolumeGroupId().length());
    assertEquals(randomUUIDLength, ebbs.get(7).getWorkflowResourceIds().getVolumeGroupId().length());
    assertEquals(randomUUIDLength, ebbs.get(8).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(9).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(10).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(11).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(12).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(13).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(14).getWorkflowResourceIds().getVnfId().length());
    assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
    assertEquals(true, execution.getVariable("homing"));
}
Also used : HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Service(org.onap.so.db.catalog.beans.Service) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) VfModule(org.onap.aai.domain.yang.VfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 7 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.

the class WorkflowActionTest method getConfigBuildingBlocksTest.

@Test
public void getConfigBuildingBlocksTest() throws Exception {
    String gAction = "deleteInstance";
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
    WorkflowType resourceType = WorkflowType.VFMODULE;
    execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
    execution.setVariable("requestAction", gAction);
    String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
    execution.setVariable("bpmnRequest", bpmnRequest);
    execution.setVariable("vnfId", "1234");
    execution.setVariable("vfModuleId", "vfModuleId1234");
    execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
    ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
    RequestDetails requestDetails = sIRequest.getRequestDetails();
    String requestAction = "deleteInstance";
    String requestId = "9c944122-d161-4280-8594-48c06a9d96d5";
    boolean aLaCarte = true;
    String apiVersion = "7";
    String vnfType = "vnfType";
    String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
    String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
    Resource resourceKey = new Resource(resourceType, key, aLaCarte, null);
    WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
    List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB", "DeleteFabricConfigurationBB");
    ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion).setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution);
    org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
    vnf.setVnfId("vnf0");
    vnf.setModelCustomizationId("modelCustomizationId");
    when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf);
    org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
    vfModule.setModelCustomizationId("modelCustomizationId");
    org.onap.aai.domain.yang.Configuration config1 = new org.onap.aai.domain.yang.Configuration();
    config1.setConfigurationId("config1");
    org.onap.aai.domain.yang.Configuration config2 = new org.onap.aai.domain.yang.Configuration();
    config2.setConfigurationId("config2");
    List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
    org.onap.aai.domain.yang.Vnfc vnfc1 = new org.onap.aai.domain.yang.Vnfc();
    vnfc1.setVnfcName("zauk53avetd02svm001");
    org.onap.aai.domain.yang.Vnfc vnfc2 = new org.onap.aai.domain.yang.Vnfc();
    vnfc2.setVnfcName("zauk53avetd02tvm001");
    vnfcs.add(vnfc1);
    vnfcs.add(vnfc2);
    when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule);
    doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), eq(org.onap.aai.domain.yang.Vnfc.class), eq(Types.VNFC));
    doReturn(config1).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc1), eq(org.onap.aai.domain.yang.Configuration.class), eq(Types.CONFIGURATION));
    doReturn(config2).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc2), eq(org.onap.aai.domain.yang.Configuration.class), eq(Types.CONFIGURATION));
    List<ExecuteBuildingBlock> results = SPY_workflowAction.getConfigBuildingBlocks(dataObj);
    assertFalse(results.isEmpty());
    assertEquals(2, results.size());
    assertEquals("config1", results.get(0).getWorkflowResourceIds().getConfigurationId());
    assertEquals("config2", results.get(1).getWorkflowResourceIds().getConfigurationId());
    assertEquals("zauk53avetd02svm001", results.get(0).getConfigurationResourceKeys().getVnfcName());
    assertEquals("zauk53avetd02tvm001", results.get(1).getConfigurationResourceKeys().getVnfcName());
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ArrayList(java.util.ArrayList) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) VfModule(org.onap.aai.domain.yang.VfModule) VfModule(org.onap.aai.domain.yang.VfModule) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 8 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.

the class WorkflowActionTest method selectExecutionListServiceMacroCreateWithUserParamsAndPriorities.

@Test
public void selectExecutionListServiceMacroCreateWithUserParamsAndPriorities() throws Exception {
    String gAction = "createInstance";
    String resource = "Service";
    String bpmnRequest = readBpmnRequestFromFile(MACRO_CREATE_JSON);
    initExecution(gAction, bpmnRequest, false);
    execution.setVariable("requestUri", "v6/serviceInstances/123");
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "AssignPnfBB", "WaitForPnfReadyBB", "ActivatePnfBB", "CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB", "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
    northBoundRequest.setOrchestrationFlowList(orchFlows);
    Service service = new Service();
    service.setModelUUID("3c40d244-808e-42ca-b09a-256d83d19d0a");
    VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
    vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
    HeatEnvironment volumeHeatEnv = new HeatEnvironment();
    vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
    org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
    HeatTemplate volumeHeatTemplate = new HeatTemplate();
    vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
    vfModuleCustomization.setVfModule(vfModule);
    VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
    vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
    HeatEnvironment heatEnvironment = new HeatEnvironment();
    vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
    org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
    HeatTemplate moduleHeatTemplate = new HeatTemplate();
    vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
    vfModuleCustomization2.setVfModule(vfModule2);
    VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
    vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
    when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString())).thenReturn(prepareListWithResources(true, true));
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
    when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f")).thenReturn(vfModuleCustomization);
    when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8")).thenReturn(vfModuleCustomization2);
    when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969")).thenReturn(vfModuleCustomization3);
    when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
    workflowAction.selectExecutionList(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB", "AssignPnfBB", "WaitForPnfReadyBB", "ActivatePnfBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB", "ActivateServiceInstanceBB");
    assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
    int randomUUIDLength = UUID.randomUUID().toString().length();
    assertEquals(randomUUIDLength, ebbs.get(1).getWorkflowResourceIds().getVnfId().length());
    assertEquals(randomUUIDLength, ebbs.get(2).getWorkflowResourceIds().getVolumeGroupId().length());
    assertEquals(randomUUIDLength, ebbs.get(3).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(4).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(5).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals("72d9d1cd-f46d-447a-abdb-451d6fb05fa8", ebbs.get(3).getBuildingBlock().getKey());
    assertEquals("da4d4327-fb7d-4311-ac7a-be7ba60cf969", ebbs.get(4).getBuildingBlock().getKey());
    assertEquals("3c40d244-808e-42ca-b09a-256d83d19d0a", ebbs.get(5).getBuildingBlock().getKey());
    assertEquals(randomUUIDLength, ebbs.get(6).getWorkflowResourceIds().getPnfId().length());
    assertEquals(randomUUIDLength, ebbs.get(7).getWorkflowResourceIds().getPnfId().length());
    assertEquals(randomUUIDLength, ebbs.get(8).getWorkflowResourceIds().getPnfId().length());
    assertEquals(randomUUIDLength, ebbs.get(9).getWorkflowResourceIds().getVolumeGroupId().length());
    assertEquals(randomUUIDLength, ebbs.get(10).getWorkflowResourceIds().getVolumeGroupId().length());
    assertEquals(randomUUIDLength, ebbs.get(11).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(12).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(13).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(14).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(15).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(16).getWorkflowResourceIds().getVfModuleId().length());
    assertEquals(randomUUIDLength, ebbs.get(17).getWorkflowResourceIds().getVnfId().length());
    assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
    assertEquals(true, execution.getVariable("homing"));
}
Also used : HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Service(org.onap.so.db.catalog.beans.Service) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) VfModule(org.onap.aai.domain.yang.VfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 9 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow 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);
}
Also used : ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Arrays(java.util.Arrays) AAIUriFactory(org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) VfModule(org.onap.aai.domain.yang.VfModule) ServiceEBBLoader(org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.ServiceEBBLoader) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) Assert.assertThat(org.junit.Assert.assertThat) Mockito.doThrow(org.mockito.Mockito.doThrow) Service(org.onap.so.db.catalog.beans.Service) Map(java.util.Map) Spy(org.mockito.Spy) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) DuplicateNameException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException) Mockito.doReturn(org.mockito.Mockito.doReturn) VnfEBBLoader(org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.VnfEBBLoader) GenericVnf(org.onap.aai.domain.yang.GenericVnf) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) ArgumentMatchers.anyObject(org.mockito.ArgumentMatchers.anyObject) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) Set(java.util.Set) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) UUID(java.util.UUID) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) Collectors(java.util.stream.Collectors) DelegateExecutionFake(org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) Environment(org.springframework.core.env.Environment) Optional(java.util.Optional) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) Mock(org.mockito.Mock) Relationship(org.onap.aai.domain.yang.Relationship) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) ArrayList(java.util.ArrayList) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) RelationshipList(org.onap.aai.domain.yang.RelationshipList) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) ExpectedException(org.junit.rules.ExpectedException) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) ArgumentMatchers.isA(org.mockito.ArgumentMatchers.isA) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) UserParamsServiceTraversal(org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.UserParamsServiceTraversal) MalformedURLException(java.net.MalformedURLException) Files(java.nio.file.Files) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) AAIEntityNotFoundException(org.onap.so.client.orchestration.AAIEntityNotFoundException) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) Assert.assertTrue(org.junit.Assert.assertTrue) CvnfcCustomization(org.onap.so.db.catalog.beans.CvnfcCustomization) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) Mockito(org.mockito.Mockito) Assert.assertNull(org.junit.Assert.assertNull) Rule(org.junit.Rule) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) Ignore(org.junit.Ignore) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) Paths(java.nio.file.Paths) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Assert.assertEquals(org.junit.Assert.assertEquals) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Service(org.onap.so.db.catalog.beans.Service) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) VfModule(org.onap.aai.domain.yang.VfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 10 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.

the class WorkflowActionTest method getConfigBuildingBlocksNoVfModuleFabricDeleteTest.

@Test
public void getConfigBuildingBlocksNoVfModuleFabricDeleteTest() throws Exception {
    String gAction = "deleteInstance";
    ObjectMapper mapper = new ObjectMapper();
    WorkflowType resourceType = WorkflowType.VFMODULE;
    String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON);
    execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
    execution.setVariable("requestAction", gAction);
    execution.setVariable("bpmnRequest", bpmnRequest);
    execution.setVariable("vnfId", "1234");
    execution.setVariable("vfModuleId", "vfModuleId1234");
    execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
    ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
    RequestDetails requestDetails = sIRequest.getRequestDetails();
    String requestAction = "deleteInstance";
    String requestId = "9c944122-d161-4280-8594-48c06a9d96d5";
    boolean aLaCarte = true;
    String apiVersion = "7";
    String vnfType = "vnfType";
    String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
    String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
    Resource resourceKey = new Resource(resourceType, key, aLaCarte, null);
    WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
    thrown.expect(AAIEntityNotFoundException.class);
    thrown.expectMessage(containsString("No matching VfModule is found in Generic-Vnf in AAI for vnfId: 1234 and vfModuleId : vfModuleId1234"));
    List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
    ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion).setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution);
    org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
    vnf.setVnfId("vnf0");
    vnf.setModelCustomizationId("modelCustomizationId");
    when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
    org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
    vfModule.setModelCustomizationId("modelCustomizationId");
    when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(null);
    SPY_workflowAction.getConfigBuildingBlocks(dataObj);
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) VfModule(org.onap.aai.domain.yang.VfModule) VfModule(org.onap.aai.domain.yang.VfModule) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

OrchestrationFlow (org.onap.so.db.catalog.beans.macro.OrchestrationFlow)44 ArrayList (java.util.ArrayList)39 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)37 Test (org.junit.Test)33 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)32 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)32 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)31 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)31 List (java.util.List)30 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)27 RelationshipList (org.onap.aai.domain.yang.RelationshipList)27 VfModule (org.onap.aai.domain.yang.VfModule)15 GenericVnf (org.onap.aai.domain.yang.GenericVnf)11 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)9 Service (org.onap.so.db.catalog.beans.Service)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)8 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)8 VolumeGroup (org.onap.aai.domain.yang.VolumeGroup)7 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)7