diff options
author | Steve Smokowski <ss835w@att.com> | 2020-11-30 14:49:34 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-11-30 14:49:34 +0000 |
commit | aec0236281f227a0a68b38ca7b0e56e50ffa95b7 (patch) | |
tree | b7268ffebef0eac17699c7f39b95cc364bbbf153 /bpmn | |
parent | 2ec5cc6941918a3e525afa1e406835b6051e097b (diff) | |
parent | 223aed1447650c9fe4c0b8c3402622171abdfce4 (diff) |
Merge "incorrect filtering of config bbs on"
Diffstat (limited to 'bpmn')
2 files changed, 143 insertions, 20 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 5e281cff87..554385d043 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -450,14 +450,18 @@ public class WorkflowActionBBTasks { if (requestAction.equalsIgnoreCase("replaceInstance") || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) { List<ExecuteBuildingBlock> configBBs = flowsToExecute.stream() - .filter(item -> !item.getBuildingBlock().getBpmnFlowName().matches(CONFIGURATION_PATTERN)) + .filter(item -> item.getBuildingBlock().getBpmnFlowName().matches(CONFIGURATION_PATTERN)) .collect(Collectors.toList()); - for (ExecuteBuildingBlock bb : configBBs) { - bb.getConfigurationResourceKeys().setCvnfcCustomizationUUID(modelCustomizationId); - bb.getConfigurationResourceKeys().setVnfcName(vnfc.getVnfcName()); + if (configBBs != null && configBBs.size() > 0) { + for (ExecuteBuildingBlock bb : configBBs) { + if (bb.getConfigurationResourceKeys() != null) { + bb.getConfigurationResourceKeys().setCvnfcCustomizationUUID(modelCustomizationId); + bb.getConfigurationResourceKeys().setVnfcName(vnfc.getVnfcName()); + } + } + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable(COMPLETED, false); } - execution.setVariable("flowsToExecute", flowsToExecute); - execution.setVariable(COMPLETED, false); } else { CvnfcConfigurationCustomization fabricConfig = catalogDbClient.getCvnfcCustomization( serviceModelUUID, vnfCustomizationUUID, vfModuleCustomizationUUID, modelCustomizationId); 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<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + 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<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + flowsToExecute.add(ebbActivateVfModule); + + execution.setVariable("requestAction", "createInstance"); + execution.setVariable("completed", true); + + ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); + ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); + ArgumentCaptor<List> 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<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); flowsToExecute.add(ebbActivateVfModule); + flowsToExecute.add(ebbAddFabric); ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); ArgumentCaptor<List> 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<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + 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<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); flowsToExecute.add(ebbActivateVfModule); + + ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); + ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); + ArgumentCaptor<List> 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"); |