From 223aed1447650c9fe4c0b8c3402622171abdfce4 Mon Sep 17 00:00:00 2001 From: "Kuleshov, Elena" Date: Thu, 19 Nov 2020 18:06:15 -0500 Subject: incorrect filtering of config bbs on Fix configuration BB setup for replaceInstance cases Fix configuration BB setup for replaceInstance cases Formatting fixes for workflowAction. Issue-ID: SO-3396 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Ia08e5d9c9057d2b991fb33fa89bfd833afc50d12 --- .../workflow/tasks/WorkflowActionBBTasksTest.java | 147 +++++++++++++++++++-- 1 file changed, 133 insertions(+), 14 deletions(-) (limited to 'bpmn/so-bpmn-tasks/src/test') diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 0384a28cdc..b7529bdeb8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -613,7 +613,73 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test - public void postProcessingExecuteBBActivateVfModuleTest() throws CloneNotSupportedException { + public void postProcessingExecuteBBActivateVfModuleNotReplaceInstanceTest() throws CloneNotSupportedException { + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("1"); + workflowResourceIds.setVnfId("1"); + + BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule); + ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds); + ebbActivateVfModule.setResourceId("1"); + + ServiceInstance service = new ServiceInstance(); + service.setServiceInstanceName("name"); + service.setModelVersionId("1"); + doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfName("name"); + vnf.setModelCustomizationId("1"); + doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1"); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleName("name"); + vfModule.setModelCustomizationId("1"); + doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1"); + + List vnfcs = new ArrayList(); + org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); + vnfc.setModelInvariantId("1"); + vnfc.setVnfcName("name"); + vnfc.setModelCustomizationId("2"); + vnfcs.add(vnfc); + doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any()); + + CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization(); + ConfigurationResource configuration = new ConfigurationResource(); + configuration.setToscaNodeType("FabricConfiguration"); + configuration.setModelUUID("1"); + vfModuleCustomization.setConfigurationResource(configuration); + + doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2"); + + prepareDelegateExecution(); + List flowsToExecute = new ArrayList<>(); + flowsToExecute.add(ebbActivateVfModule); + + execution.setVariable("requestAction", "createInstance"); + execution.setVariable("completed", true); + + ArgumentCaptor executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); + ArgumentCaptor bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); + ArgumentCaptor listCaptor = ArgumentCaptor.forClass(List.class); + workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute); + verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), + bbCaptor.capture(), listCaptor.capture()); + assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed")); + assertEquals(2, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size()); + assertEquals("2", + ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0) + .getVariable("flowsToExecute")).get(1)).getConfigurationResourceKeys() + .getCvnfcCustomizationUUID()); + assertEquals("AddFabricConfigurationBB", ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues() + .get(0).getVariable("flowsToExecute")).get(1)).getBuildingBlock().getBpmnFlowName()); + } + + @Test + public void postProcessingExecuteBBActivateVfModuleReplaceInstanceHasConfigurationTest() + throws CloneNotSupportedException { BuildingBlock bbAddFabric = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB"); ExecuteBuildingBlock ebbAddFabric = new ExecuteBuildingBlock().setBuildingBlock(bbAddFabric); @@ -628,7 +694,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds); ebbActivateVfModule.setResourceId("1"); ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); - ebbActivateVfModule.setConfigurationResourceKeys(configurationResourceKeys); + ebbAddFabric.setConfigurationResourceKeys(configurationResourceKeys); ServiceInstance service = new ServiceInstance(); service.setServiceInstanceName("name"); @@ -664,35 +730,88 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { prepareDelegateExecution(); List flowsToExecute = new ArrayList<>(); flowsToExecute.add(ebbActivateVfModule); + flowsToExecute.add(ebbAddFabric); ArgumentCaptor executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); ArgumentCaptor bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); ArgumentCaptor listCaptor = ArgumentCaptor.forClass(List.class); - workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbAddFabric, flowsToExecute); + + execution.setVariable("requestAction", "replaceInstance"); + execution.setVariable("completed", true); + workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute); verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), bbCaptor.capture(), listCaptor.capture()); assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed")); assertEquals(2, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size()); - assertEquals(null, + assertEquals("2", ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0) - .getVariable("flowsToExecute")).get(0)).getConfigurationResourceKeys() + .getVariable("flowsToExecute")).get(1)).getConfigurationResourceKeys() .getCvnfcCustomizationUUID()); + } + @Test + public void postProcessingExecuteBBActivateVfModuleReplaceInstanceHasNoConfigurationTest() + throws CloneNotSupportedException { - execution.setVariable("requestAction", "replaceInstance"); - flowsToExecute = new ArrayList<>(); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("1"); + workflowResourceIds.setVnfId("1"); + + BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule); + ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds); + ebbActivateVfModule.setResourceId("1"); + + ServiceInstance service = new ServiceInstance(); + service.setServiceInstanceName("name"); + service.setModelVersionId("1"); + doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfName("name"); + vnf.setModelCustomizationId("1"); + doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1"); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleName("name"); + vfModule.setModelCustomizationId("1"); + doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1"); + + List vnfcs = new ArrayList(); + org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); + vnfc.setModelInvariantId("1"); + vnfc.setVnfcName("name"); + vnfc.setModelCustomizationId("2"); + vnfcs.add(vnfc); + doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any()); + + CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization(); + ConfigurationResource configuration = new ConfigurationResource(); + configuration.setToscaNodeType("FabricConfiguration"); + configuration.setModelUUID("1"); + vfModuleCustomization.setConfigurationResource(configuration); + + doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2"); + + prepareDelegateExecution(); + List flowsToExecute = new ArrayList<>(); flowsToExecute.add(ebbActivateVfModule); + + ArgumentCaptor executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); + ArgumentCaptor bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); + ArgumentCaptor listCaptor = ArgumentCaptor.forClass(List.class); + + execution.setVariable("requestAction", "replaceInstance"); + execution.setVariable("completed", true); + workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute); - verify(workflowActionBBTasks, times(2)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), + verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), bbCaptor.capture(), listCaptor.capture()); - assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed")); - assertEquals(1, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size()); - assertEquals("2", - ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0) - .getVariable("flowsToExecute")).get(0)).getConfigurationResourceKeys() - .getCvnfcCustomizationUUID()); + assertEquals(true, executionCaptor.getAllValues().get(0).getVariable("completed")); } + + @Test public void getExecuteBBForConfigTest() throws CloneNotSupportedException { BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); -- cgit 1.2.3-korg