Search in sources :

Example 41 with CaseExecution

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

the class CaseServiceCaseInstanceTest method testCompleteWithEnabledStage.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneStageCase.cmmn" })
public void testCompleteWithEnabledStage() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    caseService.withCaseDefinition(caseDefinitionId).create();
    CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    CaseExecution caseExecution2 = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_2").singleResult();
    // when
    caseService.withCaseExecution(caseExecution.getId()).complete();
    caseService.withCaseExecution(caseExecution2.getId()).complete();
    // then
    // the corresponding case execution has been also
    // deleted and completed
    CaseExecution caseExecution3 = caseService.createCaseExecutionQuery().activityId("PI_Stage_1").singleResult();
    assertNull(caseExecution3);
    CaseInstance caseInstance = caseService.createCaseInstanceQuery().singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isCompleted());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 42 with CaseExecution

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

the class CaseServiceCaseInstanceTest method testCompleteWithEnabledTask.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testCompleteWithEnabledTask() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
    // when
    caseService.withCaseExecution(caseInstanceId).complete();
    // then
    // the corresponding case execution has been also
    // deleted and completed
    CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    assertNull(caseExecution);
    CaseInstance caseInstance = caseService.createCaseInstanceQuery().singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isCompleted());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 43 with CaseExecution

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

the class CaseServiceCaseInstanceTest method testTerminateActiveCaseInstance.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testTerminateActiveCaseInstance() {
    // given:
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
    assertNotNull(queryCaseExecutionByActivityId("CasePlanModel_1"));
    CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1");
    assertTrue(taskExecution.isActive());
    caseService.withCaseExecution(caseInstanceId).terminate();
    CaseExecution caseInstance = queryCaseExecutionByActivityId("CasePlanModel_1");
    assertTrue(caseInstance.isTerminated());
    assertNull(queryCaseExecutionByActivityId("PI_HumanTask_1"));
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 44 with CaseExecution

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

the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToVariableInstanceFromHumanTask.

public void testPropagateTenantIdToVariableInstanceFromHumanTask() {
    deploymentForTenant(TENANT_ID, CMMN_FILE);
    createCaseInstance();
    VariableMap variables = Variables.createVariables().putValue("var", "test");
    CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    caseService.setVariables(caseExecution.getId(), variables);
    VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();
    assertThat(variableInstance, is(notNullValue()));
    // inherit the tenant id from human task
    assertThat(variableInstance.getTenantId(), is(TENANT_ID));
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) VariableMap(org.camunda.bpm.engine.variable.VariableMap) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance)

Example 45 with CaseExecution

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

the class TenantIdProviderTest method providerNotCalledForProcessDefinitionWithTenantId_ProcessTask.

@Test
public void providerNotCalledForProcessDefinitionWithTenantId_ProcessTask() {
    ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
    TestTenantIdProvider.delegate = tenantIdProvider;
    testRule.deployForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().userTask().done(), "org/camunda/bpm/engine/test/api/multitenancy/CaseWithProcessTask.cmmn");
    // if the case is started
    engineRule.getCaseService().createCaseInstanceByKey("testCase");
    CaseExecution caseExecution = engineRule.getCaseService().createCaseExecutionQuery().activityId("PI_ProcessTask_1").singleResult();
    // then the tenant id provider is not invoked
    assertThat(tenantIdProvider.parameters.size(), is(0));
}
Also used : DelegateCaseExecution(org.camunda.bpm.engine.delegate.DelegateCaseExecution) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) Test(org.junit.Test)

Aggregations

CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)280 Deployment (org.camunda.bpm.engine.test.Deployment)246 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)61 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)48 Task (org.camunda.bpm.engine.task.Task)28 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)27 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)18 Test (org.junit.Test)17 HashMap (java.util.HashMap)13 HistoricCaseActivityInstance (org.camunda.bpm.engine.history.HistoricCaseActivityInstance)11 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)11 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)9 VariableMap (org.camunda.bpm.engine.variable.VariableMap)7 DelegateCaseExecution (org.camunda.bpm.engine.delegate.DelegateCaseExecution)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)4 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)3 ArrayList (java.util.ArrayList)2 CaseService (org.camunda.bpm.engine.CaseService)2