use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartAfterActivityDuringCompensation.
@Deployment(resources = TRANSACTION_WITH_COMPENSATION_PROCESS)
public void testStartAfterActivityDuringCompensation() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
completeTasksInOrder("userTask");
Task task = taskService.createTaskQuery().singleResult();
assertEquals("undoTask", task.getTaskDefinitionKey());
runtimeService.createProcessInstanceModification(processInstance.getId()).startAfterActivity("userTask").execute();
task = taskService.createTaskQuery().singleResult();
assertEquals("afterCancel", task.getTaskDefinitionKey());
completeTasksInOrder("afterCancel");
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByLeafActivityId.
@Test
public void testQueryByLeafActivityId() {
// given
ProcessDefinition oneTaskDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition gatewaySubProcessDefinition = testHelper.deployAndGetDefinition(FORK_JOIN_SUB_PROCESS_MODEL);
// when
ProcessInstance oneTaskInstance1 = runtimeService.startProcessInstanceById(oneTaskDefinition.getId());
ProcessInstance oneTaskInstance2 = runtimeService.startProcessInstanceById(oneTaskDefinition.getId());
ProcessInstance gatewaySubProcessInstance1 = runtimeService.startProcessInstanceById(gatewaySubProcessDefinition.getId());
ProcessInstance gatewaySubProcessInstance2 = runtimeService.startProcessInstanceById(gatewaySubProcessDefinition.getId());
Task task = engineRule.getTaskService().createTaskQuery().processInstanceId(gatewaySubProcessInstance2.getId()).taskName("completeMe").singleResult();
engineRule.getTaskService().complete(task.getId());
// then
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("userTask");
assertReturnedProcessInstances(query, oneTaskInstance1, oneTaskInstance2);
query = runtimeService.createProcessInstanceQuery().activityIdIn("userTask1", "userTask2");
assertReturnedProcessInstances(query, gatewaySubProcessInstance1, gatewaySubProcessInstance2);
query = runtimeService.createProcessInstanceQuery().activityIdIn("userTask", "userTask1");
assertReturnedProcessInstances(query, oneTaskInstance1, oneTaskInstance2, gatewaySubProcessInstance1);
query = runtimeService.createProcessInstanceQuery().activityIdIn("userTask", "userTask1", "userTask2");
assertReturnedProcessInstances(query, oneTaskInstance1, oneTaskInstance2, gatewaySubProcessInstance1, gatewaySubProcessInstance2);
query = runtimeService.createProcessInstanceQuery().activityIdIn("join");
assertReturnedProcessInstances(query, gatewaySubProcessInstance2);
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationVariableTest method modifyAProcessInstanceWithLocalVariableCreation.
@Test
public void modifyAProcessInstanceWithLocalVariableCreation() {
// given a process that sets a local variable when entering the user task
BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().userTask("userTask").camundaTaskListenerClass("create", "org.camunda.bpm.engine.test.api.runtime.util.CreateLocalVariableEventListener").endEvent().done();
testHelper.deployAndGetDefinition(instance);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
// when I start another activity and delete the old one
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("userTask").cancelActivityInstance(updatedTree.getActivityInstances("userTask")[0].getId()).execute(false, false);
// then migration was successful and I can finish the process
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testMICallActivityReturnAfterProcessInstanceSuspendByProcessDefinitionId.
@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 testMICallActivityReturnAfterProcessInstanceSuspendByProcessDefinitionId() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("callMISimpleProcess");
runtimeService.suspendProcessInstanceByProcessDefinitionId(instance.getProcessDefinitionId());
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.activateProcessInstanceByProcessDefinitionId(instance.getProcessDefinitionId());
taskService.complete(task1.getId());
taskService.complete(task2.getId());
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testTaskLifecycleOperationsFailAfterProcessInstanceSuspendByProcessDefinitionKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTaskLifecycleOperationsFailAfterProcessInstanceSuspendByProcessDefinitionKey() {
// 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.suspendProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
// 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
}
}
Aggregations