aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorElena Kuleshov <evn@att.com>2019-08-29 16:47:28 -0400
committerElena Kuleshov <evn@att.com>2019-08-29 16:49:17 -0400
commit9d6f84234a66f349b4f05e04a45ba544533ca56a (patch)
tree3e167c87d60931ba15c35d511b6dd40ccaa720cc /bpmn/so-bpmn-tasks
parente709eab9ab55753eb17e435ee87f7f32d811bce2 (diff)
Update requestStatus to FAILED on activity error.
Update status and related fields in Requests DB on activity error, add a junit to verify error reporting. Issue-ID: SO-2263 Signed-off-by: Kuleshov, Elena <evn@att.com> Change-Id: I1a2e97afb95e4510b4860486c2b7836b014f990e
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java34
2 files changed, 39 insertions, 2 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 9340609ffc..d9c6857ef1 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
@@ -33,6 +33,7 @@ import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables;
import org.camunda.bpm.engine.variable.VariableMap;
import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBFailure;
import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBTasks;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
@@ -79,6 +80,8 @@ public class ExecuteActivity implements JavaDelegate {
@Autowired
private ExceptionBuilder exceptionBuilder;
@Autowired
+ private WorkflowActionBBFailure workflowActionBBFailure;
+ @Autowired
private WorkflowActionBBTasks workflowActionBBTasks;
@Override
@@ -178,13 +181,15 @@ public class ExecuteActivity implements JavaDelegate {
protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) {
logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
ErrorCode.UnknownError.getValue(), msg, ex);
- execution.setVariable("ExecuteActivityErrorMessage", msg);
+ execution.setVariable(EXECUTE_ACTIVITY_ERROR_MESSAGE, msg);
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
}
protected void buildAndThrowException(DelegateExecution execution, String msg) {
logger.error(msg);
execution.setVariable(EXECUTE_ACTIVITY_ERROR_MESSAGE, msg);
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg);
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
index 56ff813e73..c0056291ef 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
@@ -22,22 +22,41 @@ package org.onap.so.bpmn.infrastructure.activity;
import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
import java.nio.file.Files;
import java.nio.file.Paths;
+import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBFailure;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.onap.so.client.exception.ExceptionBuilder;
public class ExecuteActivityTest extends BaseTaskTest {
@InjectMocks
protected ExecuteActivity executeActivity = new ExecuteActivity();
+ @InjectMocks
+ @Spy
+ private ExceptionBuilder exceptionBuilder;
+
+ @Mock
+ private WorkflowActionBBFailure workflowActionBBFailure;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
private DelegateExecution execution;
@Before
@@ -72,4 +91,17 @@ public class ExecuteActivityTest extends BaseTaskTest {
assertEquals(ebb.getBuildingBlock(), bb);
}
+ @Test
+ public void buildAndThrowException_Test() throws Exception {
+ doNothing().when(workflowActionBBFailure).updateRequestStatusToFailed(execution);
+ doReturn("Process key").when(exceptionBuilder).getProcessKey(execution);
+ thrown.expect(BpmnError.class);
+ executeActivity.buildAndThrowException(execution, "TEST EXCEPTION MSG");
+ String errorMessage = (String) execution.getVariable("ExecuteActivityErrorMessage");
+ assertEquals(errorMessage, "TEST EXCEPTION MSG");
+ WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
+ assertEquals(workflowException.getErrorMessage(), "TEST EXCEPTION MSG");
+ assertEquals(workflowException.getErrorCode(), 7000);
+ }
+
}