Search in sources :

Example 26 with SuspendedEntityInteractionException

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

the class EventSubProcessStartConditionalEventTest method testSuspendedProcess.

@Test
public void testSuspendedProcess() {
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_WITH_CONDITION_ID).endEvent().done();
    deployConditionalEventSubProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, true);
    // given suspended process
    ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
    runtimeService.suspendProcessInstanceById(procInst.getId());
    // when wrong variable is set
    runtimeService.setVariable(procInst.getId(), VARIABLE_NAME + 1, 1);
    // then nothing happens
    assertTrue(runtimeService.createProcessInstanceQuery().singleResult().isSuspended());
    // then exception is expected
    try {
        runtimeService.setVariable(procInst.getId(), VARIABLE_NAME, 1);
        fail("Should fail!");
    } catch (SuspendedEntityInteractionException seie) {
    // expected
    }
    runtimeService.activateProcessInstanceById(procInst.getId());
    tasksAfterVariableIsSet = taskService.createTaskQuery().list();
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Test(org.junit.Test)

Example 27 with SuspendedEntityInteractionException

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

the class EventSubProcessStartConditionalEventTest method testNonInterruptingConditionalSuspendedProcess.

@Test
public void testNonInterruptingConditionalSuspendedProcess() {
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_WITH_CONDITION_ID).endEvent().done();
    deployConditionalEventSubProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, false);
    // given suspended process
    ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
    runtimeService.suspendProcessInstanceById(procInst.getId());
    // when wrong variable is set
    runtimeService.setVariable(procInst.getId(), VARIABLE_NAME + 1, 1);
    // then nothing happens
    assertTrue(runtimeService.createProcessInstanceQuery().singleResult().isSuspended());
    // then exception is expected
    try {
        runtimeService.setVariable(procInst.getId(), VARIABLE_NAME, 1);
        fail("Should fail!");
    } catch (SuspendedEntityInteractionException seie) {
    // expected
    }
    runtimeService.activateProcessInstanceById(procInst.getId());
    tasksAfterVariableIsSet = taskService.createTaskQuery().list();
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Test(org.junit.Test)

Example 28 with SuspendedEntityInteractionException

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

the class IntermediateConditionalEventTest method testSuspendedProcess.

@Test
public void testSuspendedProcess() {
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().intermediateCatchEvent(CONDITIONAL_EVENT).conditionalEventDefinition().condition(CONDITION_EXPR).conditionalEventDefinitionDone().endEvent().done();
    engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, modelInstance).deploy());
    // given suspended process
    ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
    runtimeService.suspendProcessInstanceById(procInst.getId());
    // when wrong variable is set
    runtimeService.setVariable(procInst.getId(), VARIABLE_NAME + 1, 1);
    // then nothing happens
    assertTrue(runtimeService.createProcessInstanceQuery().singleResult().isSuspended());
    // then exception is expected
    try {
        runtimeService.setVariable(procInst.getId(), VARIABLE_NAME, 1);
        fail("Should fail!");
    } catch (SuspendedEntityInteractionException seie) {
    // expected
    }
    runtimeService.activateProcessInstanceById(procInst.getId());
    tasksAfterVariableIsSet = taskService.createTaskQuery().list();
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Test(org.junit.Test)

Example 29 with SuspendedEntityInteractionException

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

the class BoundaryConditionalEventTest method testNonInterruptingConditionalSuspendedProcess.

@Test
public void testNonInterruptingConditionalSuspendedProcess() {
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_WITH_CONDITION_ID).endEvent().done();
    deployConditionalBoundaryEventProcess(modelInstance, TASK_WITH_CONDITION_ID, false);
    // given suspended process
    ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
    runtimeService.suspendProcessInstanceById(procInst.getId());
    // when wrong variable is set
    runtimeService.setVariable(procInst.getId(), VARIABLE_NAME + 1, 1);
    // then nothing happens
    assertTrue(runtimeService.createProcessInstanceQuery().singleResult().isSuspended());
    // then exception is expected
    try {
        runtimeService.setVariable(procInst.getId(), VARIABLE_NAME, 1);
        fail("Should fail!");
    } catch (SuspendedEntityInteractionException seie) {
    // expected
    }
    runtimeService.activateProcessInstanceById(procInst.getId());
    tasksAfterVariableIsSet = taskService.createTaskQuery().list();
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Test(org.junit.Test)

Example 30 with SuspendedEntityInteractionException

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

the class ProcessInstanceSuspensionTest method testCallActivityReturnAfterProcessInstanceSuspendByProcessDefinitionId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/ProcessInstanceSuspensionTest.callSimpleProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/subProcess.bpmn20.xml" })
public void testCallActivityReturnAfterProcessInstanceSuspendByProcessDefinitionId() {
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("callSimpleProcess");
    runtimeService.suspendProcessInstanceByProcessDefinitionId(instance.getProcessDefinitionId());
    Task task = taskService.createTaskQuery().singleResult();
    try {
        taskService.complete(task.getId());
        fail("this should not be successful, as the execution of a suspended instance is resumed");
    } catch (SuspendedEntityInteractionException e) {
    // this is expected to fail
    }
    // should be successful after reactivation
    runtimeService.activateProcessInstanceByProcessDefinitionId(instance.getProcessDefinitionId());
    taskService.complete(task.getId());
    assertEquals(1, runtimeService.createProcessInstanceQuery().count());
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Task(org.camunda.bpm.engine.task.Task) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

SuspendedEntityInteractionException (org.camunda.bpm.engine.SuspendedEntityInteractionException)39 Deployment (org.camunda.bpm.engine.test.Deployment)34 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)30 Task (org.camunda.bpm.engine.task.Task)16 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)15 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)8 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)5 Test (org.junit.Test)5 Date (java.util.Date)3 HashMap (java.util.HashMap)3 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 Job (org.camunda.bpm.engine.runtime.Job)3