Search in sources :

Example 1 with ProcessInstance

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());
}
Also used : ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Job(org.activiti.engine.runtime.Job) Deployment(org.activiti.engine.test.Deployment)

Example 2 with ProcessInstance

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());
}
Also used : Execution(org.activiti.engine.runtime.Execution) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 3 with ProcessInstance

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());
}
Also used : Execution(org.activiti.engine.runtime.Execution) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 4 with ProcessInstance

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());
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Job(org.activiti.engine.runtime.Job) Deployment(org.activiti.engine.test.Deployment)

Example 5 with ProcessInstance

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());
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

ProcessInstance (org.activiti.engine.runtime.ProcessInstance)822 Deployment (org.activiti.engine.test.Deployment)708 Task (org.activiti.engine.task.Task)374 HashMap (java.util.HashMap)242 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)182 Execution (org.activiti.engine.runtime.Execution)76 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)64 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)57 Job (org.activiti.engine.runtime.Job)55 Date (java.util.Date)53 JsonNode (com.fasterxml.jackson.databind.JsonNode)49 Calendar (java.util.Calendar)48 ActivitiException (org.activiti.engine.ActivitiException)41 ArrayList (java.util.ArrayList)38 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)38 HttpGet (org.apache.http.client.methods.HttpGet)38 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)27 StringEntity (org.apache.http.entity.StringEntity)27 HttpPost (org.apache.http.client.methods.HttpPost)25 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)24