use of org.camunda.bpm.engine.repository.ProcessDefinition 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
}
}
use of org.camunda.bpm.engine.repository.ProcessDefinition 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.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testChangeVariablesAfterProcessInstanceSuspendByProcessDefinitionId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testChangeVariablesAfterProcessInstanceSuspendByProcessDefinitionId() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
runtimeService.suspendProcessInstanceByProcessDefinitionId(processInstance.getProcessDefinitionId());
try {
runtimeService.removeVariable(processInstance.getId(), "someVariable");
} catch (ProcessEngineException e) {
fail("This should be possible");
}
try {
runtimeService.removeVariableLocal(processInstance.getId(), "someVariable");
} catch (ProcessEngineException e) {
fail("This should be possible");
}
try {
runtimeService.removeVariables(processInstance.getId(), Arrays.asList("one", "two", "three"));
} catch (ProcessEngineException e) {
fail("This should be possible");
}
try {
runtimeService.removeVariablesLocal(processInstance.getId(), Arrays.asList("one", "two", "three"));
} catch (ProcessEngineException e) {
fail("This should be possible");
}
try {
runtimeService.setVariable(processInstance.getId(), "someVariable", "someValue");
} catch (ProcessEngineException e) {
fail("This should be possible");
}
try {
runtimeService.setVariableLocal(processInstance.getId(), "someVariable", "someValue");
} catch (ProcessEngineException e) {
fail("This should be possible");
}
try {
runtimeService.setVariables(processInstance.getId(), new HashMap<String, Object>());
} catch (ProcessEngineException e) {
fail("This should be possible");
}
try {
runtimeService.setVariablesLocal(processInstance.getId(), new HashMap<String, Object>());
} catch (ProcessEngineException e) {
fail("This should be possible");
}
}
use of org.camunda.bpm.engine.repository.ProcessDefinition 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.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testActivateAlreadyActiveProcessInstance.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testActivateAlreadyActiveProcessInstance() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.startProcessInstanceByKey(processDefinition.getKey());
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertFalse(processInstance.isSuspended());
try {
// activate
runtimeService.activateProcessInstanceById(processInstance.getId());
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertFalse(processInstance.isSuspended());
} catch (ProcessEngineException e) {
fail("Should not fail");
}
try {
// activate
runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinition.getId());
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertFalse(processInstance.isSuspended());
} catch (ProcessEngineException e) {
fail("Should not fail");
}
try {
// activate
runtimeService.activateProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertFalse(processInstance.isSuspended());
} catch (ProcessEngineException e) {
fail("Should not fail");
}
}
Aggregations