Search in sources :

Example 6 with Execution

use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.

the class ImportExportTest method testConvertXMLToModel.

public void testConvertXMLToModel() throws Exception {
    BpmnModel bpmnModel = readXMLFile();
    bpmnModel = exportAndReadXMLFile(bpmnModel);
    byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
    org.activiti.engine.repository.Deployment deployment = processEngine.getRepositoryService().createDeployment().name("test1").addString("test1.bpmn20.xml", new String(xml)).deploy();
    String processInstanceKey = runtimeService.startProcessInstanceByKey("process").getId();
    Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstanceKey).messageEventSubscriptionName("InterruptMessage").singleResult();
    assertNotNull(execution);
}
Also used : Execution(org.activiti.engine.runtime.Execution) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter)

Example 7 with Execution

use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.

the class MultiInstanceTest method testMultiInstanceParallelReceiveTask.

@Deployment
public void testMultiInstanceParallelReceiveTask() {
    runtimeService.startProcessInstanceByKey("multi-instance-receive");
    List<Execution> executions = runtimeService.createExecutionQuery().activityId("theReceiveTask").list();
    assertEquals(4, executions.size());
    // Complete all four of the executions
    for (Execution execution : executions) {
        runtimeService.signal(execution.getId());
    }
    // There is one task after the task
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    taskService.complete(task.getId());
    assertEquals(0, runtimeService.createExecutionQuery().count());
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) Execution(org.activiti.engine.runtime.Execution) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) Deployment(org.activiti.engine.test.Deployment)

Example 8 with Execution

use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.

the class MultiInstanceTest method testParallelSubProcessAllAutomatic.

@Deployment
public void testParallelSubProcessAllAutomatic() {
    String procId = runtimeService.startProcessInstanceByKey("miParallelSubprocessAllAutomatics", CollectionUtil.singletonMap("nrOfLoops", 5)).getId();
    Execution waitState = runtimeService.createExecutionQuery().singleResult();
    assertEquals(10, runtimeService.getVariable(waitState.getId(), "sum"));
    runtimeService.signal(waitState.getId());
    assertProcessEnded(procId);
}
Also used : Execution(org.activiti.engine.runtime.Execution) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) Deployment(org.activiti.engine.test.Deployment)

Example 9 with Execution

use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.

the class MultiInstanceTest method testMultiInstanceParalelReceiveTaskWithTimer.

@Deployment
public void testMultiInstanceParalelReceiveTaskWithTimer() {
    Date startTime = new Date();
    processEngineConfiguration.getClock().setCurrentTime(startTime);
    runtimeService.startProcessInstanceByKey("multiInstanceReceiveWithTimer");
    List<Execution> executions = runtimeService.createExecutionQuery().activityId("theReceiveTask").list();
    assertEquals(3, executions.size());
    // Signal only one execution. Then the timer will fire
    runtimeService.signal(executions.get(1).getId());
    processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + 60000L));
    waitForJobExecutorToProcessAllJobs(10000L, 1000L);
    // The process should now be in the task after the timer
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("Task after timer", task.getName());
    // Completing it should end the process
    taskService.complete(task.getId());
    assertEquals(0, runtimeService.createExecutionQuery().count());
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) Execution(org.activiti.engine.runtime.Execution) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) Date(java.util.Date) Deployment(org.activiti.engine.test.Deployment)

Example 10 with Execution

use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.

the class MultiInstanceTest method testParallelUserTasksExecutionAndTaskListeners.

@Deployment
public void testParallelUserTasksExecutionAndTaskListeners() {
    runtimeService.startProcessInstanceByKey("miParallelUserTasks");
    List<Task> tasks = taskService.createTaskQuery().list();
    for (Task task : tasks) {
        taskService.complete(task.getId());
    }
    Execution waitState = runtimeService.createExecutionQuery().singleResult();
    assertEquals(3, runtimeService.getVariable(waitState.getId(), "taskListenerCounter"));
    assertEquals(3, runtimeService.getVariable(waitState.getId(), "executionListenerCounter"));
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) Execution(org.activiti.engine.runtime.Execution) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) Deployment(org.activiti.engine.test.Deployment)

Aggregations

Execution (org.activiti.engine.runtime.Execution)131 Deployment (org.activiti.engine.test.Deployment)105 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)75 Task (org.activiti.engine.task.Task)33 HashMap (java.util.HashMap)30 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)12 DelegateExecution (org.activiti.engine.delegate.DelegateExecution)12 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)12 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)10 ExecutionQuery (org.activiti.engine.runtime.ExecutionQuery)10 HttpPut (org.apache.http.client.methods.HttpPut)10 StringEntity (org.apache.http.entity.StringEntity)9 ArrayList (java.util.ArrayList)8 ActivitiException (org.activiti.engine.ActivitiException)8 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 Date (java.util.Date)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)5 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)5