use of org.activiti.engine.runtime.ProcessInstance 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.runtime.ProcessInstance 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());
}
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testJobNotExecutedAfterProcessInstanceSuspend.
@Deployment
public void testJobNotExecutedAfterProcessInstanceSuspend() {
Date now = new Date();
processEngineConfiguration.getClock().setCurrentTime(now);
// Suspending the process instance should also stop the execution of jobs for that process instance
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
assertEquals(1, managementService.createJobQuery().count());
runtimeService.suspendProcessInstanceById(processInstance.getId());
assertEquals(1, managementService.createJobQuery().count());
// The jobs should not be executed now
// Timer is set to fire on 5 minutes
processEngineConfiguration.getClock().setCurrentTime(new Date(now.getTime() + (60 * 60 * 1000)));
Job job = managementService.createJobQuery().executable().singleResult();
assertNull(job);
assertEquals(1, managementService.createJobQuery().count());
// Activation of the process instance should now allow for job execution
runtimeService.activateProcessInstanceById(processInstance.getId());
waitForJobExecutorToProcessAllJobs(1000L, 100L);
assertEquals(0, managementService.createJobQuery().count());
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ProcessInstanceUpdateBusinessKeyTest method testUpdateExistingBusinessKey.
@Deployment
public void testUpdateExistingBusinessKey() {
runtimeService.startProcessInstanceByKey("businessKeyProcess", "testKey");
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertEquals("testKey", processInstance.getBusinessKey());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertEquals("testKey", historicProcessInstance.getBusinessKey());
}
runtimeService.updateBusinessKey(processInstance.getId(), "newKey");
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertEquals("newKey", processInstance.getBusinessKey());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertEquals("newKey", historicProcessInstance.getBusinessKey());
}
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ProcessInstanceUpdateBusinessKeyTest method testProcessInstanceUpdateBusinessKey.
@Deployment
public void testProcessInstanceUpdateBusinessKey() {
runtimeService.startProcessInstanceByKey("businessKeyProcess");
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertEquals("bzKey", processInstance.getBusinessKey());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertEquals("bzKey", historicProcessInstance.getBusinessKey());
}
}
Aggregations