use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class MultiInstanceTest method testRunProcess.
@Deployment(resources = { "process/multiinstanceReceive.bpmn20.xml" })
public void testRunProcess() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miProcessExample");
List<Job> jobList = managementService.createJobQuery().list();
assertEquals(5, jobList.size());
assertEquals(5, runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("serviceTask1").count());
waitForJobExecutorToProcessAllJobs(3000, 500);
int counter = 0;
long processInstanceCount = 1;
while (processInstanceCount == 1 && counter < 20) {
Thread.sleep(500);
processInstanceCount = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count();
counter++;
}
assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class AsyncPingTest method testRunProcess.
@Deployment(resources = { "process/asyncPing.bpmn20.xml" })
public void testRunProcess() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("asyncPingProcess");
List<Execution> executionList = runtimeService.createExecutionQuery().list();
Assert.assertEquals(1, executionList.size());
managementService.executeJob(managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult().getId());
Thread.sleep(1500);
executionList = runtimeService.createExecutionQuery().list();
Assert.assertEquals(0, executionList.size());
Assert.assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class AsyncProcessTest method testRunProcess.
@Deployment(resources = { "process/async.bpmn20.xml" })
public void testRunProcess() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("asyncCamelProcess");
List<Execution> executionList = runtimeService.createExecutionQuery().list();
assertEquals(3, executionList.size());
Thread.sleep(4000);
assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ErrorHandlingTest method testCamelRouteWorksAsIntended.
/**
* Process instance should be removed after completion. Works as intended,
* if no exception interrupts the Camel route.
*
* @throws Exception
*/
@Deployment(resources = { "process/errorHandling.bpmn20.xml" })
public void testCamelRouteWorksAsIntended() throws Exception {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("routing", Routing.DEFAULT);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ErrorHandling", variables);
Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(job);
managementService.executeJob(job.getId());
Thread.sleep(WAIT);
assertEquals("Process instance not completed", 0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ErrorHandlingTest method testRollbackOnException.
/**
* Expected behavior, with default error handling in Camel:
* Roll-back to previous wait state. Fails with Activiti 5.12.
*
* @throws Exception
*/
@Deployment(resources = { "process/errorHandling.bpmn20.xml" })
public void testRollbackOnException() throws Exception {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("routing", Routing.PROVOKE_ERROR);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ErrorHandling", variables);
assertEquals("No roll-back to previous wait state", 1, runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId(PREVIOUS_WAIT_STATE).count());
assertEquals("Process instance advanced to next wait state", 0, runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId(NEXT_WAIT_STATE).count());
}
Aggregations