diff options
author | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2021-08-04 06:51:34 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-08-04 06:51:34 +0000 |
commit | 872613eafe80034cca612bd93294286b3dbed4b1 (patch) | |
tree | 0f14309d02bb1ea862368095a65ebfd04871884d /bpmn/so-bpmn-tasks/src/test | |
parent | e32fa2efac9f9b9e5a01a86f494664714042c352 (diff) | |
parent | ed5c51313c1bd3745a554888c969e840341599b0 (diff) |
Merge "Support instantiation of same model vnfs/vf-modules"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
4 files changed, 438 insertions, 16 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index e52d2dfecf..021bac3a7a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -51,8 +51,11 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; 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; @@ -118,6 +121,8 @@ public class WorkflowActionTest extends BaseTaskTest { 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; @@ -752,6 +757,139 @@ public class WorkflowActionTest extends BaseTaskTest { } @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"; String resource = "Service"; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java index 58fee86ade..cac7f872b3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java @@ -53,6 +53,7 @@ import java.util.stream.Collectors; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -63,6 +64,8 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest { private static final String MACRO_ASSIGN_PNF_JSON = "Macro/ServiceMacroAssignPnf.json"; private static final String NETWORK_COLLECTION_JSON = "Macro/CreateNetworkCollection.json"; private static final String MACRO_CREATE_WITHOUT_RESOURCES_JSON = "Macro/ServiceMacroCreateWithoutResources.json"; + private static final String MACRO_CREATE_SVC_SAME_MODEL_VNF_VFMODULE = + "Macro/ServiceMacroCreateMultipleSameModelVnfsAndVfModules.json"; private static final String serviceInstanceId = "123"; private DelegateExecution execution; private CatalogDbClient mockCatalogDbClient; @@ -80,8 +83,6 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest { @Test public void getResourceListFromUserParams() throws Exception { initExecution(requestAction, readBpmnRequestFromFile(MACRO_CREATE_WITHOUT_RESOURCES_JSON), false); - Mockito.doReturn(getVfModuleCustomization()).when(mockCatalogDbClient) - .getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); Mockito.doReturn(getCvnfcCustomizations()).when(mockCatalogDbClient).getCvnfcCustomization(anyString(), anyString(), anyString()); @@ -96,9 +97,62 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest { } @Test + public void getResourceListFromUserParamsMultipleSameModelVnfVfModule() throws Exception { + initExecution("createInstance", readBpmnRequestFromFile(MACRO_CREATE_SVC_SAME_MODEL_VNF_VFMODULE), false); + Mockito.doReturn(getVfModuleCustomization("3bd19000-6d21-49f1-9eb3-ea76a6eac5e0", false)) + .when(mockCatalogDbClient) + .getVfModuleCustomizationByModelCuztomizationUUID("3bd19000-6d21-49f1-9eb3-ea76a6eac5e0"); + Mockito.doReturn(getVfModuleCustomization("83677d89-428a-407b-b4ec-738e68275d84", false)) + .when(mockCatalogDbClient) + .getVfModuleCustomizationByModelCuztomizationUUID("83677d89-428a-407b-b4ec-738e68275d84"); + + List<Resource> resources = userParamsServiceTraversal.getResourceListFromUserParams(execution, getUserParams(), + serviceInstanceId, requestAction); + + assertEquals(7, resources.size()); + + Resource service = resources.get(0); + assertTrue(service.getResourceType() == WorkflowType.SERVICE); + assertEquals(2, service.getChildren().size()); + + Resource vnf1 = service.getChildren().get(0); + assertEquals(service, vnf1.getParent()); + assertEquals("vnf-instanceName-1", vnf1.getInstanceName()); + assertEquals("0d0ba1ee-6b7f-47fe-8266-2967993b2c08", vnf1.getResourceId()); + assertEquals(2, vnf1.getChildren().size()); + + Resource vnf2 = service.getChildren().get(1); + assertEquals(service, vnf2.getParent()); + assertEquals("vnf-instanceName-2", vnf2.getInstanceName()); + assertEquals("0d0ba1ee-6b7f-47fe-8266-2967993b2c08", vnf2.getResourceId()); + assertEquals(2, vnf2.getChildren().size()); + + Resource vfmodule1 = vnf1.getChildren().get(0); + assertEquals(vnf1, vfmodule1.getParent()); + assertEquals("demo-network-1", vfmodule1.getInstanceName()); + assertEquals("3bd19000-6d21-49f1-9eb3-ea76a6eac5e0", vfmodule1.getResourceId()); + + Resource vfmodule2 = vnf1.getChildren().get(1); + assertEquals(vnf1, vfmodule2.getParent()); + assertEquals("demo-1", vfmodule2.getInstanceName()); + assertEquals("83677d89-428a-407b-b4ec-738e68275d84", vfmodule2.getResourceId()); + + Resource vfmodule3 = vnf2.getChildren().get(0); + assertEquals(vnf2, vfmodule3.getParent()); + assertEquals("demo-2", vfmodule3.getInstanceName()); + assertEquals("83677d89-428a-407b-b4ec-738e68275d84", vfmodule3.getResourceId()); + + Resource vfmodule4 = vnf2.getChildren().get(1); + assertEquals(vnf2, vfmodule4.getParent()); + assertEquals("demo-3", vfmodule4.getInstanceName()); + assertEquals("83677d89-428a-407b-b4ec-738e68275d84", vfmodule4.getResourceId()); + } + + @Test public void getResourceListFromUserParamsForVnfs() throws Exception { initExecution(requestAction, readBpmnRequestFromFile(MACRO_ASSIGN_JSON), false); - Mockito.doReturn(getVfModuleCustomization()).when(mockCatalogDbClient) + Mockito.doReturn(getVfModuleCustomization("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", true)) + .when(mockCatalogDbClient) .getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); Mockito.doReturn(getCvnfcCustomizations()).when(mockCatalogDbClient).getCvnfcCustomization(anyString(), anyString(), anyString()); @@ -117,7 +171,8 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest { @Test public void getResourceListFromUserParamsForVnfsWithPriorities() throws Exception { initExecution(requestAction, readBpmnRequestFromFile(MACRO_CREATE_JSON), false); - Mockito.doReturn(getVfModuleCustomization()).when(mockCatalogDbClient) + Mockito.doReturn(getVfModuleCustomization("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", true)) + .when(mockCatalogDbClient) .getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); Mockito.doReturn(getCvnfcCustomizations()).when(mockCatalogDbClient).getCvnfcCustomization(anyString(), anyString(), anyString()); @@ -137,8 +192,6 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest { @Test public void getResourceListFromUserParamsForPnfs() throws Exception { initExecution(requestAction, readBpmnRequestFromFile(MACRO_ASSIGN_PNF_JSON), false); - Mockito.doReturn(getVfModuleCustomization()).when(mockCatalogDbClient) - .getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); Mockito.doReturn(getCvnfcCustomizations()).when(mockCatalogDbClient).getCvnfcCustomization(anyString(), anyString(), anyString()); @@ -156,8 +209,6 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest { public void getResourceListFromUserParamsForNetworks() throws Exception { requestAction = "createInstance"; initExecution(requestAction, readBpmnRequestFromFile(NETWORK_COLLECTION_JSON), false); - Mockito.doReturn(getVfModuleCustomization()).when(mockCatalogDbClient) - .getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); Mockito.doReturn(getCvnfcCustomizations()).when(mockCatalogDbClient).getCvnfcCustomization(anyString(), anyString(), anyString()); Mockito.doReturn(getService()).when(mockCatalogDbClient).getServiceByID(anyString()); @@ -230,13 +281,17 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest { return service; } - private VfModuleCustomization getVfModuleCustomization() { + private VfModuleCustomization getVfModuleCustomization(String modelCustomizationUUID, boolean includeVolumeGroup) { VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); - vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment()); - vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); + vfModuleCustomization.setModelCustomizationUUID(modelCustomizationUUID); VfModule vfModule = new VfModule(); - vfModule.setVolumeHeatTemplate(new HeatTemplate()); - vfModule.setModelName("helm"); + if (includeVolumeGroup) { + vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment()); + vfModule.setVolumeHeatTemplate(new HeatTemplate()); + vfModule.setModelName("helm"); + } else { + vfModuleCustomization.setHeatEnvironment(new HeatEnvironment()); + } vfModule.setModuleHeatTemplate(new HeatTemplate()); vfModuleCustomization.setVfModule(vfModule); return vfModuleCustomization; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtilsTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtilsTest.java index 0d68cf362b..996c0c07e1 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtilsTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtilsTest.java @@ -40,7 +40,8 @@ public class WorkflowResourceIdsUtilsTest { private static final String PNF_ID = "pnfId"; private static final String NETWORK_COLLECTION_ID = "networkCollectionId"; private static final String CONFIGURATION_ID = "configurationId"; - + private static final String VNF_INSTANCE_NAME = "vnfInstanceNameId"; + private static final String VF_MODULE_INSTANCE_NAME = "vfModuleInstanceNameId"; private WorkflowResourceIds workflowResourceIds; @Before @@ -57,6 +58,8 @@ public class WorkflowResourceIdsUtilsTest { execution.setVariable("vnfId", VNF_ID); execution.setVariable("volumeGroupId", VOLUME_GROUP_ID); execution.setVariable("instanceGroupId", INSTANCE_GROUP_ID); + execution.setVariable("vnfInstanceName", VNF_INSTANCE_NAME); + execution.setVariable("vfModuleInstanceName", VF_MODULE_INSTANCE_NAME); workflowResourceIds = WorkflowResourceIdsUtils.getWorkflowResourceIdsFromExecution(execution); @@ -66,54 +69,84 @@ public class WorkflowResourceIdsUtilsTest { assertEquals(VNF_ID, workflowResourceIds.getVnfId()); assertEquals(VOLUME_GROUP_ID, workflowResourceIds.getVolumeGroupId()); assertEquals(INSTANCE_GROUP_ID, workflowResourceIds.getInstanceGroupId()); + assertEquals(VNF_INSTANCE_NAME, workflowResourceIds.getVnfInstanceName()); + assertEquals(VF_MODULE_INSTANCE_NAME, workflowResourceIds.getVfModuleInstanceName()); } @Test public void shouldProperlySetServiceInstanceId() { assertFieldSetProperly(WorkflowType.SERVICE, SERVICE_ID, workflowResourceIds::getServiceInstanceId); + assertEquals(SERVICE_ID, + WorkflowResourceIdsUtils.getResourceIdByWorkflowType(workflowResourceIds, WorkflowType.SERVICE)); } @Test public void shouldProperlySetVnfId() { assertFieldSetProperly(WorkflowType.VNF, VNF_ID, workflowResourceIds::getVnfId); - + assertEquals(VNF_ID, + WorkflowResourceIdsUtils.getResourceIdByWorkflowType(workflowResourceIds, WorkflowType.VNF)); } @Test public void shouldProperlySetPnfId() { assertFieldSetProperly(WorkflowType.PNF, PNF_ID, workflowResourceIds::getPnfId); + assertEquals(PNF_ID, + WorkflowResourceIdsUtils.getResourceIdByWorkflowType(workflowResourceIds, WorkflowType.PNF)); } @Test public void shouldProperlySetVfModuleId() { assertFieldSetProperly(WorkflowType.VFMODULE, VF_MODULE_ID, workflowResourceIds::getVfModuleId); + assertEquals(VF_MODULE_ID, + WorkflowResourceIdsUtils.getResourceIdByWorkflowType(workflowResourceIds, WorkflowType.VFMODULE)); } @Test public void shouldProperlySetVolumeGroupId() { assertFieldSetProperly(WorkflowType.VOLUMEGROUP, VOLUME_GROUP_ID, workflowResourceIds::getVolumeGroupId); + assertEquals(VOLUME_GROUP_ID, + WorkflowResourceIdsUtils.getResourceIdByWorkflowType(workflowResourceIds, WorkflowType.VOLUMEGROUP)); } @Test public void shouldProperlySetNetworkId() { assertFieldSetProperly(WorkflowType.NETWORK, NETWORK_ID, workflowResourceIds::getNetworkId); + assertEquals(NETWORK_ID, + WorkflowResourceIdsUtils.getResourceIdByWorkflowType(workflowResourceIds, WorkflowType.NETWORK)); } @Test public void shouldProperlySetNetworkCollectionId() { assertFieldSetProperly(WorkflowType.NETWORKCOLLECTION, NETWORK_COLLECTION_ID, workflowResourceIds::getNetworkCollectionId); - + assertEquals(NETWORK_COLLECTION_ID, WorkflowResourceIdsUtils.getResourceIdByWorkflowType(workflowResourceIds, + WorkflowType.NETWORKCOLLECTION)); } @Test public void shouldProperlySetConfigurationId() { assertFieldSetProperly(WorkflowType.CONFIGURATION, CONFIGURATION_ID, workflowResourceIds::getConfigurationId); + assertEquals(CONFIGURATION_ID, + WorkflowResourceIdsUtils.getResourceIdByWorkflowType(workflowResourceIds, WorkflowType.CONFIGURATION)); } @Test public void shouldProperlySetInstanceGroupId() { assertFieldSetProperly(WorkflowType.INSTANCE_GROUP, INSTANCE_GROUP_ID, workflowResourceIds::getInstanceGroupId); + assertEquals(INSTANCE_GROUP_ID, + WorkflowResourceIdsUtils.getResourceIdByWorkflowType(workflowResourceIds, WorkflowType.INSTANCE_GROUP)); + } + + @Test + public void shouldPropertySetVnfInstanceName() { + assertFieldSetProperlyInstanceName(WorkflowType.VNF, VNF_INSTANCE_NAME, + workflowResourceIds::getVnfInstanceName); + } + + @Test + public void shouldPropertySetVfModuleInstanceName() { + assertFieldSetProperlyInstanceName(WorkflowType.VFMODULE, VF_MODULE_INSTANCE_NAME, + workflowResourceIds::getVfModuleInstanceName); } private void assertFieldSetProperly(WorkflowType workflowType, String expectedId, @@ -121,4 +154,13 @@ public class WorkflowResourceIdsUtilsTest { WorkflowResourceIdsUtils.setResourceIdByWorkflowType(workflowResourceIds, workflowType, expectedId); assertEquals(expectedId, testedObjectField.get()); } + + private void assertFieldSetProperlyInstanceName(WorkflowType workflowType, String expectedId, + Supplier<String> testedObjectField) { + WorkflowResourceIdsUtils.setInstanceNameByWorkflowType(workflowResourceIds, workflowType, expectedId); + assertEquals(expectedId, testedObjectField.get()); + } + + + } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroCreateMultipleSameModelVnfsAndVfModules.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroCreateMultipleSameModelVnfsAndVfModules.json new file mode 100644 index 0000000000..059754846a --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroCreateMultipleSameModelVnfsAndVfModules.json @@ -0,0 +1,187 @@ +{ + "requestDetails": { + "subscriberInfo": { + "globalSubscriberId": "test-customer" + }, + "requestInfo": { + "suppressRollback": false, + "instanceName": "test", + "productFamilyId": "6ea37d21-1a8d-4cd5-a727-e543191a5bb6", + "requestorId": "portal", + "source": "source" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "cloudid", + "tenantId": "tenantid", + "cloudOwner": "cloudowner" + }, + "requestParameters": { + "subscriptionServiceType": "ubuntu", + "userParams": [ + { + "Homing_Solution": "none" + }, + { + "service": { + "instanceParams": [], + "resources": { + "vnfs": [ + { + "modelInfo": { + "modelName": "UbuntuVF", + "modelVersionId": "744a1610-782e-47cf-bb45-d83319e33e17", + "modelInvariantUuid": "fc573bb4-d312-48ab-b81d-8b3313df4d07", + "modelVersion": "1.0", + "modelCustomizationId": "0d0ba1ee-6b7f-47fe-8266-2967993b2c08", + "modelInstanceName": "Ubuntu VF 0" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "cloudid", + "tenantId": "tenantid", + "cloudOwner": "cloudowner" + }, + "platform": { + "platformName": "platform" + }, + "lineOfBusiness": { + "lineOfBusinessName": "lob" + }, + "productFamilyId": "6ea37d21-1a8d-4cd5-a727-e543191a5bb6\n", + "instanceName": "vnf-instanceName-1", + "instanceParams": [ + { + "vnf-name": "vnf-vnf-name", + "vnf_name": "UbuntuVNFName" + } + ], + "vfModules": [ + { + "modelInfo": { + "modelName": "UbuntuVF..base..module-0", + "modelVersionId": "8fa495ac-d057-4060-b772-868d8e97766e", + "modelInvariantUuid": "71dcbf41-9838-4b3d-baa4-4024d22ef0cc", + "modelVersion": "1", + "modelCustomizationId": "3bd19000-6d21-49f1-9eb3-ea76a6eac5e0" + }, + "instanceName": "demo-network-1", + "instanceParams": [ + { + "name": "demo-network-1", + "cidr": "10.10.10.0/24" + } + ] + }, + { + "modelInfo": { + "modelName": "UbuntuVF..base..module-1", + "modelVersionId": "21954495-830f-48b7-b7b2-030d837789b3", + "modelInvariantUuid": "90355af6-55f3-460e-abe6-bec9a27a15e6", + "modelVersion": "1", + "modelCustomizationId": "83677d89-428a-407b-b4ec-738e68275d84" + }, + "instanceName": "demo-1", + "instanceParams": [ + { + "name": "demo-ubuntu-1", + "network_mgmt": "vlan101", + "network_name": "demo-network-1" + } + ] + } + ] + }, + { + "modelInfo": { + "modelName": "UbuntuVF", + "modelVersionId": "744a1610-782e-47cf-bb45-d83319e33e17", + "modelInvariantUuid": "fc573bb4-d312-48ab-b81d-8b3313df4d07", + "modelVersion": "1.0", + "modelCustomizationId": "0d0ba1ee-6b7f-47fe-8266-2967993b2c08", + "modelInstanceName": "Ubuntu VF 0" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "cloudid", + "tenantId": "tenantid", + "cloudOwner": "cloudowner" + }, + "platform": { + "platformName": "platform" + }, + "lineOfBusiness": { + "lineOfBusinessName": "lob" + }, + "productFamilyId": "6ea37d21-1a8d-4cd5-a727-e543191a5bb6\n", + "instanceName": "vnf-instanceName-2", + "instanceParams": [ + { + "vnf-name": "vnf-vnf-name", + "vnf_name": "UbuntuVNFName" + } + ], + "vfModules": [ + { + "modelInfo": { + "modelName": "UbuntuVF..base..module-1", + "modelVersionId": "21954495-830f-48b7-b7b2-030d837789b3", + "modelInvariantUuid": "90355af6-55f3-460e-abe6-bec9a27a15e6", + "modelVersion": "1", + "modelCustomizationId": "83677d89-428a-407b-b4ec-738e68275d84" + }, + "instanceName": "demo-2", + "instanceParams": [ + { + "name": "demo-ubuntu-2", + "network_mgmt": "vlan101", + "network_name": "demo-network-1" + } + ] + }, + { + "modelInfo": { + "modelName": "UbuntuVF..base..module-1", + "modelVersionId": "21954495-830f-48b7-b7b2-030d837789b3", + "modelInvariantUuid": "90355af6-55f3-460e-abe6-bec9a27a15e6", + "modelVersion": "1", + "modelCustomizationId": "83677d89-428a-407b-b4ec-738e68275d84" + }, + "instanceName": "demo-3", + "instanceParams": [ + { + "name": "demo-ubuntu-3", + "network_mgmt": "vlan101", + "network_name": "demo-network-1" + } + ] + } + ] + } + ] + }, + "modelInfo": { + "modelVersion": "1.0", + "modelVersionId": "f2444885-3c76-4ddc-8668-7741c0631495", + "modelInvariantId": "3bd19000-6d21-49f1-9eb3-ea76a6eac5e0", + "modelName": "UbuntuSVC", + "modelType": "service" + } + } + } + ], + "aLaCarte": false + }, + "project": { + "projectName": "Project-UbuntuDemo" + }, + "owningEntity": { + "owningEntityId": "33a8b609-1cfe-4d19-8dc2-5b95b921de1e", + "owningEntityName": "demo" + }, + "modelInfo": { + "modelVersion": "1.0", + "modelVersionId": "f2444885-3c76-4ddc-8668-7741c0631495", + "modelInvariantId": "3bd19000-6d21-49f1-9eb3-ea76a6eac5e0", + "modelName": "UbuntuSVC", + "modelType": "service" + } + } +}
\ No newline at end of file |