Search in sources :

Example 56 with Execution

use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.

the class ExecutionQueryTest method testQueryExecutionId.

public void testQueryExecutionId() {
    Execution execution = runtimeService.createExecutionQuery().processDefinitionKey(SEQUENTIAL_PROCESS_KEY).singleResult();
    assertNotNull(runtimeService.createExecutionQuery().executionId(execution.getId()));
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution)

Example 57 with Execution

use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.

the class MultiTenancyMessageEventReceivedCmdTenantCheckTest method correlateReceivedMessageToIntermediateCatchEventWithAuthenticatedTenant.

@Test
public void correlateReceivedMessageToIntermediateCatchEventWithAuthenticatedTenant() {
    testRule.deployForTenant(TENANT_ONE, MESSAGE_CATCH_PROCESS);
    engineRule.getRuntimeService().createProcessInstanceByKey("messageCatch").execute();
    Execution execution = engineRule.getRuntimeService().createExecutionQuery().processDefinitionKey("messageCatch").messageEventSubscriptionName("message").singleResult();
    engineRule.getIdentityService().setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    engineRule.getRuntimeService().messageEventReceived("message", execution.getId());
    engineRule.getIdentityService().clearAuthentication();
    TaskQuery query = engineRule.getTaskService().createTaskQuery();
    assertThat(query.count(), is(1L));
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) Test(org.junit.Test)

Example 58 with Execution

use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.

the class MultiTenancySignalReceiveCmdTenantCheckTest method failToSignalIntermediateCatchEventNoAuthenticatedTenants.

@Test
public void failToSignalIntermediateCatchEventNoAuthenticatedTenants() {
    testRule.deployForTenant(TENANT_ONE, SIGNAL_CATCH_PROCESS);
    engineRule.getRuntimeService().createProcessInstanceByKey("signalCatch").execute();
    Execution execution = engineRule.getRuntimeService().createExecutionQuery().processDefinitionKey("signalCatch").signalEventSubscriptionName("signal").singleResult();
    // declared expected exception
    thrown.expect(ProcessEngineException.class);
    thrown.expectMessage("Cannot update the process instance");
    engineRule.getIdentityService().setAuthentication("user", null, null);
    engineRule.getRuntimeService().signal(execution.getId(), "signal", null, null);
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) Test(org.junit.Test)

Example 59 with Execution

use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.

the class MultiTenancySignalReceiveCmdTenantCheckTest method signalIntermediateCatchEventDisabledTenantCheck.

@Test
public void signalIntermediateCatchEventDisabledTenantCheck() {
    testRule.deployForTenant(TENANT_ONE, SIGNAL_CATCH_PROCESS);
    testRule.deployForTenant(TENANT_TWO, SIGNAL_CATCH_PROCESS);
    engineRule.getRuntimeService().createProcessInstanceByKey("signalCatch").processDefinitionTenantId(TENANT_ONE).execute();
    engineRule.getRuntimeService().createProcessInstanceByKey("signalCatch").processDefinitionTenantId(TENANT_TWO).execute();
    Execution execution = engineRule.getRuntimeService().createExecutionQuery().processDefinitionKey("signalCatch").signalEventSubscriptionName("signal").tenantIdIn(TENANT_ONE).singleResult();
    engineRule.getProcessEngineConfiguration().setTenantCheckEnabled(false);
    engineRule.getIdentityService().setAuthentication("user", null, null);
    engineRule.getRuntimeService().signal(execution.getId(), "signal", null, null);
    TaskQuery query = engineRule.getTaskService().createTaskQuery();
    assertThat(query.count(), is(1L));
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
    assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L));
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) Test(org.junit.Test)

Example 60 with Execution

use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.

the class ExecutionVariablesTest method testTreeCompactionWithLocalVariableOnConcurrentExecution.

@Deployment
public void testTreeCompactionWithLocalVariableOnConcurrentExecution() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    Execution innerTaskExecution = runtimeService.createExecutionQuery().activityId("innerTask").singleResult();
    Execution subProcessConcurrentExecution = runtimeService.createExecutionQuery().executionId(((ExecutionEntity) innerTaskExecution).getParentId()).singleResult();
    Task task = taskService.createTaskQuery().taskDefinitionKey("task").singleResult();
    // when
    runtimeService.setVariableLocal(subProcessConcurrentExecution.getId(), "foo", "bar");
    // and completing the concurrent task, thereby pruning the sub process concurrent execution
    taskService.complete(task.getId());
    // then the variable still exists
    VariableInstance variable = runtimeService.createVariableInstanceQuery().singleResult();
    assertNotNull(variable);
    assertEquals("foo", variable.getName());
    assertEquals(processInstance.getId(), variable.getExecutionId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

Execution (org.camunda.bpm.engine.runtime.Execution)279 Deployment (org.camunda.bpm.engine.test.Deployment)188 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)143 Task (org.camunda.bpm.engine.task.Task)99 Test (org.junit.Test)95 HashMap (java.util.HashMap)45 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)33 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)23 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)22 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 ThrowErrorDelegate.leaveExecution (org.camunda.bpm.engine.test.bpmn.event.error.ThrowErrorDelegate.leaveExecution)18 ExecutionQuery (org.camunda.bpm.engine.runtime.ExecutionQuery)17 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)15 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)14 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)14 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)14 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)14 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)13 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)12 ArrayList (java.util.ArrayList)11