Search in sources :

Example 91 with Execution

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

the class ProcessInstanceMigrationTest method testSetProcessDefinitionVersionActivityMissing.

@Deployment(resources = { TEST_PROCESS })
public void testSetProcessDefinitionVersionActivityMissing() {
    // start process instance
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
    // check that receive task has been reached
    Execution execution = runtimeService.createExecutionQuery().activityId("waitState1").singleResult();
    assertNotNull(execution);
    // deploy new version of the process definition
    org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_ACTIVITY_MISSING).deploy();
    assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
    // migrate process instance to new process definition version
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
    SetProcessDefinitionVersionCmd setProcessDefinitionVersionCmd = new SetProcessDefinitionVersionCmd(pi.getId(), 2);
    try {
        commandExecutor.execute(setProcessDefinitionVersionCmd);
        fail("ActivitiException expected");
    } catch (ActivitiException ae) {
        assertTextPresent("The new process definition (key = 'receiveTask') does not contain the current activity (id = 'waitState1') of the process instance (id = '", ae.getMessage());
    }
    // undeploy "manually" deployed process definition
    repositoryService.deleteDeployment(deployment.getId(), true);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) Execution(org.activiti.engine.runtime.Execution) CommandExecutor(org.activiti.engine.impl.interceptor.CommandExecutor) SetProcessDefinitionVersionCmd(org.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 92 with Execution

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

the class TransactionSubProcessTest method testMultiInstanceTxSuccessful.

@Deployment(resources = { "org/activiti/engine/test/bpmn/subprocess/transaction/TransactionSubProcessTest.testMultiInstanceTx.bpmn20.xml" })
public void testMultiInstanceTxSuccessful() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("transactionProcess");
    // there are now 5 instances of the transaction:
    List<EventSubscriptionEntity> EventSubscriptionEntitys = createEventSubscriptionQuery().eventType("compensate").list();
    // there are 10 compensation event subscriptions
    assertEquals(10, EventSubscriptionEntitys.size());
    // the event subscriptions are all under the same execution (the execution of the multi-instance wrapper)
    String executionId = EventSubscriptionEntitys.get(0).getExecutionId();
    for (EventSubscriptionEntity EventSubscriptionEntity : EventSubscriptionEntitys) {
        if (!executionId.equals(EventSubscriptionEntity.getExecutionId())) {
            fail("subscriptions not under same execution");
        }
    }
    // first complete the inner user-tasks
    List<Task> tasks = taskService.createTaskQuery().list();
    for (Task task : tasks) {
        taskService.setVariable(task.getId(), "confirmed", true);
        taskService.complete(task.getId());
    }
    // now complete the inner receive tasks    
    List<Execution> executions = runtimeService.createExecutionQuery().activityId("receive").list();
    for (Execution execution : executions) {
        runtimeService.signal(execution.getId());
    }
    runtimeService.signal(runtimeService.createExecutionQuery().activityId("afterSuccess").singleResult().getId());
    assertEquals(0, createEventSubscriptionQuery().count());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.activiti.engine.task.Task) Execution(org.activiti.engine.runtime.Execution) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) EventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity) Deployment(org.activiti.engine.test.Deployment)

Example 93 with Execution

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

the class MultiInstanceTest method testParallelSubProcessAllAutomaticCompletionCondition.

@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelSubProcessAllAutomatic.bpmn20.xml" })
public void testParallelSubProcessAllAutomaticCompletionCondition() {
    String procId = runtimeService.startProcessInstanceByKey("miParallelSubprocessAllAutomatics", CollectionUtil.singletonMap("nrOfLoops", 10)).getId();
    Execution waitState = runtimeService.createExecutionQuery().singleResult();
    assertEquals(12, 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 94 with Execution

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

the class MultiInstanceTest method testParallelScriptTasksCompletionCondition.

@Deployment
public void testParallelScriptTasksCompletionCondition() {
    runtimeService.startProcessInstanceByKey("miParallelScriptTaskCompletionCondition");
    Execution waitStateExecution = runtimeService.createExecutionQuery().singleResult();
    int sum = (Integer) runtimeService.getVariable(waitStateExecution.getId(), "sum");
    assertEquals(2, sum);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Execution(org.activiti.engine.runtime.Execution) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) Deployment(org.activiti.engine.test.Deployment)

Example 95 with Execution

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

the class MultiInstanceTest method testSequentialScriptTasksCompletionCondition.

@Deployment
public void testSequentialScriptTasksCompletionCondition() {
    runtimeService.startProcessInstanceByKey("miSequentialScriptTaskCompletionCondition").getId();
    Execution waitStateExecution = runtimeService.createExecutionQuery().singleResult();
    int sum = (Integer) runtimeService.getVariable(waitStateExecution.getId(), "sum");
    assertEquals(5, sum);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) 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