Search in sources :

Example 1 with BpmnError

use of org.camunda.bpm.engine.delegate.BpmnError in project camunda-bpm-platform by camunda.

the class ConnectProcessEnginePluginTest method testConnectorBpmnErrorThrownInScriptResourceInputMappingIsHandledByBoundaryEvent.

@Deployment(resources = "org/camunda/connect/plugin/ConnectProcessEnginePluginTest.testConnectorWithThrownExceptionInScriptResourceInputOutputMapping.bpmn")
public void testConnectorBpmnErrorThrownInScriptResourceInputMappingIsHandledByBoundaryEvent() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("throwInMapping", "in");
    variables.put("exception", new BpmnError("error"));
    runtimeService.startProcessInstanceByKey("testProcess", variables);
    // we will only reach the user task if the BPMNError from the script was handled by the boundary event
    Task task = taskService.createTaskQuery().singleResult();
    assertThat(task.getName(), is("User Task"));
}
Also used : Task(org.camunda.bpm.engine.task.Task) HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 2 with BpmnError

use of org.camunda.bpm.engine.delegate.BpmnError in project camunda-bpm-platform by camunda.

the class ConnectProcessEnginePluginTest method testConnectorBpmnErrorThrownInScriptInputMappingIsHandledByBoundaryEvent.

@Deployment(resources = "org/camunda/connect/plugin/ConnectProcessEnginePluginTest.testConnectorWithThrownExceptionInScriptInputOutputMapping.bpmn")
public void testConnectorBpmnErrorThrownInScriptInputMappingIsHandledByBoundaryEvent() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("throwInMapping", "in");
    variables.put("exception", new BpmnError("error"));
    runtimeService.startProcessInstanceByKey("testProcess", variables);
    // we will only reach the user task if the BPMNError from the script was handled by the boundary event
    Task task = taskService.createTaskQuery().singleResult();
    assertThat(task.getName(), is("User Task"));
}
Also used : Task(org.camunda.bpm.engine.task.Task) HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 3 with BpmnError

use of org.camunda.bpm.engine.delegate.BpmnError in project camunda-bpm-platform by camunda.

the class ConnectProcessEnginePluginTest method testConnectorBpmnErrorThrownInScriptResourceOutputMappingIsHandledByBoundaryEvent.

@Deployment(resources = "org/camunda/connect/plugin/ConnectProcessEnginePluginTest.testConnectorWithThrownExceptionInScriptResourceInputOutputMapping.bpmn")
public void testConnectorBpmnErrorThrownInScriptResourceOutputMappingIsHandledByBoundaryEvent() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("throwInMapping", "out");
    variables.put("exception", new BpmnError("error"));
    runtimeService.startProcessInstanceByKey("testProcess", variables);
    // we will only reach the user task if the BPMNError from the script was handled by the boundary event
    Task task = taskService.createTaskQuery().singleResult();
    assertThat(task.getName(), is("User Task"));
}
Also used : Task(org.camunda.bpm.engine.task.Task) HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 4 with BpmnError

use of org.camunda.bpm.engine.delegate.BpmnError in project camunda-bpm-platform by camunda.

the class ExternalTaskEntity method bpmnError.

public void bpmnError(String errorCode) {
    ensureActive();
    ActivityExecution activityExecution = getExecution();
    BpmnError bpmnError = new BpmnError(errorCode);
    try {
        ExternalTaskActivityBehavior behavior = ((ExternalTaskActivityBehavior) activityExecution.getActivity().getActivityBehavior());
        behavior.propagateBpmnError(bpmnError, activityExecution);
    } catch (Exception ex) {
        throw ProcessEngineLogger.CMD_LOGGER.exceptionBpmnErrorPropagationFailed(errorCode, ex);
    }
}
Also used : ActivityExecution(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) ExternalTaskActivityBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior)

Example 5 with BpmnError

use of org.camunda.bpm.engine.delegate.BpmnError in project camunda-bpm-platform by camunda.

the class BoundaryErrorEventTest method testUncaughtErrorOnCallActivity.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.testUncaughtErrorOnCallActivity-parent.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.subprocess.bpmn20.xml" })
public void testUncaughtErrorOnCallActivity() {
    runtimeService.startProcessInstanceByKey("uncaughtErrorOnCallActivity");
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("Task in subprocess", task.getName());
    try {
        // Completing the task will reach the end error event,
        // which is never caught in the process
        taskService.complete(task.getId());
    } catch (BpmnError e) {
        assertTextPresent("No catching boundary event found for error with errorCode 'myError', neither in same process nor in parent process", e.getMessage());
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

BpmnError (org.camunda.bpm.engine.delegate.BpmnError)10 Task (org.camunda.bpm.engine.task.Task)9 Deployment (org.camunda.bpm.engine.test.Deployment)9 HashMap (java.util.HashMap)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 ExternalTaskActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior)1 ActivityExecution (org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution)1