use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessDefinitionSuspensionTest method testStartProcessInstanceForSuspendedProcessDefinition.
@Deployment(resources = { "org/activiti/engine/test/db/processOne.bpmn20.xml" })
public void testStartProcessInstanceForSuspendedProcessDefinition() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
repositoryService.suspendProcessDefinitionById(processDefinition.getId());
// By id
try {
runtimeService.startProcessInstanceById(processDefinition.getId());
fail("Exception is expected but not thrown");
} catch (ActivitiException e) {
assertTextPresentIgnoreCase("cannot start process instance", e.getMessage());
}
// By Key
try {
runtimeService.startProcessInstanceByKey(processDefinition.getKey());
fail("Exception is expected but not thrown");
} catch (ActivitiException e) {
assertTextPresentIgnoreCase("cannot start process instance", e.getMessage());
}
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessDefinitionSuspensionTest method testProcessDefinitionActiveByDefault.
@Deployment(resources = { "org/activiti/engine/test/db/processOne.bpmn20.xml" })
public void testProcessDefinitionActiveByDefault() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertFalse(processDefinition.isSuspended());
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessDefinitionSuspensionTest method testQueryForActiveDefinitions.
@Deployment(resources = { "org/activiti/engine/test/db/processOne.bpmn20.xml", "org/activiti/engine/test/db/processTwo.bpmn20.xml" })
public void testQueryForActiveDefinitions() {
// default = all definitions
List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery().list();
assertEquals(2, processDefinitionList.size());
assertEquals(2, repositoryService.createProcessDefinitionQuery().active().count());
ProcessDefinition processDefinition = processDefinitionList.get(0);
repositoryService.suspendProcessDefinitionById(processDefinition.getId());
assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
assertEquals(1, repositoryService.createProcessDefinitionQuery().active().count());
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessDefinitionSuspensionTest method testContinueProcessAfterProcessDefinitionSuspend.
@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testContinueProcessAfterProcessDefinitionSuspend() {
// Start Process Instance
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.startProcessInstanceByKey(processDefinition.getKey());
// Verify one task is created
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
// Suspend process definition
repositoryService.suspendProcessDefinitionById(processDefinition.getId());
// Process should be able to continue
taskService.complete(task.getId());
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessDefinitionSuspensionTest method testDelayedActivateProcessDefinition.
@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testDelayedActivateProcessDefinition() {
Date startTime = new Date();
processEngineConfiguration.getClock().setCurrentTime(startTime);
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
repositoryService.suspendProcessDefinitionById(processDefinition.getId());
// Try to start process instance. It should fail now.
try {
runtimeService.startProcessInstanceById(processDefinition.getId());
fail();
} catch (ActivitiException e) {
assertTextPresentIgnoreCase("suspended", e.getMessage());
}
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
assertEquals(0, repositoryService.createProcessDefinitionQuery().active().count());
assertEquals(1, repositoryService.createProcessDefinitionQuery().suspended().count());
// Activate in a day from now
long oneDayFromStart = startTime.getTime() + (24 * 60 * 60 * 1000);
repositoryService.activateProcessDefinitionById(processDefinition.getId(), false, new Date(oneDayFromStart));
// Move clock two days and let job executor run
long twoDaysFromStart = startTime.getTime() + (2 * 24 * 60 * 60 * 1000);
processEngineConfiguration.getClock().setCurrentTime(new Date(twoDaysFromStart));
waitForJobExecutorToProcessAllJobs(5000L, 50L);
// Starting a process instance should now succeed
runtimeService.startProcessInstanceById(processDefinition.getId());
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
assertEquals(1, repositoryService.createProcessDefinitionQuery().active().count());
assertEquals(0, repositoryService.createProcessDefinitionQuery().suspended().count());
}
Aggregations