Set WorkflowException on BPMN WF error 00/96300/1
authorElena Kuleshov <evn@att.com>
Thu, 26 Sep 2019 17:10:46 +0000 (13:10 -0400)
committerElena Kuleshov <evn@att.com>
Thu, 26 Sep 2019 17:12:35 +0000 (13:12 -0400)
WorkflowException needs to be set when execution of a custom workflows fails due to an error from BPMN

Issue-ID: SO-2369
Signed-off-by: Kuleshov, Elena <evn@att.com>
Change-Id: Ie5ab66105681588000693fdbb3ca89310aee8a7c

bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java

index d9c6857..0c31dfa 100644 (file)
@@ -138,7 +138,9 @@ public class ExecuteActivity implements JavaDelegate {
 
             execution.setVariable(WORKFLOW_EXCEPTION, workflowException);
         } catch (Exception e) {
-            buildAndThrowException(execution, e.getMessage());
+            logger.error("BPMN exception on activity execution: " + e.getMessage());
+            workflowException = new WorkflowException(EXECUTE_BUILDING_BLOCK, 7000, e.getMessage());
+            handlingCode = ABORT_HANDLING_CODE;
         }
 
         if (workflowException != null && handlingCode != null && handlingCode.equals(ABORT_HANDLING_CODE)) {
index c005629..1fde3f4 100644 (file)
@@ -91,6 +91,19 @@ public class ExecuteActivityTest extends BaseTaskTest {
         assertEquals(ebb.getBuildingBlock(), bb);
     }
 
+    @Test
+    public void executeException_Test() throws Exception {
+        execution.setVariable("workflowSyncAckSent", true);
+        execution.setVariable("testProcessKey", "testProcessKeyValue");
+        thrown.expect(BpmnError.class);
+        executeActivity.execute(execution);
+        String errorMessage = (String) execution.getVariable("ExecuteActivityErrorMessage");
+        assertEquals(errorMessage, "not implemented");
+        WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
+        assertEquals(workflowException.getErrorMessage(), "not implemented");
+        assertEquals(workflowException.getErrorCode(), 7000);
+    }
+
     @Test
     public void buildAndThrowException_Test() throws Exception {
         doNothing().when(workflowActionBBFailure).updateRequestStatusToFailed(execution);