aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorMax Benjamin <max.benjamin@att.com>2021-03-26 14:02:40 +0000
committerGerrit Code Review <gerrit@onap.org>2021-03-26 14:02:40 +0000
commitddf1a56a6ea6c8cfc40836f0bcf00afdd151c702 (patch)
tree9cb4a006daf22fec8b3160d2901808821df3bb8e /bpmn/so-bpmn-tasks
parent5b5da69bad88682f442d588ae58b70c220da099a (diff)
parent82358726fc0c37adcd426a41cdca4f3b4ddf2c56 (diff)
Merge "request db endpoint and bpmn cleanup"
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java44
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java44
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java14
3 files changed, 49 insertions, 53 deletions
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 ee4e56bc18..bc8f8cc822 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
@@ -26,9 +26,27 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.NETWORKCOLLECTION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.USER_PARAM_SERVICE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.SerializationUtils;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.javatuples.Pair;
@@ -79,26 +97,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.NETWORKCOLLECTION;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.USER_PARAM_SERVICE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class WorkflowAction {
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 ec2ca74fa7..cd151bafea 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
@@ -37,6 +37,7 @@ import org.onap.aai.domain.yang.Vnfc;
import org.onap.aai.domain.yang.VolumeGroup;
import org.onap.aaiclient.client.aai.entities.Configuration;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
+import org.onap.so.bpmn.common.BBConstants;
import org.onap.so.bpmn.common.DelegateExecutionImpl;
import org.onap.so.bpmn.common.listener.db.RequestsDbListenerRunner;
import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner;
@@ -68,10 +69,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class WorkflowActionBBTasks {
- private static final String G_CURRENT_SEQUENCE = "gCurrentSequence";
- private static final String G_REQUEST_ID = "mso-request-id";
- private static final String G_ALACARTE = "aLaCarte";
- private static final String G_ACTION = "requestAction";
private static final String RETRY_COUNT = "retryCount";
private static final String FABRIC_CONFIGURATION = "FabricConfiguration";
private static final String ADD_FABRIC_CONFIGURATION_BB = "AddFabricConfigurationBB";
@@ -112,14 +109,15 @@ public class WorkflowActionBBTasks {
} catch (NullPointerException ex) {
workflowAction.buildAndThrowException(execution, "Error in FlowManipulator Modify Flows", ex);
}
- int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
+ int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence);
execution.setVariable("buildingBlock", ebb);
currentSequence++;
execution.setVariable(COMPLETED, currentSequence >= flowsToExecute.size());
- execution.setVariable(G_CURRENT_SEQUENCE, currentSequence);
+ execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currentSequence);
+
} catch (Exception e) {
workflowAction.buildAndThrowException(execution, "Internal Error occured during selectBB", e);
}
@@ -127,7 +125,7 @@ public class WorkflowActionBBTasks {
public void updateFlowStatistics(DelegateExecution execution) {
try {
- int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
+ int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
if (currentSequence > 1) {
InfraActiveRequests request = this.getUpdatedRequest(execution, currentSequence);
requestDbclient.updateInfraActiveRequests(request);
@@ -142,7 +140,7 @@ public class WorkflowActionBBTasks {
protected InfraActiveRequests getUpdatedRequest(DelegateExecution execution, int currentSequence) {
List<ExecuteBuildingBlock> flowsToExecute =
(List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
ExecuteBuildingBlock completedBB = flowsToExecute.get(currentSequence - 2);
ExecuteBuildingBlock nextBB = flowsToExecute.get(currentSequence - 1);
@@ -171,7 +169,7 @@ public class WorkflowActionBBTasks {
}
public void sendSyncAck(DelegateExecution execution) {
- final String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
final String resourceId = (String) execution.getVariable("resourceId");
ServiceInstancesResponse serviceInstancesResponse = new ServiceInstancesResponse();
RequestReferences requestRef = new RequestReferences();
@@ -199,7 +197,7 @@ public class WorkflowActionBBTasks {
}
public void sendErrorSyncAck(DelegateExecution execution) {
- final String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
try {
ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
String errorMsg = (String) execution.getVariable("WorkflowActionErrorMessage");
@@ -225,10 +223,10 @@ public class WorkflowActionBBTasks {
public void updateRequestStatusToComplete(DelegateExecution execution) {
try {
- final String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
- final String action = (String) execution.getVariable(G_ACTION);
- final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
+ final String action = (String) execution.getVariable(BBConstants.G_ACTION);
+ final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE);
final String resourceName = (String) execution.getVariable("resourceName");
String statusMessage = (String) execution.getVariable("StatusMessage");
String macroAction;
@@ -258,7 +256,7 @@ public class WorkflowActionBBTasks {
public void checkRetryStatus(DelegateExecution execution) {
String handlingCode = (String) execution.getVariable(HANDLINGCODE);
- String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
String retryDuration = (String) execution.getVariable("RetryDuration");
int retryCount = (int) execution.getVariable(RETRY_COUNT);
int envMaxRetries;
@@ -280,8 +278,8 @@ public class WorkflowActionBBTasks {
logger.warn("Failed to update Request Db Infra Active Requests with Retry Status", ex);
}
if (retryCount < envMaxRetries) {
- int currSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
- execution.setVariable(G_CURRENT_SEQUENCE, currSequence - 1);
+ int currSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+ execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currSequence - 1);
execution.setVariable(RETRY_COUNT, nextCount);
} else {
workflowAction.buildAndThrowException(execution,
@@ -297,7 +295,7 @@ public class WorkflowActionBBTasks {
* working on.
*/
public void rollbackExecutionPath(DelegateExecution execution) {
- final String action = (String) execution.getVariable(G_ACTION);
+ final String action = (String) execution.getVariable(BBConstants.G_ACTION);
final String resourceName = (String) execution.getVariable("resourceName");
if (!(boolean) execution.getVariable("isRollback")) {
List<ExecuteBuildingBlock> flowsToExecute =
@@ -308,7 +306,7 @@ public class WorkflowActionBBTasks {
.collect(Collectors.toList());
List<ExecuteBuildingBlock> rollbackFlows = new ArrayList<>();
- int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
+ int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
int listSize = flowsToExecute.size();
for (int i = listSize - 1; i >= 0; i--) {
@@ -381,7 +379,7 @@ public class WorkflowActionBBTasks {
execution.setVariable("flowsToExecute", rollbackFlowsFiltered);
execution.setVariable(HANDLINGCODE, "PreformingRollback");
execution.setVariable("isRollback", true);
- execution.setVariable(G_CURRENT_SEQUENCE, 0);
+ execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0);
execution.setVariable(RETRY_COUNT, 0);
} else {
workflowAction.buildAndThrowException(execution,
@@ -391,7 +389,7 @@ public class WorkflowActionBBTasks {
protected void updateInstanceId(DelegateExecution execution) {
try {
- String requestId = (String) execution.getVariable(G_REQUEST_ID);
+ String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
String resourceId = (String) execution.getVariable("resourceId");
WorkflowType resourceType = (WorkflowType) execution.getVariable("resourceType");
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
@@ -424,8 +422,8 @@ public class WorkflowActionBBTasks {
List<ExecuteBuildingBlock> flowsToExecute =
(List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
String handlingCode = (String) execution.getVariable(HANDLINGCODE);
- final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE);
- int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
+ final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE);
+ int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
logger.debug("Current Sequence: {}", currentSequence);
ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1);
String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName();
@@ -444,7 +442,7 @@ public class WorkflowActionBBTasks {
protected void postProcessingExecuteBBActivateVfModule(DelegateExecution execution, ExecuteBuildingBlock ebb,
List<ExecuteBuildingBlock> flowsToExecute) {
try {
- String requestAction = (String) execution.getVariable(G_ACTION);
+ String requestAction = (String) execution.getVariable(BBConstants.G_ACTION);
String serviceInstanceId = ebb.getWorkflowResourceIds().getServiceInstanceId();
String vnfId = ebb.getWorkflowResourceIds().getVnfId();
String vfModuleId = ebb.getResourceId();
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 26e0d2f8c9..55529b5bf0 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
@@ -232,7 +232,6 @@ public class WorkflowActionTest extends BaseTaskTest {
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
-
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "ActivateServiceInstanceBB");
@@ -1044,7 +1043,7 @@ public class WorkflowActionTest extends BaseTaskTest {
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
- "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB");
+ "AddFabricConfigurationBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<CvnfcCustomization>();
@@ -1078,15 +1077,14 @@ public class WorkflowActionTest extends BaseTaskTest {
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
- // when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID("fc25201d-36d6-43a3-8d39-fdae88e526ae",
- // "9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(cvnfcCustomizations);
+
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
- "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "AssignFabricConfigurationBB",
- "ActivateFabricConfigurationBB");
+ assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB");
}
+
+
@Test
public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceTest() throws Exception {
String gAction = "replaceInstance";
@@ -1450,7 +1448,6 @@ public class WorkflowActionTest extends BaseTaskTest {
"ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
}
-
@Test
public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception {
String gAction = "deleteInstance";
@@ -2249,6 +2246,7 @@ public class WorkflowActionTest extends BaseTaskTest {
for (int i = 0; i < ebbs.size(); i++) {
assertEquals(ebbs.get(i).getBuildingBlock().getBpmnFlowName(), flowNames[i]);
}
+ assertEquals(ebbs.size(), flowNames.length);
}
private void initExecution(String gAction, String bpmnRequest, boolean isAlaCarte) {