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());
}
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());
}
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"));
}
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));
}
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));
}
Aggregations