use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method providerCalledWithSuperCaseInstance.
@Test
public void providerCalledWithSuperCaseInstance() {
ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
TestTenantIdProvider.delegate = tenantIdProvider;
testRule.deploy(CMMN_SUBPROCESS_FILE, CMMN_FILE_WITH_MANUAL_ACTIVATION);
CaseDefinition superCaseDefinition = engineRule.getRepositoryService().createCaseDefinitionQuery().caseDefinitionKey(CASE_DEFINITION_KEY).singleResult();
// if a case instance is created
engineRule.getCaseService().withCaseDefinitionByKey(CASE_DEFINITION_KEY).create();
startCaseTask();
// then the tenant id provider is passed in the case definition
DelegateCaseExecution superCaseExecution = tenantIdProvider.caseParameters.get(1).getSuperCaseExecution();
assertThat(superCaseExecution, is(notNullValue()));
assertThat(superCaseExecution.getCaseDefinitionId(), is(superCaseDefinition.getId()));
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method providerCalledWithCaseDefinition.
@Test
public void providerCalledWithCaseDefinition() {
ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
TestTenantIdProvider.delegate = tenantIdProvider;
testRule.deploy(CMMN_FILE_WITH_MANUAL_ACTIVATION);
CaseDefinition deployedCaseDefinition = engineRule.getRepositoryService().createCaseDefinitionQuery().singleResult();
// if a case instance is created
engineRule.getCaseService().withCaseDefinitionByKey(CASE_DEFINITION_KEY).create();
// then the tenant id provider is passed in the case definition
CaseDefinition passedCaseDefinition = tenantIdProvider.caseParameters.get(0).getCaseDefinition();
assertThat(passedCaseDefinition, is(notNullValue()));
assertThat(passedCaseDefinition.getId(), is(deployedCaseDefinition.getId()));
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyCreateCaseInstanceTest method testFailToCreateCaseInstanceByIdWithTenantId.
public void testFailToCreateCaseInstanceByIdWithTenantId() {
deploymentForTenant(TENANT_ONE, CMMN_FILE);
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
try {
caseService.withCaseDefinition(caseDefinition.getId()).caseDefinitionTenantId(TENANT_ONE).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 MultiTenancyCreateCaseInstanceTest method testCreateCaseInstanceByIdAuthenticatedTenant.
public void testCreateCaseInstanceByIdAuthenticatedTenant() {
deploymentForTenant(TENANT_ONE, CMMN_FILE);
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
caseService.withCaseDefinition(caseDefinition.getId()).create();
CaseInstanceQuery query = caseService.createCaseInstanceQuery();
assertThat(query.count(), is(1L));
assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyCreateCaseInstanceTest method testFailToCreateCaseInstanceByIdNoAuthenticatedTenants.
public void testFailToCreateCaseInstanceByIdNoAuthenticatedTenants() {
deploymentForTenant(TENANT_ONE, CMMN_FILE);
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
identityService.setAuthentication("user", null, null);
try {
caseService.withCaseDefinition(caseDefinition.getId()).create();
fail("expected exception");
} catch (ProcessEngineException e) {
assertThat(e.getMessage(), containsString("Cannot create an instance of the case definition"));
}
}
Aggregations