use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testSubTaskCreationFailAfterProcessInstanceSuspendByProcessDefinitionId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSubTaskCreationFailAfterProcessInstanceSuspendByProcessDefinitionId() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinition.getId());
Task subTask = taskService.newTask("someTaskId");
subTask.setParentTaskId(task.getId());
try {
taskService.saveTask(subTask);
fail("Creating sub tasks for suspended task should not be possible");
} catch (SuspendedEntityInteractionException e) {
}
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testTaskSuspendedAfterProcessInstanceSuspensionByProcessDefinitionKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskSuspendedAfterProcessInstanceSuspensionByProcessDefinitionKey() {
// Start Process Instance
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.startProcessInstanceByKey(processDefinition.getKey());
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
// Suspense process instance
runtimeService.suspendProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
// Assert that the task is now also suspended
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
for (Task task : tasks) {
assertTrue(task.isSuspended());
}
// Activate process instance again
runtimeService.activateProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
for (Task task : tasks) {
assertFalse(task.isSuspended());
}
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testChildExecutionsSuspendedAfterProcessInstanceSuspendByProcessDefinitionKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/ProcessInstanceSuspensionTest.testChildExecutionsSuspendedAfterProcessInstanceSuspend.bpmn20.xml" })
public void testChildExecutionsSuspendedAfterProcessInstanceSuspendByProcessDefinitionKey() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testChildExecutionsSuspended");
runtimeService.suspendProcessInstanceByProcessDefinitionKey("testChildExecutionsSuspended");
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).list();
for (Execution execution : executions) {
assertTrue(execution.isSuspended());
}
// Activate again
runtimeService.activateProcessInstanceByProcessDefinitionKey("testChildExecutionsSuspended");
executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).list();
for (Execution execution : executions) {
assertFalse(execution.isSuspended());
}
// Finish process
while (taskService.createTaskQuery().count() > 0) {
for (Task task : taskService.createTaskQuery().list()) {
taskService.complete(task.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 testChildExecutionsSuspendedAfterProcessInstanceSuspendByProcessDefinitionId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/ProcessInstanceSuspensionTest.testChildExecutionsSuspendedAfterProcessInstanceSuspend.bpmn20.xml" })
public void testChildExecutionsSuspendedAfterProcessInstanceSuspendByProcessDefinitionId() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testChildExecutionsSuspended");
runtimeService.suspendProcessInstanceByProcessDefinitionId(processInstance.getProcessDefinitionId());
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).list();
for (Execution execution : executions) {
assertTrue(execution.isSuspended());
}
// Activate again
runtimeService.activateProcessInstanceByProcessDefinitionId(processInstance.getProcessDefinitionId());
executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).list();
for (Execution execution : executions) {
assertFalse(execution.isSuspended());
}
// Finish process
while (taskService.createTaskQuery().count() > 0) {
for (Task task : taskService.createTaskQuery().list()) {
taskService.complete(task.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 testCallActivityReturnAfterProcessInstanceSuspend.
@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 testCallActivityReturnAfterProcessInstanceSuspend() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("callSimpleProcess");
runtimeService.suspendProcessInstanceById(instance.getId());
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.activateProcessInstanceById(instance.getId());
taskService.complete(task.getId());
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
}
Aggregations