use of org.activiti.engine.ActivitiException 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.ActivitiException in project Activiti by Activiti.
the class ExecutionQueryTest method testQueryByActivityId.
public void testQueryByActivityId() {
ExecutionQuery query = runtimeService.createExecutionQuery().activityId("receivePayment");
assertEquals(4, query.list().size());
assertEquals(4, query.count());
try {
assertNull(query.singleResult());
fail();
} catch (ActivitiException e) {
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class ProcessInstanceQueryTest method testQueryByProcessDefinitionKeys.
public void testQueryByProcessDefinitionKeys() {
final Set<String> processDefinitionKeySet = new HashSet<String>(2);
processDefinitionKeySet.add(PROCESS_DEFINITION_KEY);
processDefinitionKeySet.add(PROCESS_DEFINITION_KEY_2);
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionKeys(processDefinitionKeySet);
assertEquals(PROCESS_DEPLOY_COUNT, query.count());
assertEquals(PROCESS_DEPLOY_COUNT, query.list().size());
try {
query.singleResult();
fail();
} catch (ActivitiException e) {
// Exception is expected
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testCannotActivateActiveProcessInstance.
@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testCannotActivateActiveProcessInstance() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.startProcessInstanceByKey(processDefinition.getKey());
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertFalse(processInstance.isSuspended());
try {
//activate
runtimeService.activateProcessInstanceById(processInstance.getId());
fail("Expected activiti exception");
} catch (ActivitiException e) {
// expected
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class RepositoryServiceTest method testDeploymentWithDelayedProcessDefinitionActivation.
public void testDeploymentWithDelayedProcessDefinitionActivation() {
Date startTime = new Date();
processEngineConfiguration.getClock().setCurrentTime(startTime);
Date inThreeDays = new Date(startTime.getTime() + (3 * 24 * 60 * 60 * 1000));
// Deploy process, but activate after three days
org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml").addClasspathResource("org/activiti/engine/test/api/twoTasksProcess.bpmn20.xml").activateProcessDefinitionsOn(inThreeDays).deploy();
assertEquals(1, repositoryService.createDeploymentQuery().count());
assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
assertEquals(2, repositoryService.createProcessDefinitionQuery().suspended().count());
assertEquals(0, repositoryService.createProcessDefinitionQuery().active().count());
// Shouldn't be able to start a process instance
try {
runtimeService.startProcessInstanceByKey("oneTaskProcess");
fail();
} catch (ActivitiException e) {
assertTextPresentIgnoreCase("suspended", e.getMessage());
}
// Move time four days forward, the timer will fire and the process definitions will be active
Date inFourDays = new Date(startTime.getTime() + (4 * 24 * 60 * 60 * 1000));
processEngineConfiguration.getClock().setCurrentTime(inFourDays);
waitForJobExecutorToProcessAllJobs(5000L, 50L);
assertEquals(1, repositoryService.createDeploymentQuery().count());
assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
assertEquals(0, repositoryService.createProcessDefinitionQuery().suspended().count());
assertEquals(2, repositoryService.createProcessDefinitionQuery().active().count());
// Should be able to start process instance
runtimeService.startProcessInstanceByKey("oneTaskProcess");
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
// Cleanup
repositoryService.deleteDeployment(deployment.getId(), true);
}
Aggregations