use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyCreateCaseInstanceTest method testFailToCreateCaseInstanceByIdWithoutTenantId.
public void testFailToCreateCaseInstanceByIdWithoutTenantId() {
deployment(CMMN_FILE);
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
try {
caseService.withCaseDefinition(caseDefinition.getId()).caseDefinitionWithoutTenantId().create();
fail("BadUserRequestException exception");
} catch (BadUserRequestException e) {
assertThat(e.getMessage(), containsString("Cannot specify a tenant-id"));
}
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyCaseDefinitionQueryTest method testQueryByLatestWithoutTenantId.
public void testQueryByLatestWithoutTenantId() {
// deploy a second version without tenant id
deployment(CMMN);
CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(CASE_DEFINITION_KEY).latestVersion().withoutTenantId();
assertThat(query.count(), is(1L));
CaseDefinition cDefinition = query.singleResult();
assertThat(cDefinition.getTenantId(), is(nullValue()));
assertThat(cDefinition.getVersion(), is(2));
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyCaseDefinitionQueryTest method testQueryByLatestNoTenantIdSet.
public void testQueryByLatestNoTenantIdSet() {
// deploy a second version for tenant one
deploymentForTenant(TENANT_ONE, CMMN);
CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(CASE_DEFINITION_KEY).latestVersion();
// one definition for each tenant
assertThat(query.count(), is(3L));
Map<String, CaseDefinition> caseDefinitionsForTenant = getCaseDefinitionsForTenant(query.list());
assertThat(caseDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2));
assertThat(caseDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1));
assertThat(caseDefinitionsForTenant.get(null).getVersion(), is(1));
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class CaseExecutionEntity method provideTenantId.
protected void provideTenantId(Map<String, Object> variables) {
TenantIdProvider tenantIdProvider = Context.getProcessEngineConfiguration().getTenantIdProvider();
if (tenantIdProvider != null) {
VariableMap variableMap = Variables.fromMap(variables);
CaseDefinition caseDefinition = (CaseDefinition) getCaseDefinition();
TenantIdProviderCaseInstanceContext ctx = null;
if (superExecutionId != null) {
ctx = new TenantIdProviderCaseInstanceContext(caseDefinition, variableMap, getSuperExecution());
} else if (superCaseExecutionId != null) {
ctx = new TenantIdProviderCaseInstanceContext(caseDefinition, variableMap, getSuperCaseExecution());
} else {
ctx = new TenantIdProviderCaseInstanceContext(caseDefinition, variableMap);
}
tenantId = tenantIdProvider.provideTenantIdForCaseInstance(ctx);
}
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class CaseDefinitionQueryTest method testCaseDefinitionProperties.
public void testCaseDefinitionProperties() {
List<CaseDefinition> caseDefinitions = repositoryService.createCaseDefinitionQuery().orderByCaseDefinitionName().asc().orderByCaseDefinitionVersion().asc().orderByCaseDefinitionCategory().asc().list();
CaseDefinition caseDefinition = caseDefinitions.get(0);
assertEquals("one", caseDefinition.getKey());
assertEquals("One", caseDefinition.getName());
assertTrue(caseDefinition.getId().startsWith("one:1"));
assertEquals("Examples", caseDefinition.getCategory());
assertEquals(1, caseDefinition.getVersion());
assertEquals("org/camunda/bpm/engine/test/repository/one.cmmn", caseDefinition.getResourceName());
assertEquals(deploymentOneId, caseDefinition.getDeploymentId());
caseDefinition = caseDefinitions.get(1);
assertEquals("one", caseDefinition.getKey());
assertEquals("One", caseDefinition.getName());
assertTrue(caseDefinition.getId().startsWith("one:2"));
assertEquals("Examples", caseDefinition.getCategory());
assertEquals(2, caseDefinition.getVersion());
assertEquals("org/camunda/bpm/engine/test/repository/one.cmmn", caseDefinition.getResourceName());
assertEquals(deploymentTwoId, caseDefinition.getDeploymentId());
caseDefinition = caseDefinitions.get(2);
assertEquals("two", caseDefinition.getKey());
assertEquals("Two", caseDefinition.getName());
assertTrue(caseDefinition.getId().startsWith("two:1"));
assertEquals("Examples2", caseDefinition.getCategory());
assertEquals(1, caseDefinition.getVersion());
assertEquals("org/camunda/bpm/engine/test/repository/two.cmmn", caseDefinition.getResourceName());
assertEquals(deploymentOneId, caseDefinition.getDeploymentId());
}
Aggregations