use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class CaseServiceTest method testCaseExecutionQuery.
@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/loan-application.cmmn")
public void testCaseExecutionQuery() {
// given
// there exists a deployment containing a case definition with key "loanApplication"
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionKey("loanApplication").singleResult();
assertNotNull(caseDefinition);
// when
// create a new case instance by key
CaseInstance caseInstance = caseService.withCaseDefinitionByKey(caseDefinition.getKey()).create();
// then
// the returned caseInstance is not null
assertNotNull(caseInstance);
// verify that there are three case execution:
// - the case instance itself (ie. for the casePlanModel)
// - a case execution for the stage
// - a case execution for the humanTask
List<CaseExecution> caseExecutions = caseService.createCaseExecutionQuery().caseInstanceId(caseInstance.getId()).list();
assertEquals(3, caseExecutions.size());
CaseExecution casePlanModelExecution = caseService.createCaseExecutionQuery().activityId("CasePlanModel_1").singleResult();
assertNotNull(casePlanModelExecution);
CaseExecution stageExecution = caseService.createCaseExecutionQuery().activityId("PI_Stage_1").singleResult();
assertNotNull(stageExecution);
CaseExecution humanTaskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_6").singleResult();
assertNotNull(humanTaskExecution);
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToVariableInstanceOnCreateCaseInstance.
public void testPropagateTenantIdToVariableInstanceOnCreateCaseInstance() {
deploymentForTenant(TENANT_ID, CMMN_FILE);
VariableMap variables = Variables.putValue("var", "test");
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
caseService.createCaseInstanceById(caseDefinition.getId(), variables);
VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();
assertThat(variableInstance, is(notNullValue()));
// inherit the tenant id from case instance
assertThat(variableInstance.getTenantId(), is(TENANT_ID));
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyExecutionPropagationTest method createCaseInstance.
protected void createCaseInstance() {
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
caseService.createCaseInstanceById(caseDefinition.getId());
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyRepositoryServiceTest method getPreviousCaseDefinitionWithTenantId.
@Test
public void getPreviousCaseDefinitionWithTenantId() {
testRule.deployForTenant(TENANT_ONE, CMMN);
testRule.deployForTenant(TENANT_ONE, CMMN);
testRule.deployForTenant(TENANT_ONE, CMMN);
testRule.deployForTenant(TENANT_TWO, CMMN);
testRule.deployForTenant(TENANT_TWO, CMMN);
List<CaseDefinition> latestCaseDefinitions = repositoryService.createCaseDefinitionQuery().latestVersion().orderByTenantId().asc().list();
CaseDefinitionEntity previousDefinitionTenantOne = getPreviousDefinition((CaseDefinitionEntity) latestCaseDefinitions.get(0));
CaseDefinitionEntity previousDefinitionTenantTwo = getPreviousDefinition((CaseDefinitionEntity) latestCaseDefinitions.get(1));
assertThat(previousDefinitionTenantOne.getVersion(), is(2));
assertThat(previousDefinitionTenantOne.getTenantId(), is(TENANT_ONE));
assertThat(previousDefinitionTenantTwo.getVersion(), is(1));
assertThat(previousDefinitionTenantTwo.getTenantId(), is(TENANT_TWO));
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyCaseDefinitionCmdsTenantCheckTest method getCaseDefinitionDisabledTenantCheck.
@Test
public void getCaseDefinitionDisabledTenantCheck() {
processEngineConfiguration.setTenantCheckEnabled(false);
identityService.setAuthentication("user", null, null);
CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinitionId);
assertThat(definition.getTenantId(), is(TENANT_ONE));
}
Aggregations