use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testTaskNonLifecycleOperationsSucceedAfterProcessInstanceSuspendByProcessDefinitionId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTaskNonLifecycleOperationsSucceedAfterProcessInstanceSuspendByProcessDefinitionId() {
// 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();
runtimeService.suspendProcessInstanceByProcessDefinitionId(processInstance.getProcessDefinitionId());
assertNotNull(task);
try {
taskService.setVariable(task.getId(), "someVar", "someValue");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.setVariableLocal(task.getId(), "someVar", "someValue");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
HashMap<String, String> variables = new HashMap<String, String>();
variables.put("varOne", "one");
variables.put("varTwo", "two");
taskService.setVariables(task.getId(), variables);
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
HashMap<String, String> variables = new HashMap<String, String>();
variables.put("varOne", "one");
variables.put("varTwo", "two");
taskService.setVariablesLocal(task.getId(), variables);
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.removeVariable(task.getId(), "someVar");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.removeVariableLocal(task.getId(), "someVar");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.removeVariables(task.getId(), Arrays.asList("one", "two"));
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.removeVariablesLocal(task.getId(), Arrays.asList("one", "two"));
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
if (processEngineConfiguration.getHistoryLevel().getId() > HistoryLevel.HISTORY_LEVEL_ACTIVITY.getId()) {
try {
taskService.createComment(task.getId(), processInstance.getId(), "test comment");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.createAttachment("text", task.getId(), processInstance.getId(), "tesTastName", "testDescription", "http://test.com");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
}
try {
taskService.setPriority(task.getId(), 99);
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testSubTaskCreationFailAfterProcessInstanceSuspend.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSubTaskCreationFailAfterProcessInstanceSuspend() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
runtimeService.suspendProcessInstanceById(processInstance.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 testTaskNonLifecycleOperationsSucceedAfterProcessInstanceSuspend.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTaskNonLifecycleOperationsSucceedAfterProcessInstanceSuspend() {
// 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();
runtimeService.suspendProcessInstanceById(processInstance.getId());
assertNotNull(task);
try {
taskService.setVariable(task.getId(), "someVar", "someValue");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.setVariableLocal(task.getId(), "someVar", "someValue");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
HashMap<String, String> variables = new HashMap<String, String>();
variables.put("varOne", "one");
variables.put("varTwo", "two");
taskService.setVariables(task.getId(), variables);
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
HashMap<String, String> variables = new HashMap<String, String>();
variables.put("varOne", "one");
variables.put("varTwo", "two");
taskService.setVariablesLocal(task.getId(), variables);
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.removeVariable(task.getId(), "someVar");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.removeVariableLocal(task.getId(), "someVar");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.removeVariables(task.getId(), Arrays.asList("one", "two"));
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.removeVariablesLocal(task.getId(), Arrays.asList("one", "two"));
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
if (processEngineConfiguration.getHistoryLevel().getId() > HistoryLevel.HISTORY_LEVEL_ACTIVITY.getId()) {
try {
taskService.createComment(task.getId(), processInstance.getId(), "test comment");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
try {
taskService.createAttachment("text", task.getId(), processInstance.getId(), "tesTastName", "testDescription", "http://test.com");
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
}
try {
taskService.setPriority(task.getId(), 99);
} catch (SuspendedEntityInteractionException e) {
fail("should be allowed");
}
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testProcessInstanceActiveByDefault.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testProcessInstanceActiveByDefault() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.startProcessInstanceByKey(processDefinition.getKey());
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertFalse(processInstance.isSuspended());
}
use of org.camunda.bpm.engine.repository.ProcessDefinition 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
}
}
Aggregations