use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testSubmitTaskFormAfterProcessInstanceSuspend.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSubmitTaskFormAfterProcessInstanceSuspend() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
runtimeService.suspendProcessInstanceById(processInstance.getId());
try {
formService.submitTaskFormData(taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId(), new HashMap<String, String>());
fail();
} catch (ActivitiException e) {
// This is expected
}
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testCannotSuspendSuspendedProcessInstance.
@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testCannotSuspendSuspendedProcessInstance() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.startProcessInstanceByKey(processDefinition.getKey());
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertFalse(processInstance.isSuspended());
runtimeService.suspendProcessInstanceById(processInstance.getId());
try {
runtimeService.suspendProcessInstanceById(processInstance.getId());
fail("Expected activiti exception");
} catch (ActivitiException e) {
// expected
}
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testTaskQueryAfterProcessInstanceSuspend.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTaskQueryAfterProcessInstanceSuspend() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
task = taskService.createTaskQuery().active().singleResult();
assertNotNull(task);
// Suspend
runtimeService.suspendProcessInstanceById(processInstance.getId());
assertEquals(1, taskService.createTaskQuery().count());
assertEquals(1, taskService.createTaskQuery().suspended().count());
assertEquals(0, taskService.createTaskQuery().active().count());
// Activate
runtimeService.activateProcessInstanceById(processInstance.getId());
assertEquals(1, taskService.createTaskQuery().count());
assertEquals(0, taskService.createTaskQuery().suspended().count());
assertEquals(1, taskService.createTaskQuery().active().count());
// Completing should end the process instance
task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testSuspendActivateProcessInstance.
@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testSuspendActivateProcessInstance() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.startProcessInstanceByKey(processDefinition.getKey());
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertFalse(processInstance.isSuspended());
//suspend
runtimeService.suspendProcessInstanceById(processInstance.getId());
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertTrue(processInstance.isSuspended());
//activate
runtimeService.activateProcessInstanceById(processInstance.getId());
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertFalse(processInstance.isSuspended());
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testTaskSuspendedAfterProcessInstanceSuspension.
@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskSuspendedAfterProcessInstanceSuspension() {
// Start Process Instance
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.startProcessInstanceByKey(processDefinition.getKey());
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
// Suspense process instance
runtimeService.suspendProcessInstanceById(processInstance.getId());
// 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.activateProcessInstanceById(processInstance.getId());
tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
for (Task task : tasks) {
assertFalse(task.isSuspended());
}
}
Aggregations