aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorGamboa, Gilbert <gilbert.g.gamboa@att.com>2019-07-05 10:30:58 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-07-05 10:31:04 -0400
commitcc805b184620525115c88c1a52ddfde55c73e15b (patch)
tree419e6d3573b0860d2aa18d0b462e310a2d17bef9 /bpmn/so-bpmn-tasks
parent0e2cda138f35ee6a7a8a54c29a6c4edf07d51745 (diff)
mso will support new requeststate values
Support new request status - ROLLED_BACK, ROLLED_BACK_TO_ASSIGNED, ROLLED_BACK_TO_CREATED, and ABORTED. Support new request status - ROLLED_BACK, ROLLED_BACK_TO_ASSIGNED, ROLLED_BACK_TO_CREATED, and ABORTED. Added default FAILED request status in case rollback is not needed. Variable rollbackTargetState needs to be returned to WorkflowAction flow Variable rollbackTargetState needs to in to ExecuteBuildingBlock as well. Add new RequestDb migration file to expand infra_active_requests column request_status to 25 bytes to fit new request states. Change-Id: I0da2f8013001a28dcc20f64eb9455e4cfd3dd197 Issue-ID: SO-2093 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java12
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java54
2 files changed, 64 insertions, 2 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java
index 67dc9fec26..2d3f5de616 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java
@@ -26,6 +26,7 @@ import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.constants.Status;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
import org.slf4j.Logger;
@@ -37,6 +38,7 @@ import org.springframework.stereotype.Component;
public class WorkflowActionBBFailure {
private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBFailure.class);
+ public static final String ROLLBACK_TARGET_STATE = "rollbackTargetState";
@Autowired
private RequestsDbClient requestDbclient;
@Autowired
@@ -89,6 +91,8 @@ public class WorkflowActionBBFailure {
rollbackErrorMsg = "Rollback has been completed successfully.";
request.setRollbackStatusMessage(rollbackErrorMsg);
execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
+ String rollbackTargetState = (String) execution.getVariable(ROLLBACK_TARGET_STATE);
+ request.setRequestStatus(rollbackTargetState);
} else if (isRollbackFailure) {
Optional<String> rollbackErrorMsgOp = retrieveErrorMessage(execution);
if (rollbackErrorMsgOp.isPresent()) {
@@ -98,6 +102,7 @@ public class WorkflowActionBBFailure {
}
request.setRollbackStatusMessage(rollbackErrorMsg);
execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
+ request.setRequestStatus(Status.FAILED.toString());
} else {
Optional<String> errorMsgOp = retrieveErrorMessage(execution);
if (errorMsgOp.isPresent()) {
@@ -107,6 +112,12 @@ public class WorkflowActionBBFailure {
}
request.setStatusMessage(errorMsg);
execution.setVariable("ErrorMessage", errorMsg);
+ String handlingCode = (String) execution.getVariable("handlingCode");
+ if ("Abort".equalsIgnoreCase(handlingCode)) {
+ request.setRequestStatus(Status.ABORTED.toString());
+ } else {
+ request.setRequestStatus(Status.FAILED.toString());
+ }
}
if (ebb != null && ebb.getBuildingBlock() != null) {
String flowStatus = "";
@@ -120,7 +131,6 @@ public class WorkflowActionBBFailure {
}
request.setProgress(Long.valueOf(100));
- request.setRequestStatus("FAILED");
request.setLastModifiedBy("CamundaBPMN");
request.setEndTime(new Timestamp(System.currentTimeMillis()));
requestDbclient.updateInfraActiveRequests(request);
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 12f34eaddf..2d48d02774 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
@@ -41,6 +41,7 @@ import org.mockito.Spy;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
+import org.onap.so.constants.Status;
import org.onap.so.db.request.beans.InfraActiveRequests;
public class WorkflowActionBBFailureTest extends BaseTaskTest {
@@ -102,6 +103,24 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest {
workflowActionBBFailure.updateRequestStatusToFailed(execution);
String errorMsg = (String) execution.getVariable("ErrorMessage");
assertEquals("error in test case", errorMsg);
+ assertEquals(Status.FAILED.toString(), req.getRequestStatus());
+ }
+
+ @Test
+ public void updateRequestStatusToAborted() {
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", false);
+ execution.setVariable("isRollback", false);
+ execution.setVariable("handlingCode", "Abort");
+ InfraActiveRequests req = new InfraActiveRequests();
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in test case");
+ execution.setVariable("WorkflowException", wfe);
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("ErrorMessage");
+ assertEquals("error in test case", errorMsg);
+ assertEquals(Status.ABORTED.toString(), req.getRequestStatus());
}
@Test
@@ -117,19 +136,52 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest {
workflowActionBBFailure.updateRequestStatusToFailed(execution);
String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
assertEquals("error in rollback", errorMsg);
+ assertEquals(Status.FAILED.toString(), req.getRequestStatus());
+ }
+
+ @Test
+ public void updateRequestStatusToRolledback() {
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", true);
+ execution.setVariable("isRollback", true);
+ execution.setVariable("rollbackTargetState", "ROLLED_BACK");
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
+ assertEquals("Rollback has been completed successfully.", errorMsg);
+ assertEquals(Status.ROLLED_BACK.toString(), req.getRequestStatus());
+ }
+
+ @Test
+ public void updateRequestStatusToRolledbackToAssigned() {
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", true);
+ execution.setVariable("isRollback", true);
+ execution.setVariable("rollbackTargetState", "ROLLED_BACK_TO_ASSIGNED");
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
+ assertEquals("Rollback has been completed successfully.", errorMsg);
+ assertEquals(Status.ROLLED_BACK_TO_ASSIGNED.toString(), req.getRequestStatus());
}
@Test
- public void updateRequestStatusToFailedRollbackCompleted() {
+ public void updateRequestStatusToRolledbackToCreated() {
execution.setVariable("mso-request-id", "123");
execution.setVariable("isRollbackComplete", true);
execution.setVariable("isRollback", true);
+ execution.setVariable("rollbackTargetState", "ROLLED_BACK_TO_CREATED");
InfraActiveRequests req = new InfraActiveRequests();
doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
workflowActionBBFailure.updateRequestStatusToFailed(execution);
String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
assertEquals("Rollback has been completed successfully.", errorMsg);
+ assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), req.getRequestStatus());
}
@Test