diff options
author | Elena Kuleshov <evn@att.com> | 2019-08-29 16:47:28 -0400 |
---|---|---|
committer | Elena Kuleshov <evn@att.com> | 2019-08-29 16:49:17 -0400 |
commit | 9d6f84234a66f349b4f05e04a45ba544533ca56a (patch) | |
tree | 3e167c87d60931ba15c35d511b6dd40ccaa720cc /bpmn/so-bpmn-tasks/src/test/java | |
parent | e709eab9ab55753eb17e435ee87f7f32d811bce2 (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/src/test/java')
-rw-r--r-- | bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java | 34 |
1 files changed, 33 insertions, 1 deletions
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); + } + } |