Support instantiation of same model vnfs/vf-modules
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / workflow / tasks / WorkflowActionTest.java
index 407a844..021bac3 100644 (file)
@@ -8,6 +8,8 @@
  * ================================================================================
  * Modifications Copyright (c) 2020 Nokia
  * ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package org.onap.so.bpmn.infrastructure.workflow.tasks;
 
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
 import static org.mockito.ArgumentMatchers.anyObject;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.isA;
-import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.when;
@@ -51,15 +50,15 @@ import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
+import java.util.Set;
 import java.util.UUID;
+import java.util.stream.Collectors;
 import org.camunda.bpm.engine.delegate.BpmnError;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
-import org.javatuples.Pair;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Rule;
@@ -68,23 +67,21 @@ import org.junit.rules.ExpectedException;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.Spy;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.GenericVnfs;
-import org.onap.aai.domain.yang.L3Network;
 import org.onap.aai.domain.yang.Relationship;
 import org.onap.aai.domain.yang.RelationshipList;
 import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aai.domain.yang.ServiceInstances;
 import org.onap.aai.domain.yang.VfModule;
-import org.onap.aai.domain.yang.VfModules;
 import org.onap.aai.domain.yang.VolumeGroup;
-import org.onap.aaiclient.client.aai.AAIObjectType;
 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
 import org.onap.aaiclient.client.aai.entities.Relationships;
 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
 import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.ServiceEBBLoader;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.UserParamsServiceTraversal;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.VnfEBBLoader;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
 import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
@@ -108,11 +105,8 @@ import org.onap.so.db.catalog.beans.Service;
 import org.onap.so.db.catalog.beans.VfModuleCustomization;
 import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
 import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
-import org.onap.so.serviceinstancebeans.ModelInfo;
 import org.onap.so.serviceinstancebeans.RequestDetails;
-import org.onap.so.serviceinstancebeans.RequestParameters;
 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
-import org.onap.so.serviceinstancebeans.SubscriberInfo;
 import org.springframework.core.env.Environment;
 
 public class WorkflowActionTest extends BaseTaskTest {
@@ -121,21 +115,42 @@ public class WorkflowActionTest extends BaseTaskTest {
     private static final String MACRO_ASSIGN_JSON = "Macro/ServiceMacroAssign.json";
     private static final String MACRO_ASSIGN_NO_CLOUD_JSON = "Macro/ServiceMacroAssignNoCloud.json";
     private static final String VF_MODULE_CREATE_WITH_FABRIC_JSON = "VfModuleCreateWithFabric.json";
+    private static final String VF_MODULE_CREATE_WITH_FABRIC_NO_PARAMS_JSON = "VfModuleCreateWithFabricNoParams.json";
     private static final String VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON =
             "VfModuleReplaceRebuildVolumeGroups.json";
     private static final String MACRO_CREATE_NETWORK_COLLECTION_JSON = "Macro/CreateNetworkCollection.json";
     private static final String MACRO_VNF_MACRO_REPLACE_JSON = "Macro/VnfMacroReplace.json";
+    private static final String MACRO_CREATE_JSON = "Macro/ServiceMacroAssignVnfAndPnf.json";
+    private static final String MACRO_CREATE_SERVICE_MULTIPLE_SAME_MODEL_VNF_VFMODULE =
+            "Macro/ServiceMacroCreateMultipleSameModelVnfsAndVfModules.json";
 
     @Mock
     protected Environment environment;
+    @Mock
+    protected UserParamsServiceTraversal userParamsServiceTraversal;
+
+    @Mock
+    private AaiResourceIdValidator aaiResourceIdValidator;
     @InjectMocks
     protected WorkflowAction workflowAction;
+
     private DelegateExecution execution;
 
     @InjectMocks
     @Spy
     protected WorkflowAction SPY_workflowAction;
 
+    @Spy
+    protected ExecuteBuildingBlockBuilder executeBuildingBlockBuilder;
+
+    @InjectMocks
+    @Spy
+    protected VnfEBBLoader vnfEBBLoaderSpy;
+
+    @InjectMocks
+    @Spy
+    protected ServiceEBBLoader serviceEBBLoader;
+
     @Rule
     public ExpectedException thrown = ExpectedException.none();
 
@@ -164,6 +179,7 @@ public class WorkflowActionTest extends BaseTaskTest {
         when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
         workflowAction.setBbInputSetupUtils(bbSetupUtils);
         workflowAction.setBbInputSetup(bbInputSetup);
+
     }
 
     /**
@@ -184,6 +200,7 @@ public class WorkflowActionTest extends BaseTaskTest {
 
         when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
                 true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
         workflowAction.selectExecutionList(execution);
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
         assertEqualsBulkFlowName(ebbs, "AssignNetwork1802BB", "CreateNetworkBB", "ActivateNetworkBB");
@@ -204,6 +221,7 @@ public class WorkflowActionTest extends BaseTaskTest {
 
         when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
                 true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
         workflowAction.selectExecutionList(execution);
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
         assertEqualsBulkFlowName(ebbs, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetwork1802BB");
@@ -238,12 +256,16 @@ public class WorkflowActionTest extends BaseTaskTest {
 
         doThrow(new DuplicateNameException(
                 "serviceInstance with name (instanceName) and different version id (3c40d244-808e-42ca-b09a-256d83d19d0a) already exists. The name must be unique."))
-                        .when(SPY_workflowAction).validateResourceIdInAAI(anyString(), eq(WorkflowType.SERVICE),
+                        .when(aaiResourceIdValidator).validateResourceIdInAAI(anyString(), eq(WorkflowType.SERVICE),
                                 eq("test"), any(RequestDetails.class), any(WorkflowResourceIds.class));
 
         SPY_workflowAction.selectExecutionList(execution);
         assertEquals(execution.getVariable("WorkflowActionErrorMessage"),
                 "Exception while setting execution list. serviceInstance with name (instanceName) and different version id (3c40d244-808e-42ca-b09a-256d83d19d0a) already exists. The name must be unique.");
+
+        // verify default values are present in failure case
+        assertEquals(true, execution.getVariable("isTopLevelFlow"));
+        assertEquals(false, execution.getVariable("sentSyncResponse"));
     }
 
     /**
@@ -283,6 +305,8 @@ public class WorkflowActionTest extends BaseTaskTest {
         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"))
@@ -291,6 +315,7 @@ public class WorkflowActionTest extends BaseTaskTest {
                 .thenReturn(vfModuleCustomization2);
         when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969"))
                 .thenReturn(vfModuleCustomization3);
+
         workflowAction.selectExecutionList(execution);
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
         assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB",
@@ -331,6 +356,8 @@ public class WorkflowActionTest extends BaseTaskTest {
         VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
         vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
 
+        when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString()))
+                .thenReturn(prepareListWithResources(false, false));
         when(environment.getProperty("org.onap.so.cloud-owner")).thenReturn("att-aic");
         when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
                 false, "att-aic")).thenReturn(northBoundRequest);
@@ -387,13 +414,13 @@ public class WorkflowActionTest extends BaseTaskTest {
         workflowAction.selectExecutionList(execution);
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
         assertEqualsBulkFlowName(ebbs, "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
-                "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
+                "ActivateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
                 "ActivateServiceInstanceBB");
         assertEquals("volumeGroup0", ebbs.get(0).getWorkflowResourceIds().getVolumeGroupId());
         assertEquals("volumeGroup0", ebbs.get(1).getWorkflowResourceIds().getVolumeGroupId());
         assertEquals("testVfModuleId1", ebbs.get(2).getWorkflowResourceIds().getVfModuleId());
-        assertEquals("testVfModuleId2", ebbs.get(3).getWorkflowResourceIds().getVfModuleId());
-        assertEquals("testVfModuleId1", ebbs.get(4).getWorkflowResourceIds().getVfModuleId());
+        assertEquals("testVfModuleId1", ebbs.get(3).getWorkflowResourceIds().getVfModuleId());
+        assertEquals("testVfModuleId2", ebbs.get(4).getWorkflowResourceIds().getVfModuleId());
         assertEquals("testVfModuleId2", ebbs.get(5).getWorkflowResourceIds().getVfModuleId());
         assertEquals("vnf0", ebbs.get(6).getWorkflowResourceIds().getVnfId());
         assertEquals("si0", ebbs.get(7).getWorkflowResourceIds().getServiceInstanceId());
@@ -468,6 +495,7 @@ public class WorkflowActionTest extends BaseTaskTest {
         doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
         when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
                 false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
         workflowAction.selectExecutionList(execution);
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
         assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignNetworkBB", "CreateNetworkBB",
@@ -603,6 +631,8 @@ public class WorkflowActionTest extends BaseTaskTest {
         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"))
@@ -616,9 +646,10 @@ public class WorkflowActionTest extends BaseTaskTest {
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
         assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB",
                 "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB", "CreateVolumeGroupBB",
-                "ActivateVolumeGroupBB", "CreateVfModuleBB", "CreateVfModuleBB", "CreateVfModuleBB",
-                "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
+                "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());
@@ -639,6 +670,225 @@ public class WorkflowActionTest extends BaseTaskTest {
         assertEquals(true, execution.getVariable("homing"));
     }
 
+    @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"));
+    }
+
+    @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);
+    }
+
     @Test
     public void selectExecutionListServiceMacroDeleteTest() throws Exception {
         String gAction = "deleteInstance";
@@ -685,7 +935,7 @@ public class WorkflowActionTest extends BaseTaskTest {
                 false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
         workflowAction.selectExecutionList(execution);
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
-        assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB",
+        assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVfModuleBB",
                 "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB",
                 "DeactivatePnfBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVfModuleBB",
                 "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignServiceInstanceBB");
@@ -856,8 +1106,8 @@ public class WorkflowActionTest extends BaseTaskTest {
         workflowAction.selectExecutionList(execution);
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
         assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateVfModuleBB",
-                "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB",
-                "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB", "SDNOVnfHealthCheckBB",
+                "DeleteVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB",
+                "ActivateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB", "SDNOVnfHealthCheckBB",
                 "AAIUnsetVnfInMaintBB");
     }
 
@@ -917,12 +1167,13 @@ public class WorkflowActionTest extends BaseTaskTest {
                 false, "cloud-owner")).thenReturn(northBoundRequest);
         workflowAction.selectExecutionList(execution);
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
-        assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateFabricConfigurationBB",
-                "UnassignFabricConfigurationBB", "DeactivateVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB",
-                "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB", "ChangeModelVfModuleBB",
-                "CreateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB",
-                "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ChangeModelVnfBB", "ActivateVnfBB",
-                "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
+        assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateVfModuleBB",
+                "DeleteVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB",
+                "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB",
+                "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVfModuleBB", "CreateVfModuleBB",
+                "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB",
+                "ChangeModelVnfBB", "ActivateVnfBB", "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB",
+                "AAIUnsetVnfInMaintBB");
         for (ExecuteBuildingBlock executeBuildingBlock : ebbs) {
             assertEquals("123", executeBuildingBlock.getWorkflowResourceIds().getServiceInstanceId());
         }
@@ -1022,7 +1273,7 @@ public class WorkflowActionTest extends BaseTaskTest {
 
         NorthBoundRequest northBoundRequest = new NorthBoundRequest();
         List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
-                "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB");
+                "AddFabricConfigurationBB");
         northBoundRequest.setOrchestrationFlowList(orchFlows);
 
         List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<CvnfcCustomization>();
@@ -1056,15 +1307,14 @@ public class WorkflowActionTest extends BaseTaskTest {
 
         when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
                 true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
-        // when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID("fc25201d-36d6-43a3-8d39-fdae88e526ae",
-        // "9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(cvnfcCustomizations);
+
         workflowAction.selectExecutionList(execution);
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
-        assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
-                "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "AssignFabricConfigurationBB",
-                "ActivateFabricConfigurationBB");
+        assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB");
     }
 
+
+
     @Test
     public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceTest() throws Exception {
         String gAction = "replaceInstance";
@@ -1252,8 +1502,8 @@ public class WorkflowActionTest extends BaseTaskTest {
         List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
 
         assertEqualsBulkFlowName(ebbs, "DeleteFabricConfigurationBB", "DeactivateVfModuleBB", "DeleteVfModuleATTBB",
-                "UnassignVFModuleBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
-                "AddFabricConfigurationBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
+                "UnassignVFModuleBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB",
+                "ChangeModelServiceInstanceBB");
     }
 
     @Test
@@ -1428,7 +1678,6 @@ public class WorkflowActionTest extends BaseTaskTest {
                 "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
     }
 
-
     @Test
     public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception {
         String gAction = "deleteInstance";
@@ -1476,6 +1725,27 @@ public class WorkflowActionTest extends BaseTaskTest {
                 "DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB");
     }
 
+    @Test
+    public void selectExecutionListALaCarteNoRequestParametersTest() throws Exception {
+        String gAction = "createInstance";
+        String resource = "VfModule";
+        String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_NO_PARAMS_JSON);
+        initExecution(gAction, bpmnRequest, true);
+        execution.setVariable("requestUri",
+                "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+        NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+        List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
+                "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB");
+        northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+        when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+                true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+        workflowAction.selectExecutionList(execution);
+        List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+        assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB");
+    }
+
     @Test
     public void getConfigBuildingBlocksNoVfModuleFabricDeleteTest() throws Exception {
         String gAction = "deleteInstance";
@@ -1498,7 +1768,7 @@ public class WorkflowActionTest extends BaseTaskTest {
         String vnfType = "vnfType";
         String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
         String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
-        Resource resourceKey = new Resource(resourceType, key, aLaCarte);
+        Resource resourceKey = new Resource(resourceType, key, aLaCarte, null);
         WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
 
         thrown.expect(AAIEntityNotFoundException.class);
@@ -1550,7 +1820,7 @@ public class WorkflowActionTest extends BaseTaskTest {
         String vnfType = "vnfType";
         String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
         String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
-        Resource resourceKey = new Resource(resourceType, key, aLaCarte);
+        Resource resourceKey = new Resource(resourceType, key, aLaCarte, null);
         WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
 
         List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
@@ -1584,11 +1854,11 @@ public class WorkflowActionTest extends BaseTaskTest {
 
         when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule);
         doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(),
-                eq(org.onap.aai.domain.yang.Vnfc.class), eq(AAIObjectType.VNFC));
+                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(AAIObjectType.CONFIGURATION));
+                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(AAIObjectType.CONFIGURATION));
+                eq(org.onap.aai.domain.yang.Configuration.class), eq(Types.CONFIGURATION));
 
         List<ExecuteBuildingBlock> results = SPY_workflowAction.getConfigBuildingBlocks(dataObj);
 
@@ -1600,6 +1870,79 @@ public class WorkflowActionTest extends BaseTaskTest {
         assertEquals("zauk53avetd02tvm001", results.get(1).getConfigurationResourceKeys().getVnfcName());
     }
 
+    @Test
+    public void getConfigBuildingBlocksNullConfigurationTest() 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");
+
+        /* this is a test case where configuration for vnfc is null */
+        org.onap.aai.domain.yang.Configuration config1 = null;
+        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(1, results.size());
+        assertEquals("config2", results.get(0).getWorkflowResourceIds().getConfigurationId());
+        assertEquals("zauk53avetd02tvm001", results.get(0).getConfigurationResourceKeys().getVnfcName());
+    }
+
     @Test
     public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception {
         String gAction = "deleteInstance";
@@ -1690,13 +2033,13 @@ public class WorkflowActionTest extends BaseTaskTest {
         List<AAIResultWrapper> configurationResultWrappers = new ArrayList<AAIResultWrapper>();
         configurationResultWrappers.add(configurationWrapper);
 
-        AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
+        AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfc.getVnfcName()));
         when(bbSetupUtils.getAAIResourceDepthOne(uri)).thenReturn(vfncWrapper);
 
         doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(),
                 anyObject());
         org.onap.aai.domain.yang.Configuration configuration = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc,
-                org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+                org.onap.aai.domain.yang.Configuration.class, Types.CONFIGURATION);
         assertEquals("testConfigurationId", configuration.getConfigurationId());
     }
 
@@ -1833,10 +2176,10 @@ public class WorkflowActionTest extends BaseTaskTest {
         String uri6 = "/v6/serviceInstances/123/vnfs/1234/someAction";
         String uri7 = "/v6/serviceInstances/123/vnfs/1234/vfModules/5678/replace";
         String uri8 = "/v6/serviceInstances/123/vnfs/1234/vfModules/scaleOut";
-        Resource expected1 = new Resource(WorkflowType.SERVICE, "123", true);
-        Resource expected2 = new Resource(WorkflowType.VNF, "1234", false);
-        Resource expected3 = new Resource(WorkflowType.VNF, "1234", false);
-        Resource expected4 = new Resource(WorkflowType.VFMODULE, "5678", false);
+        Resource expected1 = new Resource(WorkflowType.SERVICE, "123", true, null);
+        Resource expected2 = new Resource(WorkflowType.VNF, "1234", false, expected1);
+        Resource expected3 = new Resource(WorkflowType.VNF, "1234", false, expected1);
+        Resource expected4 = new Resource(WorkflowType.VFMODULE, "5678", false, expected2);
         Resource result = workflowAction.extractResourceIdAndTypeFromUri(uri);
         assertEquals(expected1.getResourceId(), result.getResourceId());
         assertEquals(expected1.getResourceType(), result.getResourceType());
@@ -1934,1133 +2277,73 @@ public class WorkflowActionTest extends BaseTaskTest {
         assertNull(x.getVolumeGroupId());
     }
 
-    private RequestDetails setupRequestDetails(String globalSubscriberId, String subscriptionServiceType,
-            String modelCustomizationId) {
-        RequestDetails reqDetails = new RequestDetails();
-        SubscriberInfo subInfo = new SubscriberInfo();
-        subInfo.setGlobalSubscriberId(globalSubscriberId);
-        reqDetails.setSubscriberInfo(subInfo);
-        RequestParameters reqParams = new RequestParameters();
-        reqParams.setSubscriptionServiceType(subscriptionServiceType);
-        reqDetails.setRequestParameters(reqParams);
-        ModelInfo modelInfo = new ModelInfo();
-        modelInfo.setModelCustomizationId(modelCustomizationId);
-        reqDetails.setModelInfo(modelInfo);
-        return reqDetails;
-    }
-
-    @Test
-    public void validateResourceIdInAAIVnfTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        // Vnf
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setModelCustomizationId("1234567");
-        Optional<GenericVnf> opVnf = Optional.of(vnf);
-        GenericVnf vnf2 = new GenericVnf();
-        vnf2.setVnfId("id123");
-        vnf2.setVnfName("vnfName222");
-        vnf2.setModelCustomizationId("222");
-        Optional<GenericVnf> opVnf2 = Optional.of(vnf2);
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName222")).thenReturn(opVnf2);
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty());
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName123", reqDetails,
-                workflowResourceIds);
-        assertEquals("id123", id);
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "111111", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id2);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "generic-vnf with name (vnfName222), same parent and different customization id (222) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName222", reqDetails,
-                workflowResourceIds);
-    }
-
     @Test
-    public void validateResourceIdInAAIVnfNotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        // Vnf
-        GenericVnfs genericVnfs = new GenericVnfs();
-        GenericVnf vnf3 = new GenericVnf();
-        vnf3.setVnfId("id123");
-        vnf3.setVnfName("vnfName333");
-        genericVnfs.getGenericVnf().add(vnf3);
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName333")).thenReturn(Optional.empty());
-        when(bbSetupUtils.getAAIVnfsGloballyByName("vnfName333")).thenReturn(genericVnfs);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "generic-vnf with name (vnfName333) id (id123) and different parent relationship already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName333", reqDetails,
-                workflowResourceIds);
+    public void handleRuntimeExceptionTest() {
+        execution.setVariable("BPMN_javaExpMsg", "test runtime error message");
+        execution.setVariable("testProcessKey", "testProcessKeyValue");
+        try {
+            workflowAction.handleRuntimeException(execution);
+        } catch (BpmnError wfe) {
+            assertEquals("MSOWorkflowException", wfe.getErrorCode());
+        }
     }
 
-    @Test
-    public void validateResourceIdInAAINetworkTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        // Network
-        L3Network network = new L3Network();
-        network.setNetworkId("id123");
-        network.setNetworkName("name123");
-        network.setModelCustomizationId("1234567");
-        workflowResourceIds.setServiceInstanceId("siId123");
-        Optional<L3Network> opNetwork = Optional.of(network);
-        L3Network network2 = new L3Network();
-        network2.setNetworkId("id123");
-        network2.setNetworkName("networkName222");
-        network2.setModelCustomizationId("222");
-        Optional<L3Network> opNetwork2 = Optional.of(network2);
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "networkName222"))
-                .thenReturn(opNetwork2);
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty());
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123",
-                reqDetails, workflowResourceIds);
-        assertEquals("id123", id);
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111",
-                reqDetails, workflowResourceIds);
-        assertEquals("generatedId123", id2);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "l3Network with name (networkName222), same parent and different customization id (222) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName222", reqDetails,
-                workflowResourceIds);
+    private List<OrchestrationFlow> createFlowList(String... flowNames) {
+        List<OrchestrationFlow> result = new ArrayList<>();
+        int sequenceNumber = 1;
+        for (String flowName : flowNames) {
+            OrchestrationFlow orchFlow = new OrchestrationFlow();
+            orchFlow.setFlowName(flowName);
+            orchFlow.setSequenceNumber(sequenceNumber++);
+            result.add(orchFlow);
+        }
+        return result;
     }
 
-    @Test
-    public void validateNetworkResourceNameExistsInAAITest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        // Network
-        L3Network network = new L3Network();
-        network.setNetworkId("id123");
-        network.setNetworkName("name123");
-        network.setModelCustomizationId("1234567");
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("networkName333", "111111"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAINetworksGloballyByName("networkName333")).thenReturn(true);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "l3Network with name (networkName333) id (siId123) and different parent relationship already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName333", reqDetails,
-                workflowResourceIds);
+    private void assertEqualsBulkFlowName(List<ExecuteBuildingBlock> ebbs, String... flowNames) {
+        for (int i = 0; i < ebbs.size(); i++) {
+            assertEquals(ebbs.get(i).getBuildingBlock().getBpmnFlowName(), flowNames[i]);
+        }
+        assertEquals(ebbs.size(), flowNames.length);
     }
 
-    @Test
-    public void validateResourceIdInAAIVfModuleTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setModelCustomizationId("222");
-
-        // VfModule
-        VfModules vfModules = new VfModules();
-        VfModule vfModule = new VfModule();
-        vfModule.setVfModuleId("id123");
-        vfModule.setVfModuleName("name123");
-        vfModule.setModelCustomizationId("1234567");
-        vfModules.getVfModule().add(vfModule);
-        vnf.setVfModules(vfModules);
-        workflowResourceIds.setVnfId("id123");
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123",
-                reqDetails, workflowResourceIds);
-        assertEquals("id123", id);
-
-        GenericVnf vnf1 = new GenericVnf();
-        VfModules vfModules2 = new VfModules();
-        VfModule vfModule2 = new VfModule();
-        vfModule2.setVfModuleId("id123");
-        vfModule2.setVfModuleName("vFModName222");
-        vfModule2.setModelCustomizationId("222");
-        vfModules2.getVfModule().add(vfModule2);
-        vnf1.setVfModules(vfModules2);
-        workflowResourceIds.setVnfId("id111");
-        when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf1);
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111",
-                reqDetails, workflowResourceIds);
-        assertEquals("generatedId123", id2);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "vfModule with name (vFModName222), same parent and different customization id (1234567) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName222", reqDetails,
-                workflowResourceIds);
+    private void initExecution(String gAction, String bpmnRequest, boolean isAlaCarte) {
+        execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+        execution.setVariable("requestAction", gAction);
+        execution.setVariable("bpmnRequest", bpmnRequest);
+        execution.setVariable("aLaCarte", isAlaCarte);
+        execution.setVariable("apiVersion", "7");
     }
 
-    @Test
-    public void validateResourceIdInAAIVfModuleNotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("id111");
-
-        GenericVnf vnf1 = new GenericVnf();
-        workflowResourceIds.setVnfId("id111");
-        when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf1);
-
-        when(bbSetupUtils.existsAAIVfModuleGloballyByName("vFModName333")).thenReturn(true);
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("vfModule with name vFModName333 already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName333", reqDetails,
-                workflowResourceIds);
+    private String readBpmnRequestFromFile(String fileName) throws IOException {
+        return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/" + fileName)));
     }
 
-    @Test
-    public void validateResourceIdInAAIVolumeGroupTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setModelCustomizationId("1234567");
-
-        GenericVnf vnf2 = new GenericVnf();
-        vnf2.setVnfId("id123");
-        vnf2.setVnfName("vnfName123");
-        vnf2.setModelCustomizationId("222");
-
-        // VolumeGroup
-        VolumeGroup volumeGroup = new VolumeGroup();
-        volumeGroup.setVolumeGroupId("id123");
-        volumeGroup.setVolumeGroupName("name123");
-        volumeGroup.setVfModuleModelCustomizationId("1234567");
-        workflowResourceIds.setVnfId("id123");
-        Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
-
-        workflowResourceIds.setVnfId("id123");
-
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123")).thenReturn(opVolumeGroup);
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123",
-                reqDetails, workflowResourceIds);
-        assertEquals("id123", id);
-
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf2);
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123", "111111"))
-                .thenReturn(opVolumeGroup);
-
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "111111")).thenReturn(Optional.empty());
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "111111",
-                reqDetails, workflowResourceIds);
-        assertEquals("generatedId123", id2);
-    }
-
-    @Test
-    public void validatesourceIdInAAIVolumeGroupNotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("id123");
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "testVolumeGroup")).thenReturn(Optional.empty());
-
-        when(bbSetupUtils.existsAAIVolumeGroupGloballyByName("testVolumeGroup")).thenReturn(true);
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("volumeGroup with name testVolumeGroup already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "testVolumeGroup",
-                reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAIConfigurationTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        // Configuration
-        org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
-        configuration.setConfigurationId("id123");
-        configuration.setConfigurationName("name123");
-        configuration.setModelCustomizationId("1234567");
-        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration);
-
-        org.onap.aai.domain.yang.Configuration configuration2 = new org.onap.aai.domain.yang.Configuration();
-        configuration2.setConfigurationId("id123");
-        configuration2.setConfigurationName("name123");
-        configuration2.setModelCustomizationId("222");
-        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration2 = Optional.of(configuration2);
-
-        workflowResourceIds.setVnfId("id123");
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(opConfiguration);
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "name123",
-                reqDetails, workflowResourceIds);
-        assertEquals("id123", id);
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "111111"))
-                .thenReturn(Optional.empty());
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "111111",
-                reqDetails, workflowResourceIds);
-        assertEquals("generatedId123", id2);
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name222"))
-                .thenReturn(opConfiguration2);
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "configuration with name (name222), same parent and different customization id (id123) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "name222", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAIConfigurationNotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "testConfig"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAIConfigurationGloballyByName("testConfig")).thenReturn(true);
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("configuration with name testConfig already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "testConfig", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAISITest() throws Exception {
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-        Optional<ServiceInstance> siOp = Optional.of(si);
-        ServiceInstance si2 = new ServiceInstance();
-        si2.setServiceInstanceId("siId222");
-        si2.setModelVersionId("22222");
-        si2.setServiceInstanceName("siName222");
-        Optional<ServiceInstance> siOp2 = Optional.of(si2);
-        ServiceInstances serviceInstances2 = new ServiceInstances();
-        serviceInstances2.getServiceInstance().add(si2);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName222")).thenReturn(siOp2);
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "111111"))
-                .thenReturn(Optional.empty());
-
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123",
-                reqDetails, workflowResourceIds);
-        assertEquals("siId123", id);
-        String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "111111",
-                reqDetails, workflowResourceIds);
-        assertEquals("generatedId123", id2);
-
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName222")).thenReturn(serviceInstances2);
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName222) and different version id (1234567) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName222", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAIMultipleSITest() throws Exception {
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-
-        ServiceInstance si2 = new ServiceInstance();
-        si2.setServiceInstanceId("siId222");
-        si2.setModelVersionId("22222");
-        si2.setServiceInstanceName("siName222");
-        serviceInstances.getServiceInstance().add(si2);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siId123"))
-                .thenReturn(Optional.empty());
-
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName123) and multiple combination of model-version-id + service-type + global-customer-id already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateResourceIdInAAISIExistsTest() throws Exception {
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siId123"))
-                .thenReturn(Optional.empty());
-
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
-
-        Map<String, String> uriKeys = new HashMap<>();
-        uriKeys.put(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId, "globalCustomerId");
-        uriKeys.put(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType, "serviceType");
-
-        when(bbSetupUtils.getURIKeysFromServiceInstance("siId123")).thenReturn(uriKeys);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName123) and global-customer-id (globalCustomerId), service-type (serviceType), model-version-id (1234567) already exists. The name must be unique."));
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateServiceResourceIdInAAINoDupTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(null);
-        String id = workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateServiceResourceIdInAAISameModelVersionId() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-        Optional<ServiceInstance> siOp = Optional.of(si);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
-        String id = workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails);
-        assertEquals("siId123", id);
-    }
-
-    @Test
-    public void validateServiceResourceIdInAAIDifferentModelVersionId() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("9999999");
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-        Optional<ServiceInstance> siOp = Optional.of(si);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName123) and different version id (1234567) already exists. The name must be unique."));
-
-        String id = workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails);
-        assertEquals("siId123", id);
-    }
-
-    @Test
-    public void validateServiceResourceIdInAAIDuplicateNameTest() throws Exception {
-
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName")).thenReturn(serviceInstances);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName) and global-customer-id (null), service-type (null), model-version-id (1234567) already exists. The name must be unique."));
-
-        workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName", reqDetails);
-    }
-
-    @Test
-    public void validateServiceResourceIdInAAIDuplicateNameMultipleTest() throws Exception {
-
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        reqDetails.getModelInfo().setModelVersionId("1234567");
-
-        ServiceInstance si = new ServiceInstance();
-        si.setServiceInstanceId("siId123");
-        si.setModelVersionId("1234567");
-
-        ServiceInstance si2 = new ServiceInstance();
-        si2.setServiceInstanceId("siId222");
-        si2.setModelVersionId("22222");
-        si2.setServiceInstanceName("siName222");
-
-        ServiceInstances serviceInstances = new ServiceInstances();
-        serviceInstances.getServiceInstance().add(si);
-        serviceInstances.getServiceInstance().add(si2);
-
-        when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName")).thenReturn(serviceInstances);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "serviceInstance with name (siName) and multiple combination of model-version-id + service-type + global-customer-id already exists. The name must be unique."));
-
-        workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName", reqDetails);
-    }
-
-    @Test
-    public void validateNetworkResourceIdInAAITest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAINetworksGloballyByName("name123")).thenReturn(false);
-
-        String id = workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateNetworkResourceIdInAAISameModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        L3Network network = new L3Network();
-        network.setNetworkId("id123");
-        network.setNetworkName("name123");
-        network.setModelCustomizationId("1234567");
-        Optional<L3Network> opNetwork = Optional.of(network);
-
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
-
-        String id = workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("id123", id);
-    }
-
-    @Test
-    public void validateNetworkResourceIdInAAIDuplicateNameTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        L3Network network = new L3Network();
-        network.setNetworkId("id123");
-        network.setNetworkName("name123");
-        network.setModelCustomizationId("9999999");
-        Optional<L3Network> opNetwork = Optional.of(network);
-
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "l3Network with name (name123), same parent and different customization id (9999999) already exists. The name must be unique."));
-
-        workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateNetworkResourceIdInAAINotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAINetworksGloballyByName("name123")).thenReturn(true);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "l3Network with name (name123) id (siId123) and different parent relationship already exists. The name must be unique."));
-
-        workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateVnfResourceIdInAAITest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(Optional.empty());
-        String id = workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateVnfResourceIdInAAISameModelCustomizationIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setModelCustomizationId("1234567");
-        Optional<GenericVnf> opVnf = Optional.of(vnf);
-
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
-        String id = workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails,
-                workflowResourceIds);
-        assertEquals("id123", id);
-    }
-
-    @Test
-    public void validateVnfResourceIdInAAIDiffModelCustomizationIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setModelCustomizationId("9999999");
-        Optional<GenericVnf> opVnf = Optional.of(vnf);
-
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "generic-vnf with name (vnfName123), same parent and different customization id (9999999) already exists. The name must be unique."));
-
-        workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateVnfResourceIdInAAINotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        GenericVnfs genericVnfs = new GenericVnfs();
-        genericVnfs.getGenericVnf().add(vnf);
-
-        when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(Optional.empty());
-        when(bbSetupUtils.getAAIVnfsGloballyByName("vnfName123")).thenReturn(genericVnfs);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "generic-vnf with name (vnfName123) id (id123) and different parent relationship already exists. The name must be unique."));
-
-        workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateVfModuleResourceIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(null);
-        when(bbSetupUtils.existsAAIVfModuleGloballyByName("name123")).thenReturn(false);
-
-        String id = workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateVfModuleResourceIdSameModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        VfModules vfModules = new VfModules();
-        VfModule vfModule = new VfModule();
-        vfModule.setVfModuleId("id123");
-        vfModule.setVfModuleName("name123");
-        vfModule.setModelCustomizationId("1234567");
-        vfModules.getVfModule().add(vfModule);
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setVfModules(vfModules);
-
-        when(bbSetupUtils.getAAIGenericVnf("vnfId123")).thenReturn(vnf);
-
-        String id = workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("id123", id);
-    }
-
-    @Test
-    public void validateVfModuleResourceIdDifferentModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        VfModules vfModules = new VfModules();
-        VfModule vfModule = new VfModule();
-        vfModule.setVfModuleId("id123");
-        vfModule.setVfModuleName("name123");
-        vfModule.setModelCustomizationId("9999999");
-        vfModules.getVfModule().add(vfModule);
-
-        GenericVnf vnf = new GenericVnf();
-        vnf.setVnfId("id123");
-        vnf.setVnfName("vnfName123");
-        vnf.setVfModules(vfModules);
-
-        when(bbSetupUtils.getAAIGenericVnf("vnfId123")).thenReturn(vnf);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "vfModule with name (name123), same parent and different customization id (1234567) already exists. The name must be unique."));
-
-        workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
-
-    }
-
-    @Test
-    public void validateVfModuleResourceIdNotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(null);
-        when(bbSetupUtils.existsAAIVfModuleGloballyByName("name123")).thenReturn(true);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException
-                .expectMessage(containsString("vfModule with name name123 already exists. The name must be unique."));
-
-        workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
-    }
-
-    @Test
-    public void validateVolumeGroupResourceIdInAAITest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123")).thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAIVolumeGroupGloballyByName("name123")).thenReturn(false);
-
-        String id = workflowAction.validateVolumeGroupResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateVolumeGroupResourceIdInAAISameModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        workflowResourceIds.setVnfId("vnfId123");
-
-        VolumeGroup volumeGroup = new VolumeGroup();
-        volumeGroup.setVolumeGroupId("id123");
-        volumeGroup.setVolumeGroupName("name123");
-        volumeGroup.setVfModuleModelCustomizationId("1234567");
-
-        Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
-
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("vnfId123", "name123")).thenReturn(opVolumeGroup);
-        String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123",
-                reqDetails, workflowResourceIds);
-
-        assertEquals("id123", id);
-    }
-
-    @Test
-    public void validateVolumeGroupResourceIdInAAIDifferentModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-        workflowResourceIds.setVnfId("vnfId123");
-
-        VolumeGroup volumeGroup = new VolumeGroup();
-        volumeGroup.setVolumeGroupId("id123");
-        volumeGroup.setVolumeGroupName("name123");
-        volumeGroup.setVfModuleModelCustomizationId("9999999");
-
-        Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
-
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("vnfId123", "name123")).thenReturn(opVolumeGroup);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("volumeGroup with name name123 already exists. The name must be unique."));
-
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateVolumeGroupResourceIdInAAINotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setVnfId("vnfId123");
-
-        when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("vnfId123", "name123")).thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAIVolumeGroupGloballyByName("name123")).thenReturn(true);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("volumeGroup with name name123 already exists. The name must be unique."));
-
-        workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateConfigurationResourceIdInAAITest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(false);
-
-        String id = workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("generatedId123", id);
-    }
-
-    @Test
-    public void validateConfigurationResourceIdInAAISameModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
-        configuration.setConfigurationId("id123");
-        configuration.setConfigurationName("name123");
-        configuration.setModelCustomizationId("1234567");
-        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration);
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(opConfiguration);
-        when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(false);
-
-        String id = workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-        assertEquals("id123", id);
-    }
-
-    @Test
-    public void validateConfigurationResourceIdInAAIDifferentModelCustIdTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
-        configuration.setConfigurationId("id123");
-        configuration.setConfigurationName("name123");
-        configuration.setModelCustomizationId("9999999");
-        Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration);
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(opConfiguration);
-        when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(false);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(containsString(
-                "configuration with name (name123), same parent and different customization id (id123) already exists. The name must be unique."));
-
-        workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void validateConfigurationResourceIdInAAINotGloballyUniqueTest() throws Exception {
-        RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
-        WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
-        workflowResourceIds.setServiceInstanceId("siId123");
-
-        when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
-                .thenReturn(Optional.empty());
-        when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(true);
-
-        this.expectedException.expect(DuplicateNameException.class);
-        this.expectedException.expectMessage(
-                containsString("configuration with name name123 already exists. The name must be unique."));
-
-        workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails,
-                workflowResourceIds);
-    }
-
-    @Test
-    public void handleRuntimeExceptionTest() {
-        execution.setVariable("BPMN_javaExpMsg", "test runtime error message");
-        execution.setVariable("testProcessKey", "testProcessKeyValue");
-        try {
-            workflowAction.handleRuntimeException(execution);
-        } catch (BpmnError wfe) {
-            assertEquals("MSOWorkflowException", wfe.getErrorCode());
-        }
-    }
-
-    @Ignore
-    @Test
-    public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException, VrfBondingServiceException {
-        execution.setVariable("testProcessKey", "testProcessKeyValue");
-        Service service = new Service();
-        List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
-        NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
-        networkCust.setModelCustomizationUUID("123");
-        networkCustomizations.add(networkCust);
-        service.setNetworkCustomizations(networkCustomizations);
-        NetworkCollectionResourceCustomization collectionResourceCustomization =
-                new NetworkCollectionResourceCustomization();
-        collectionResourceCustomization.setModelCustomizationUUID("123");
-        CollectionResource collectionResource = new CollectionResource();
-        collectionResource.setToscaNodeType("NetworkCollection");
-        InstanceGroup instanceGroup = new InstanceGroup();
-        List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
-        CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization =
-                new CollectionResourceInstanceGroupCustomization();
-        collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
-        collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
-        instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
-        collectionResource.setInstanceGroup(instanceGroup);
-        collectionResourceCustomization.setCollectionResource(collectionResource);;
-        service.setModelUUID("abc");
-        service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
-        service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
-        doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
-        doReturn(collectionResourceCustomization).when(catalogDbClient)
-                .getNetworkCollectionResourceCustomizationByID("123");
-        String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
-        ObjectMapper mapper = new ObjectMapper();
-        ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
-        List<Resource> resourceCounter = new ArrayList<>();
-        thrown.expect(BpmnError.class);
-        List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
-        workflowAction.traverseCatalogDbService(execution, sIRequest, resourceCounter, aaiResourceIds);
-    }
-
-    @Test
-    public void sortVfModulesByBaseFirstTest() {
-        List<Resource> resources = new ArrayList<>();
-        Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
-        resource1.setBaseVfModule(false);
-        resources.add(resource1);
-        Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
-        resource2.setBaseVfModule(false);
-        resources.add(resource2);
-        Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
-        resource3.setBaseVfModule(true);
-        resources.add(resource3);
-        List<Resource> result = workflowAction.sortVfModulesByBaseFirst(resources);
-        assertEquals("333", result.get(0).getResourceId());
-        assertEquals("222", result.get(1).getResourceId());
-        assertEquals("111", result.get(2).getResourceId());
-    }
-
-    @Test
-    public void sortVfModulesByBaseLastTest() {
-        List<Resource> resources = new ArrayList<>();
-        Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
-        resource1.setBaseVfModule(true);
-        resources.add(resource1);
-        Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
-        resource2.setBaseVfModule(false);
-        resources.add(resource2);
-        Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
-        resource3.setBaseVfModule(false);
-        resources.add(resource3);
-        List<Resource> result = workflowAction.sortVfModulesByBaseLast(resources);
-        assertEquals("333", result.get(0).getResourceId());
-        assertEquals("222", result.get(1).getResourceId());
-        assertEquals("111", result.get(2).getResourceId());
-    }
-
-    @Test
-    public void findCatalogNetworkCollectionTest() {
-        Service service = new Service();
-        NetworkCollectionResourceCustomization networkCustomization = new NetworkCollectionResourceCustomization();
-        networkCustomization.setModelCustomizationUUID("123");
-        service.getCollectionResourceCustomizations().add(networkCustomization);
-        doReturn(networkCustomization).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
-        CollectionResourceCustomization customization = workflowAction.findCatalogNetworkCollection(execution, service);
-        assertNotNull(customization);
-    }
-
-    @Test
-    public void findCatalogNetworkCollectionEmptyTest() {
-        Service service = new Service();
-        NetworkCollectionResourceCustomization networkCustomization = new NetworkCollectionResourceCustomization();
-        networkCustomization.setModelCustomizationUUID("123");
-        service.getCollectionResourceCustomizations().add(networkCustomization);
-        CollectionResourceCustomization customization = workflowAction.findCatalogNetworkCollection(execution, service);
-        assertNull(customization);
-    }
-
-    @Test
-    public void findCatalogNetworkCollectionMoreThanOneTest() {
-        Service service = new Service();
-        NetworkCollectionResourceCustomization networkCustomization1 = new NetworkCollectionResourceCustomization();
-        networkCustomization1.setModelCustomizationUUID("123");
-        NetworkCollectionResourceCustomization networkCustomization2 = new NetworkCollectionResourceCustomization();
-        networkCustomization2.setModelCustomizationUUID("321");
-        service.getCollectionResourceCustomizations().add(networkCustomization1);
-        service.getCollectionResourceCustomizations().add(networkCustomization2);
-        doReturn(networkCustomization1).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
-        doReturn(networkCustomization2).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("321");
-        workflowAction.findCatalogNetworkCollection(execution, service);
-        assertEquals("Found multiple Network Collections in the Service model, only one per Service is supported.",
-                execution.getVariable("WorkflowActionErrorMessage"));
-    }
-
-    @Test
-    public void verifyLackOfNullPointerExceptionForNullResource() {
-        ExecuteBuildingBlock result = null;
-        try {
-            result = workflowAction.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null,
-                    false, null, null, null, false, null, null, true, null);
-        } catch (NullPointerException e) {
-            fail("NullPointerException should not be thrown when 'resource' is null");
-        }
-        assertNotNull(result);
-    }
-
-    @Test
-    public void traverseAAIServiceTest() {
-        List<Resource> resourceCounter = new ArrayList<>();
-        String resourceId = "si0";
-        List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
-
-        ServiceInstance serviceInstanceAAI = new ServiceInstance();
-        serviceInstanceAAI.setServiceInstanceId(resourceId);
-
-        org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = setServiceInstance();
-        setGenericVnf();
-        setVfModule(true);
-        setVolumeGroup();
-        setL3Network();
-        setCollection();
-        setConfiguration();
-
-        Configuration config = new Configuration();
-        config.setConfigurationId("testConfigurationId2");
-        serviceInstance.getConfigurations().add(config);
-
-        Relationship relationship1 = new Relationship();
-        relationship1.setRelatedTo("vnfc");
-        RelationshipList relationshipList1 = new RelationshipList();
-        relationshipList1.getRelationship().add(relationship1);
-
-        Relationship relationship2 = new Relationship();
-        relationship2.setRelatedTo("vpn-binding");
-        RelationshipList relationshipList2 = new RelationshipList();
-        relationshipList2.getRelationship().add(relationship2);
-
-        org.onap.aai.domain.yang.Configuration aaiConfiguration1 = new org.onap.aai.domain.yang.Configuration();
-        aaiConfiguration1.setConfigurationId("testConfigurationId");
-        aaiConfiguration1.setRelationshipList(relationshipList1);
-
-        org.onap.aai.domain.yang.Configuration aaiConfiguration2 = new org.onap.aai.domain.yang.Configuration();
-        aaiConfiguration2.setConfigurationId("testConfigurationId2");
-        aaiConfiguration2.setRelationshipList(relationshipList1);
-
-        try {
-            doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById(resourceId);
-            doReturn(serviceInstance).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
-            doReturn(Optional.of(aaiConfiguration1)).when(aaiConfigurationResources)
-                    .getConfiguration("testConfigurationId");
-            doReturn(Optional.of(aaiConfiguration2)).when(aaiConfigurationResources)
-                    .getConfiguration("testConfigurationId2");
-            workflowAction.traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds);
-            assertEquals(8, resourceCounter.size());
-            assertTrue(resourceCounter.get(2).isBaseVfModule());
-            assertThat(aaiResourceIds, sameBeanAs(getExpectedResourceIds()));
-        } catch (Exception e) {
-            fail("Unexpected exception was thrown.");
+    private List<Resource> prepareListWithResources(boolean addPnf, boolean addPriorites) {
+        List<Resource> resourceList = new ArrayList<>();
+        Resource r1 = new Resource(WorkflowType.SERVICE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false, null);
+        resourceList.add(r1);
+        Resource r2 = new Resource(WorkflowType.VNF, "ab153b6e-c364-44c0-bef6-1f2982117f04", false, r1);
+        resourceList.add(r2);
+        Resource r3 = new Resource(WorkflowType.VOLUMEGROUP, "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", false, r2);
+        resourceList.add(r3);
+        Resource r4 = new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false, r2);
+        resourceList.add(r4);
+        Resource r5 = new Resource(WorkflowType.VFMODULE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false, r2);
+        resourceList.add(r5);
+        Resource r6 = new Resource(WorkflowType.VFMODULE, "da4d4327-fb7d-4311-ac7a-be7ba60cf969", false, r2);
+        resourceList.add(r6);
+        if (addPnf) {
+            Resource r7 = new Resource(WorkflowType.PNF, "aa153b6e-c364-44c0-bef6-1f2982117f04", false, r1);
+            resourceList.add(r7);
         }
-    }
-
-    private List<Pair<WorkflowType, String>> getExpectedResourceIds() {
-        List<Pair<WorkflowType, String>> resourceIds = new ArrayList<>();
-        resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, "testVnfId1"));
-        resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VFMODULE, "testVfModuleId1"));
-        resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP, "testVolumeGroupId1"));
-        resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORK, "testNetworkId1"));
-        resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION, "testId"));
-        resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, "testConfigurationId"));
-        resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, "testConfigurationId2"));
-        return resourceIds;
-    }
-
-    private List<OrchestrationFlow> createFlowList(String... flowNames) {
-        List<OrchestrationFlow> result = new ArrayList<>();
-        for (String flowName : flowNames) {
-            OrchestrationFlow orchFlow = new OrchestrationFlow();
-            orchFlow.setFlowName(flowName);
-            result.add(orchFlow);
+        if (addPriorites) {
+            r3.setProcessingPriority(2);
+            r4.setProcessingPriority(1);
+            r5.setProcessingPriority(4);
+            r5.setBaseVfModule(true);
+            r6.setProcessingPriority(3);
         }
-        return result;
-    }
-
-    private void assertEqualsBulkFlowName(List<ExecuteBuildingBlock> ebbs, String... flowNames) {
-        for (int i = 0; i < ebbs.size(); i++) {
-            assertEquals(ebbs.get(i).getBuildingBlock().getBpmnFlowName(), flowNames[i]);
-        }
-    }
-
-    private void initExecution(String gAction, String bpmnRequest, boolean isAlaCarte) {
-        execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
-        execution.setVariable("requestAction", gAction);
-        execution.setVariable("bpmnRequest", bpmnRequest);
-        execution.setVariable("aLaCarte", isAlaCarte);
-        execution.setVariable("apiVersion", "7");
-    }
-
-    private String readBpmnRequestFromFile(String fileName) throws IOException {
-        return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/" + fileName)));
+        return resourceList;
     }
 }