Search in sources :

Example 16 with SuspendedEntityInteractionException

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

the class ProcessInstanceSuspensionTest method testMICallActivityReturnAfterProcessInstanceSuspend.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/ProcessInstanceSuspensionTest.callMISimpleProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/subProcess.bpmn20.xml" })
public void testMICallActivityReturnAfterProcessInstanceSuspend() {
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("callMISimpleProcess");
    runtimeService.suspendProcessInstanceById(instance.getId());
    List<Task> tasks = taskService.createTaskQuery().list();
    Task task1 = tasks.get(0);
    Task task2 = tasks.get(1);
    try {
        taskService.complete(task1.getId());
        fail("this should not be successful, as the execution of a suspended instance is resumed");
    } catch (SuspendedEntityInteractionException e) {
    // this is expected to fail
    }
    try {
        taskService.complete(task2.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.activateProcessInstanceById(instance.getId());
    taskService.complete(task1.getId());
    taskService.complete(task2.getId());
    assertEquals(0, 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)

Example 17 with SuspendedEntityInteractionException

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

the class ProcessInstanceSuspensionTest method testTaskLifecycleOperationsFailAfterProcessInstanceSuspend.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTaskLifecycleOperationsFailAfterProcessInstanceSuspend() {
    // Start a new process instance with one task
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
    final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task);
    // Suspend the process instance
    runtimeService.suspendProcessInstanceById(processInstance.getId());
    // Completing the task should fail
    try {
        taskService.complete(task.getId());
        fail("It is not allowed to complete a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
    // Claiming the task should fail
    try {
        taskService.claim(task.getId(), "jos");
        fail("It is not allowed to claim a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
    // Adding candidate groups on the task should fail
    try {
        taskService.addCandidateGroup(task.getId(), "blahGroup");
        fail("It is not allowed to add a candidate group on a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
    // Adding candidate users on the task should fail
    try {
        taskService.addCandidateUser(task.getId(), "blahUser");
        fail("It is not allowed to add a candidate user on a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
    // Adding group identity links on the task should fail
    try {
        taskService.addGroupIdentityLink(task.getId(), "blahGroup", IdentityLinkType.CANDIDATE);
        fail("It is not allowed to add a candidate user on a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
    // Adding an identity link on the task should fail
    try {
        taskService.addUserIdentityLink(task.getId(), "blahUser", IdentityLinkType.OWNER);
        fail("It is not allowed to add an identityLink on a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
    // Set an assignee on the task should fail
    try {
        taskService.setAssignee(task.getId(), "mispiggy");
        fail("It is not allowed to set an assignee on a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
    // Set an owner on the task should fail
    try {
        taskService.setOwner(task.getId(), "kermit");
        fail("It is not allowed to set an owner on a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
    // Removing candidate groups on the task should fail
    try {
        taskService.deleteCandidateGroup(task.getId(), "blahGroup");
        fail("It is not allowed to remove a candidate group on a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
    // Removing candidate users on the task should fail
    try {
        taskService.deleteCandidateUser(task.getId(), "blahUser");
        fail("It is not allowed to remove a candidate user on a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
    // Removing group identity links on the task should fail
    try {
        taskService.deleteGroupIdentityLink(task.getId(), "blahGroup", IdentityLinkType.CANDIDATE);
        fail("It is not allowed to remove a candidate user on a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
    // Removing an identity link on the task should fail
    try {
        taskService.deleteUserIdentityLink(task.getId(), "blahUser", IdentityLinkType.OWNER);
        fail("It is not allowed to remove an identityLink on a task of a suspended process instance");
    } catch (SuspendedEntityInteractionException e) {
    // This is good
    }
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Task(org.camunda.bpm.engine.task.Task) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 18 with SuspendedEntityInteractionException

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

the class BoundaryConditionalEventTest method testSuspendedProcess.

@Test
public void testSuspendedProcess() {
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_WITH_CONDITION_ID).endEvent().done();
    deployConditionalBoundaryEventProcess(modelInstance, TASK_WITH_CONDITION_ID, 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 19 with SuspendedEntityInteractionException

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

the class ProcessDefinitionSuspensionTest method testStartBeforeActivityForSuspendProcessDefinition.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testStartBeforeActivityForSuspendProcessDefinition() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    // start process instance
    runtimeService.startProcessInstanceById(processDefinition.getId());
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
    // Suspend process definition
    repositoryService.suspendProcessDefinitionById(processDefinition.getId(), true, null);
    // try to start before activity for suspended processDefinition
    try {
        runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("theTask").execute();
        fail("Exception is expected but not thrown");
    } catch (SuspendedEntityInteractionException e) {
        assertTextPresentIgnoreCase("is suspended", e.getMessage());
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 20 with SuspendedEntityInteractionException

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

the class ProcessDefinitionSuspensionTest method testStartProcessInstanceForSuspendedProcessDefinition.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/repository/processOne.bpmn20.xml" })
public void testStartProcessInstanceForSuspendedProcessDefinition() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    repositoryService.suspendProcessDefinitionById(processDefinition.getId());
    // By id
    try {
        runtimeService.startProcessInstanceById(processDefinition.getId());
        fail("Exception is expected but not thrown");
    } catch (SuspendedEntityInteractionException e) {
        assertTextPresentIgnoreCase("is suspended", e.getMessage());
    }
    // By Key
    try {
        runtimeService.startProcessInstanceByKey(processDefinition.getKey());
        fail("Exception is expected but not thrown");
    } catch (SuspendedEntityInteractionException e) {
        assertTextPresentIgnoreCase("is suspended", e.getMessage());
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) 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