diff options
author | kjaniak <kornel.janiak@nokia.com> | 2019-12-19 13:08:05 +0100 |
---|---|---|
committer | kjaniak <kornel.janiak@nokia.com> | 2020-01-22 14:22:58 +0100 |
commit | 48fbeba2e552d6de26ed1f638ec7736c35d18019 (patch) | |
tree | 62a3c3db301c90e17f2619fa24a770d494d1babe /bpmn/so-bpmn-tasks | |
parent | 17413ddf83ba8a51e978b368313cd366d57b1e48 (diff) |
Add fluent setters for BuildingBlocks and ExecuteBuildingBlock
Test which check more than one functionallity were separarted.
Minor code improvements around BB and EBB.
Issue-ID: SO-2582
Change-Id: I318f8ac299f7204fdd6799108182a29e519724d9
Signed-off-by: kjaniak <kornel.janiak@nokia.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks')
8 files changed, 232 insertions, 312 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java index 0c31dfa16f..533dd89276 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java @@ -6,12 +6,14 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -151,32 +153,24 @@ public class ExecuteActivity implements JavaDelegate { } protected BuildingBlock buildBuildingBlock(String activityName) { - BuildingBlock buildingBlock = new BuildingBlock(); - buildingBlock.setBpmnFlowName(activityName); - buildingBlock.setMsoId(UUID.randomUUID().toString()); - buildingBlock.setKey(""); - buildingBlock.setIsVirtualLink(false); - buildingBlock.setVirtualLinkKey(""); + BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(activityName) + .setMsoId(UUID.randomUUID().toString()).setKey("").setIsVirtualLink(false).setVirtualLinkKey(""); return buildingBlock; } protected ExecuteBuildingBlock buildExecuteBuildingBlock(DelegateExecution execution, String requestId, BuildingBlock buildingBlock) throws Exception { - ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); - String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST); - ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); - RequestDetails requestDetails = sIRequest.getRequestDetails(); - executeBuildingBlock.setaLaCarte(true); - executeBuildingBlock.setRequestAction((String) execution.getVariable(G_ACTION)); - executeBuildingBlock.setResourceId((String) execution.getVariable(VNF_ID)); - executeBuildingBlock.setVnfType((String) execution.getVariable(VNF_TYPE)); WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId((String) execution.getVariable(SERVICE_INSTANCE_ID)); workflowResourceIds.setVnfId((String) execution.getVariable(VNF_ID)); - executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds); - executeBuildingBlock.setRequestId(requestId); - executeBuildingBlock.setBuildingBlock(buildingBlock); - executeBuildingBlock.setRequestDetails(requestDetails); + String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST); + ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); + RequestDetails requestDetails = sIRequest.getRequestDetails(); + ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setaLaCarte(true) + .setRequestAction((String) execution.getVariable(G_ACTION)) + .setResourceId((String) execution.getVariable(VNF_ID)) + .setVnfType((String) execution.getVariable(VNF_TYPE)).setWorkflowResourceIds(workflowResourceIds) + .setRequestId(requestId).setBuildingBlock(buildingBlock).setRequestDetails(requestDetails); return executeBuildingBlock; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 356fe8d9a2..8911ebf15d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -6,14 +6,14 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Copyright (C) 2019 Nokia. + * Modifications Copyright (c) 2020 Nokia * ================================================================================ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -75,7 +75,18 @@ 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.db.catalog.client.CatalogDbClient; -import org.onap.so.serviceinstancebeans.*; +import org.onap.so.serviceinstancebeans.CloudConfiguration; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.ModelType; +import org.onap.so.serviceinstancebeans.Networks; +import org.onap.so.serviceinstancebeans.Pnfs; +import org.onap.so.serviceinstancebeans.RelatedInstance; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; +import org.onap.so.serviceinstancebeans.Service; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import org.onap.so.serviceinstancebeans.VfModules; +import org.onap.so.serviceinstancebeans.Vnfs; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -274,15 +285,14 @@ public class WorkflowAction { for (OrchestrationFlow orchFlow : orchFlows) { ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, - requestDetails, false, null, false); + requestDetails, false, null, null, false); flowsToExecute.add(ebb); } } else { boolean foundRelated = false; boolean containsService = false; if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) { - // SERVICE-MACRO-ASSIGN will always get user params with - // a + // SERVICE-MACRO-ASSIGN will always get user params with a // service. if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { List<Map<String, Object>> userParams = @@ -300,8 +310,7 @@ public class WorkflowAction { "Service-Macro-Assign request details must contain user params with a service"); } } else if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(CREATEINSTANCE)) { - // SERVICE-MACRO-CREATE will get user params with a - // service, + // SERVICE-MACRO-CREATE will get user params with a service, // a service with a network, a service with a // networkcollection, OR an empty service. // If user params is just a service or null and macro @@ -330,8 +339,7 @@ public class WorkflowAction { || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) { // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and // SERVICE-MACRO-DELETE - // Will never get user params with service, macro will - // have + // Will never get user params with service, macro will have // to query the SI in AAI to find related instances. traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds); } else if (resourceType == WorkflowType.SERVICE @@ -368,8 +376,7 @@ public class WorkflowAction { logger.info("Sorting for Vlan Tagging"); flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); } - // By default, enable homing at VNF level for CREATEINSTANCE - // and ASSIGNINSTANCE + // By default, enable homing at VNF level for CREATEINSTANCE and ASSIGNINSTANCE if (resourceType == WorkflowType.SERVICE && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)) && !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType())) @@ -386,8 +393,7 @@ public class WorkflowAction { } } } - // If the user set "Homing_Solution" to "none", disable homing, else - // if "Homing_Solution" is specified, + // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, // enable it. if (sIRequest.getRequestDetails().getRequestParameters() != null && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { @@ -540,17 +546,16 @@ public class WorkflowAction { dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID); dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId()); dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID); - ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), - dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), - dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), - dataObj.getWorkflowResourceIds(), dataObj.getRequestDetails(), false, null, true); String vnfcName = getVnfcNameForConfiguration(configuration); if (vnfcName == null || vnfcName.isEmpty()) { buildAndThrowException(dataObj.getExecution(), "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match")); } - ebb.getConfigurationResourceKeys().setVnfcName(vnfcName); + ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), + dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), + dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), + dataObj.getWorkflowResourceIds(), dataObj.getRequestDetails(), false, null, vnfcName, true); flowsToExecuteConfigs.add(ebb); } } @@ -735,7 +740,7 @@ public class WorkflowAction { } ebb.setWorkflowResourceIds(workflowResourceIds); } - if (virtualLinkKey != null && ebb.getBuildingBlock().getIsVirtualLink() + if (virtualLinkKey != null && ebb.getBuildingBlock().isVirtualLink() && virtualLinkKey.equalsIgnoreCase(ebb.getBuildingBlock().getVirtualLinkKey())) { WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId(serviceInstanceId); @@ -1323,7 +1328,7 @@ public class WorkflowAction { for (ExecuteBuildingBlock ebb : orchFlows) { if (ebb.getBuildingBlock().getBpmnFlowName().equals("AssignNetworkBB")) { String key = ebb.getBuildingBlock().getKey(); - boolean isVirtualLink = Boolean.TRUE.equals(ebb.getBuildingBlock().getIsVirtualLink()); + boolean isVirtualLink = Boolean.TRUE.equals(ebb.getBuildingBlock().isVirtualLink()); String virtualLinkKey = ebb.getBuildingBlock().getVirtualLinkKey(); sortedOrchFlows.add(ebb); for (ExecuteBuildingBlock ebb2 : orchFlows) { @@ -1396,7 +1401,7 @@ public class WorkflowAction { .filter(resource -> resource.getResourceType().equals(workflowType)).collect(Collectors.toList()); serviceResources.forEach(resource -> flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, - isVirtualLink, resource.getVirtualLinkKey(), isConfiguration))); + isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration))); } protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows, @@ -1428,7 +1433,6 @@ public class WorkflowAction { addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VIRTUAL_LINK, orchFlow, requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, true, false); - } else if (orchFlow.getFlowName().contains(VFMODULE)) { List<Resource> vfModuleResourcesSorted = null; if (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE) @@ -1442,7 +1446,7 @@ public class WorkflowAction { for (int i = 0; i < vfModuleResourcesSorted.size(); i++) { flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, vfModuleResourcesSorted.get(i), apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, - false, null, false)); + false, null, null, false)); } } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) { if (requestAction.equalsIgnoreCase(REPLACEINSTANCE) @@ -1463,7 +1467,7 @@ public class WorkflowAction { false, true); } else { flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, - requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, false)); + requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null, false)); } } return flowsToExecute; @@ -1472,46 +1476,33 @@ public class WorkflowAction { protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId, Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, - boolean isVirtualLink, String virtualLinkKey, boolean isConfiguration) { - ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); - BuildingBlock buildingBlock = new BuildingBlock(); + boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration) { + BuildingBlock buildingBlock = + new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString()) + .setIsVirtualLink(isVirtualLink).setVirtualLinkKey(virtualLinkKey) + .setKey(Optional.ofNullable(resource).map(Resource::getResourceId).orElse("")); Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(action -> buildingBlock.setBpmnAction(action)); Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(scope -> buildingBlock.setBpmnScope(scope)); - - buildingBlock.setBpmnFlowName(orchFlow.getFlowName()); - buildingBlock.setMsoId(UUID.randomUUID().toString()); - if (resource == null) { - buildingBlock.setKey(""); - } else { - buildingBlock.setKey(resource.getResourceId()); - } - buildingBlock.setIsVirtualLink(isVirtualLink); - buildingBlock.setVirtualLinkKey(virtualLinkKey); - executeBuildingBlock.setApiVersion(apiVersion); - executeBuildingBlock.setaLaCarte(aLaCarte); - executeBuildingBlock.setRequestAction(requestAction); - if (resource != null && (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE) || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) { logger.debug("Setting resourceId to volume group id for volume group flow on replace"); resourceId = workflowResourceIds.getVolumeGroupId(); } - executeBuildingBlock.setResourceId(resourceId); - executeBuildingBlock.setVnfType(vnfType); - executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds); - executeBuildingBlock.setRequestId(requestId); - executeBuildingBlock.setBuildingBlock(buildingBlock); - executeBuildingBlock.setRequestDetails(requestDetails); + + ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion) + .setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType) + .setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock) + .setRequestDetails(requestDetails); + if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) { ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); - if (resource != null) { - configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId()); - configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId()); - configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId()); - } + Optional.ofNullable(vnfcName).ifPresent(name -> configurationResourceKeys.setVnfcName(name)); + configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId()); + configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId()); + configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId()); executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys); } return executeBuildingBlock; 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 9d45272a60..ba5d283c01 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 @@ -453,21 +453,16 @@ public class WorkflowActionBBTasks { protected ExecuteBuildingBlock getExecuteBBForConfig(String bbName, ExecuteBuildingBlock ebb, String configurationId, ConfigurationResourceKeys configurationResourceKeys) { - ExecuteBuildingBlock configBB = new ExecuteBuildingBlock(); - BuildingBlock buildingBlock = new BuildingBlock(); - buildingBlock.setBpmnFlowName(bbName); - buildingBlock.setMsoId(UUID.randomUUID().toString()); - configBB.setaLaCarte(ebb.isaLaCarte()); - configBB.setApiVersion(ebb.getApiVersion()); - configBB.setRequestAction(ebb.getRequestAction()); - configBB.setVnfType(ebb.getVnfType()); - configBB.setRequestId(ebb.getRequestId()); - configBB.setRequestDetails(ebb.getRequestDetails()); - configBB.setBuildingBlock(buildingBlock); + BuildingBlock buildingBlock = + new BuildingBlock().setBpmnFlowName(bbName).setMsoId(UUID.randomUUID().toString()); + WorkflowResourceIds workflowResourceIds = ebb.getWorkflowResourceIds(); workflowResourceIds.setConfigurationId(configurationId); - configBB.setWorkflowResourceIds(workflowResourceIds); - configBB.setConfigurationResourceKeys(configurationResourceKeys); + ExecuteBuildingBlock configBB = new ExecuteBuildingBlock().setaLaCarte(ebb.isaLaCarte()) + .setApiVersion(ebb.getApiVersion()).setRequestAction(ebb.getRequestAction()) + .setVnfType(ebb.getVnfType()).setRequestId(ebb.getRequestId()) + .setRequestDetails(ebb.getRequestDetails()).setBuildingBlock(buildingBlock) + .setWorkflowResourceIds(workflowResourceIds).setConfigurationResourceKeys(configurationResourceKeys); return configBB; } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java index 573601b20f..7f44c97f59 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java @@ -143,10 +143,8 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest { @Test public void updateRequestStatusToFailedRollbackFabric() { - ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); - BuildingBlock bb = new BuildingBlock(); - bb.setBpmnFlowName("UnassignFabricConfigurationBB"); - ebb.setBuildingBlock(bb); + BuildingBlock bb = new BuildingBlock().setBpmnFlowName("UnassignFabricConfigurationBB"); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb); execution.setVariable("buildingBlock", ebb); execution.setVariable("mso-request-id", "123"); execution.setVariable("isRollbackComplete", false); 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 4991fa59ee..ff1246bc46 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 @@ -4,12 +4,14 @@ * ================================================================================ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,19 +22,6 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.mockito.ArgumentMatchers.anyObject; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.isA; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.when; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; @@ -58,15 +47,26 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelInfo; -import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.RequestDetails; -import org.onap.so.serviceinstancebeans.RequestInfo; import org.springframework.core.env.Environment; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyObject; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; public class WorkflowActionBBTasksTest extends BaseTaskTest { + private static final String SAMPLE_MSO_REQUEST_ID = "00f704ca-c5e5-4f95-a72c-6889db7b0688"; + private static final String SAMPLE_REQUEST_ACTION = "Delete-Network-Collection"; + private static final int SAMPLE_SEQUENCE = 0; @Mock protected WorkflowAction workflowAction; @@ -94,7 +94,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { @Before public void before() throws Exception { execution = new DelegateExecutionFake(); - org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance(); + ServiceInstance servInstance = new ServiceInstance(); servInstance.setServiceInstanceId("TEST"); when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance); workflowAction.setBbInputSetupUtils(bbSetupUtils); @@ -102,30 +102,22 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test - public void selectBBTest() throws Exception { - String gAction = "Delete-Network-Collection"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - execution.setVariable("gCurrentSequence", 0); - execution.setVariable("homing", false); - execution.setVariable("calledHoming", false); - List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); - ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); - + public void selectBBTest() { String vnfCustomizationUUID = "1234567"; String modelUuid = "1234567"; - BuildingBlock buildingBlock = new BuildingBlock(); - buildingBlock.setBpmnFlowName("ConfigAssignVnfBB"); - buildingBlock.setKey(vnfCustomizationUUID); - ebb.setBuildingBlock(buildingBlock); + prepareDelegateExecution(); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + + BuildingBlock buildingBlock = + new BuildingBlock().setBpmnFlowName("ConfigAssignVnfBB").setKey(vnfCustomizationUUID); RequestDetails rd = new RequestDetails(); ModelInfo mi = new ModelInfo(); mi.setModelUuid(modelUuid); rd.setModelInfo(mi); - ebb.setRequestDetails(rd); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd); flowsToExecute.add(ebb); - List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList(); + List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>(); VnfResourceCustomization vrc = new VnfResourceCustomization(); vrc.setSkipPostInstConf(false); vrc.setModelCustomizationUUID(vnfCustomizationUUID); @@ -140,42 +132,37 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { workflowActionBBTasks.selectBB(execution); boolean success = (boolean) execution.getVariable("completed"); int currentSequence = (int) execution.getVariable("gCurrentSequence"); - assertEquals(true, success); + assertTrue(success); assertEquals(1, currentSequence); } @Test - public void select2BBTest() throws Exception { - String gAction = "Delete-Network-Collection"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - execution.setVariable("gCurrentSequence", 0); - execution.setVariable("homing", false); - execution.setVariable("calledHoming", false); - List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); - ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - + public void select2BBTest() { String vnfCustomizationUUID = "1234567"; String modelUuid = "1234567"; - BuildingBlock buildingBlock = new BuildingBlock(); - buildingBlock.setBpmnFlowName("ConfigDeployVnfBB"); - buildingBlock.setKey(vnfCustomizationUUID); - ebb.setBuildingBlock(buildingBlock); + + prepareDelegateExecution(); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + BuildingBlock buildingBlock = + new BuildingBlock().setBpmnFlowName("ConfigDeployVnfBB").setKey(vnfCustomizationUUID); RequestDetails rd = new RequestDetails(); ModelInfo mi = new ModelInfo(); mi.setModelUuid(modelUuid); rd.setModelInfo(mi); - ebb.setRequestDetails(rd); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); + flowsToExecute.add(ebb); - List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList(); + List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>(); VnfResourceCustomization vrc = new VnfResourceCustomization(); + vrc.setSkipPostInstConf(false); vrc.setModelCustomizationUUID(vnfCustomizationUUID); vnfResourceCustomizations.add(vrc); GenericVnf genericVnf = new GenericVnf(); genericVnf.setModelCustomizationId(vnfCustomizationUUID); + doReturn(vnfResourceCustomizations).when(catalogDbClient).getVnfResourceCustomizationByModelUuid(modelUuid); doReturn(vrc).when(catalogDbClient).findVnfResourceCustomizationInList(vnfCustomizationUUID, vnfResourceCustomizations); @@ -190,7 +177,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test - public void updateRequestStatusToCompleteTest() throws Exception { + public void updateRequestStatusToCompleteTest() { String reqId = "reqId123"; execution.setVariable("mso-request-id", reqId); execution.setVariable("requestAction", "createInstance"); @@ -208,21 +195,17 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionPathTest() { execution.setVariable("handlingCode", "Rollback"); execution.setVariable("isRollback", false); - List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - BuildingBlock bb1 = new BuildingBlock(); - bb1.setBpmnFlowName("AssignVfModuleBB"); - ebb1.setBuildingBlock(bb1); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("CreateVfModuleBB"); - ebb2.setBuildingBlock(bb2); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - BuildingBlock bb3 = new BuildingBlock(); - bb3.setBpmnFlowName("ActivateVfModuleBB"); - ebb3.setBuildingBlock(bb3); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); execution.setVariable("flowsToExecute", flowsToExecute); @@ -241,21 +224,17 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionPathUnfinishedFlowTest() { execution.setVariable("handlingCode", "Rollback"); execution.setVariable("isRollback", false); - List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - BuildingBlock bb1 = new BuildingBlock(); - bb1.setBpmnFlowName("AssignVfModuleBB"); - ebb1.setBuildingBlock(bb1); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("CreateVfModuleBB"); - ebb2.setBuildingBlock(bb2); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - BuildingBlock bb3 = new BuildingBlock(); - bb3.setBpmnFlowName("ActivateVfModuleBB"); - ebb3.setBuildingBlock(bb3); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); execution.setVariable("flowsToExecute", flowsToExecute); @@ -274,26 +253,21 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionTest() { execution.setVariable("handlingCode", "Rollback"); execution.setVariable("isRollback", false); - List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - BuildingBlock bb1 = new BuildingBlock(); - bb1.setBpmnFlowName("AssignServiceInstanceBB"); - ebb1.setBuildingBlock(bb1); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("CreateNetworkCollectionBB"); - ebb2.setBuildingBlock(bb2); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateNetworkCollectionBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - BuildingBlock bb3 = new BuildingBlock(); - bb3.setBpmnFlowName("AssignNetworkBB"); - ebb3.setBuildingBlock(bb3); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("AssignNetworkBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - BuildingBlock bb4 = new BuildingBlock(); - bb4.setBpmnFlowName("CreateNetworkBB"); - ebb4.setBuildingBlock(bb4); + + BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB"); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); flowsToExecute.add(ebb4); execution.setVariable("flowsToExecute", flowsToExecute); @@ -312,21 +286,18 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionRollbackToAssignedTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "RollbackToAssigned"); - List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - BuildingBlock bb1 = new BuildingBlock(); - bb1.setBpmnFlowName("AssignVfModuleBB"); - ebb1.setBuildingBlock(bb1); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("CreateVfModuleBB"); - ebb2.setBuildingBlock(bb2); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - BuildingBlock bb3 = new BuildingBlock(); - bb3.setBpmnFlowName("ActivateVfModuleBB"); - ebb3.setBuildingBlock(bb3); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); execution.setVariable("flowsToExecute", flowsToExecute); @@ -343,31 +314,26 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionRollbackToAssignedWithFabricTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "RollbackToAssigned"); - List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - BuildingBlock bb1 = new BuildingBlock(); - bb1.setBpmnFlowName("AssignVfModuleBB"); - ebb1.setBuildingBlock(bb1); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("CreateVfModuleBB"); - ebb2.setBuildingBlock(bb2); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - BuildingBlock bb3 = new BuildingBlock(); - bb3.setBpmnFlowName("ActivateVfModuleBB"); - ebb3.setBuildingBlock(bb3); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - BuildingBlock bb4 = new BuildingBlock(); - bb4.setBpmnFlowName("AssignFabricConfigurationBB"); - ebb4.setBuildingBlock(bb4); + + BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AssignFabricConfigurationBB"); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4); flowsToExecute.add(ebb4); - ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock(); - BuildingBlock bb5 = new BuildingBlock(); - bb5.setBpmnFlowName("ActivateFabricConfigurationBB"); - ebb5.setBuildingBlock(bb5); + + BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("ActivateFabricConfigurationBB"); + ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5); flowsToExecute.add(ebb5); execution.setVariable("flowsToExecute", flowsToExecute); @@ -388,21 +354,17 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { public void rollbackExecutionRollbackToCreatedTest() { execution.setVariable("isRollback", false); execution.setVariable("handlingCode", "RollbackToCreated"); - List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - BuildingBlock bb1 = new BuildingBlock(); - bb1.setBpmnFlowName("AssignVfModuleBB"); - ebb1.setBuildingBlock(bb1); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1); flowsToExecute.add(ebb1); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("CreateVfModuleBB"); - ebb2.setBuildingBlock(bb2); + + BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2); flowsToExecute.add(ebb2); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - BuildingBlock bb3 = new BuildingBlock(); - bb3.setBpmnFlowName("ActivateVfModuleBB"); - ebb3.setBuildingBlock(bb3); + + BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3); flowsToExecute.add(ebb3); execution.setVariable("flowsToExecute", flowsToExecute); @@ -480,8 +442,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); vnfc.setModelInvariantId("modelInvariantId"); vnfc.setVnfcName("testVnfcName"); - List<org.onap.aai.domain.yang.Configuration> configurations = - new ArrayList<org.onap.aai.domain.yang.Configuration>(); + List<Configuration> configurations = new ArrayList<>(); org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); configuration.setConfigurationId("configurationId"); configuration.setModelCustomizationId("modelCustimizationId"); @@ -585,4 +546,12 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { assertEquals("volumeGroupName", request.getVolumeGroupName()); } + + private void prepareDelegateExecution() { + execution.setVariable("mso-request-id", SAMPLE_MSO_REQUEST_ID); + execution.setVariable("requestAction", SAMPLE_REQUEST_ACTION); + execution.setVariable("gCurrentSequence", SAMPLE_SEQUENCE); + execution.setVariable("homing", false); + execution.setVariable("calledHoming", false); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java index 9c3f0c6f0b..73aace7592 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java @@ -67,16 +67,12 @@ public class WorkflowActionBBTasksUpdateReqDbTest extends BaseTaskTest { @Test public void getUpdatedRequestTest() throws Exception { List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); - ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); - BuildingBlock bb1 = new BuildingBlock(); - bb1.setBpmnFlowName("CreateNetworkBB"); + BuildingBlock bb1 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB"); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(bb1); flowsToExecute.add(ebb1); - ebb1.setBuildingBlock(bb1); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("ActivateNetworkBB"); + BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2); flowsToExecute.add(ebb2); - ebb2.setBuildingBlock(bb2); String requestId = "requestId"; execution.setVariable("mso-request-id", requestId); execution.setVariable("flowsToExecute", flowsToExecute); 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 ed3ee0a3a1..cc4a5ce04e 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 @@ -6,6 +6,8 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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 @@ -109,7 +111,6 @@ import org.springframework.core.env.Environment; public class WorkflowActionTest extends BaseTaskTest { - @Mock protected Environment environment; @InjectMocks @@ -1706,41 +1707,29 @@ public class WorkflowActionTest extends BaseTaskTest { @Test public void sortExecutionPathByObjectForVlanTaggingCreateTest() throws Exception { List<ExecuteBuildingBlock> executeFlows = new ArrayList<>(); - ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); - BuildingBlock bb = new BuildingBlock(); - bb.setBpmnFlowName("AssignNetworkBB"); - bb.setKey("0"); - ebb.setBuildingBlock(bb); + + BuildingBlock bb = new BuildingBlock().setBpmnFlowName("AssignNetworkBB").setKey("0"); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb); executeFlows.add(ebb); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("AssignNetworkBB"); - bb2.setKey("1"); - ebb2.setBuildingBlock(bb2); + + BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("AssignNetworkBB").setKey("1"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2); executeFlows.add(ebb2); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - BuildingBlock bb3 = new BuildingBlock(); - bb3.setBpmnFlowName("CreateNetworkBB"); - bb3.setKey("0"); - ebb3.setBuildingBlock(bb3); + + BuildingBlock bb3 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB").setKey("0"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(bb3); executeFlows.add(ebb3); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - BuildingBlock bb4 = new BuildingBlock(); - bb4.setBpmnFlowName("CreateNetworkBB"); - bb4.setKey("1"); - ebb4.setBuildingBlock(bb4); + + BuildingBlock bb4 = new BuildingBlock().setBpmnFlowName("CreateNetworkBB").setKey("1"); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(bb4); executeFlows.add(ebb4); - ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock(); - BuildingBlock bb5 = new BuildingBlock(); - bb5.setBpmnFlowName("ActivateNetworkBB"); - bb5.setKey("0"); - ebb5.setBuildingBlock(bb5); + + BuildingBlock bb5 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB").setKey("0"); + ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(bb5); executeFlows.add(ebb5); - ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock(); - BuildingBlock bb6 = new BuildingBlock(); - bb6.setBpmnFlowName("ActivateNetworkBB"); - bb6.setKey("1"); - ebb6.setBuildingBlock(bb6); + + BuildingBlock bb6 = new BuildingBlock().setBpmnFlowName("ActivateNetworkBB").setKey("1"); + ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(bb6); executeFlows.add(ebb6); List<ExecuteBuildingBlock> sorted = @@ -1752,41 +1741,29 @@ public class WorkflowActionTest extends BaseTaskTest { @Test public void sortExecutionPathByObjectForVlanTaggingDeleteTest() throws Exception { List<ExecuteBuildingBlock> executeFlows = new ArrayList<>(); - ExecuteBuildingBlock ebb = new ExecuteBuildingBlock(); - BuildingBlock bb = new BuildingBlock(); - bb.setBpmnFlowName("DeactivateNetworkBB"); - bb.setKey("0"); - ebb.setBuildingBlock(bb); + + BuildingBlock bb = new BuildingBlock().setBpmnFlowName("DeactivateNetworkBB").setKey("0"); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(bb); executeFlows.add(ebb); - ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); - BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("DeactivateNetworkBB"); - bb2.setKey("1"); - ebb2.setBuildingBlock(bb2); + + BuildingBlock bb2 = new BuildingBlock().setBpmnFlowName("DeactivateNetworkBB").setKey("1"); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(bb2); executeFlows.add(ebb2); - ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); - BuildingBlock bb3 = new BuildingBlock(); - bb3.setBpmnFlowName("DeleteNetworkBB"); - bb3.setKey("0"); - ebb3.setBuildingBlock(bb3); + + BuildingBlock bb3 = new BuildingBlock().setBpmnFlowName("DeleteNetworkBB").setKey("0"); + ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(bb3); executeFlows.add(ebb3); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - BuildingBlock bb4 = new BuildingBlock(); - bb4.setBpmnFlowName("DeleteNetworkBB"); - bb4.setKey("1"); - ebb4.setBuildingBlock(bb4); + + BuildingBlock bb4 = new BuildingBlock().setBpmnFlowName("DeleteNetworkBB").setKey("1"); + ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(bb4); executeFlows.add(ebb4); - ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock(); - BuildingBlock bb5 = new BuildingBlock(); - bb5.setBpmnFlowName("UnassignNetworkBB"); - bb5.setKey("0"); - ebb5.setBuildingBlock(bb5); + + BuildingBlock bb5 = new BuildingBlock().setBpmnFlowName("UnassignNetworkBB").setKey("0"); + ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(bb5); executeFlows.add(ebb5); - ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock(); - BuildingBlock bb6 = new BuildingBlock(); - bb6.setBpmnFlowName("UnassignNetworkBB"); - bb6.setKey("1"); - ebb6.setBuildingBlock(bb6); + + BuildingBlock bb6 = new BuildingBlock().setBpmnFlowName("UnassignNetworkBB").setKey("1"); + ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock().setBuildingBlock(bb6); executeFlows.add(ebb6); List<ExecuteBuildingBlock> sorted = @@ -2974,7 +2951,7 @@ public class WorkflowActionTest extends BaseTaskTest { ExecuteBuildingBlock result = null; try { result = workflowAction.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null, - false, null, null, null, false, null, true); + false, null, null, null, false, null, null, true); } catch (NullPointerException e) { fail("NullPointerException should not be thrown when 'resource' is null"); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java index 82d610fa97..9d208f41e8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java @@ -90,13 +90,13 @@ public class MultiStageSkipListenerTest { WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId("serviceInstanceId"); workflowResourceIds.setVnfId(vnfId); + BuildingBlock bb = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setResourceId(vfModuleId).setBuildingBlock(bb) + .setWorkflowResourceIds(workflowResourceIds); + flowsToExecute.add(ebb); flowsToExecute.add(new ExecuteBuildingBlock()); flowsToExecute.add(new ExecuteBuildingBlock()); - flowsToExecute.add(new ExecuteBuildingBlock()); - flowsToExecute.get(0).setResourceId(vfModuleId); - flowsToExecute.get(0).setBuildingBlock(new BuildingBlock()); - flowsToExecute.get(0).getBuildingBlock().setBpmnFlowName("AssignVfModuleBB"); - flowsToExecute.get(0).setWorkflowResourceIds(workflowResourceIds); + BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake()); org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule(); |