use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method setNullTenantIdForCaseInstance.
@Test
public void setNullTenantIdForCaseInstance() {
String tenantId = null;
StaticTenantIdTestProvider tenantIdProvider = new StaticTenantIdTestProvider(tenantId);
TestTenantIdProvider.delegate = tenantIdProvider;
testRule.deploy(CMMN_FILE_WITH_MANUAL_ACTIVATION);
// if a case instance is created
engineRule.getCaseService().withCaseDefinitionByKey(CASE_DEFINITION_KEY).create();
// then the tenant id provider can set the tenant id to null
CaseInstance caseInstance = engineRule.getCaseService().createCaseInstanceQuery().singleResult();
assertThat(caseInstance.getTenantId(), is(nullValue()));
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method setNullTenantId_SubCaseInstance.
@Test
public void setNullTenantId_SubCaseInstance() {
String tenantId = null;
SetValueOnSubCaseInstanceTenantIdProvider tenantIdProvider = new SetValueOnSubCaseInstanceTenantIdProvider(tenantId);
TestTenantIdProvider.delegate = tenantIdProvider;
testRule.deploy(CMMN_SUBPROCESS_FILE, CMMN_FILE);
// if a case instance is created
engineRule.getCaseService().withCaseDefinitionByKey(CASE_DEFINITION_KEY).create();
// then the tenant id provider can set the tenant id to null
CaseInstance caseInstance = engineRule.getCaseService().createCaseInstanceQuery().caseDefinitionKey("oneTaskCase").singleResult();
assertThat(caseInstance.getTenantId(), is(nullValue()));
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class MultiTenancyCleanableHistoricCaseInstanceReportCmdTenantCheckTest method prepareCaseInstances.
private void prepareCaseInstances(String key, int daysInThePast, Integer historyTimeToLive, int instanceCount, String tenantId) {
// update time to live
List<CaseDefinition> caseDefinitions = null;
if (tenantId != null) {
caseDefinitions = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).tenantIdIn(tenantId).list();
} else {
caseDefinitions = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).withoutTenantId().list();
}
assertEquals(1, caseDefinitions.size());
repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinitions.get(0).getId(), historyTimeToLive);
Date oldCurrentTime = ClockUtil.getCurrentTime();
ClockUtil.setCurrentTime(DateUtils.addDays(new Date(), daysInThePast));
for (int i = 0; i < instanceCount; i++) {
CaseInstance caseInstance = caseService.createCaseInstanceById(caseDefinitions.get(0).getId());
if (tenantId != null) {
assertEquals(tenantId, caseInstance.getTenantId());
}
caseService.terminateCaseExecution(caseInstance.getId());
caseService.closeCaseInstance(caseInstance.getId());
}
ClockUtil.setCurrentTime(oldCurrentTime);
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class MultiTenancyDecisionTaskTest method createCaseInstance.
protected CaseInstance createCaseInstance(String caseDefinitionKey, String tenantId) {
CaseInstance caseInstance = caseService.withCaseDefinitionByKey(caseDefinitionKey).caseDefinitionTenantId(tenantId).create();
CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId(DECISION_TASK_ID).tenantIdIn(tenantId).singleResult();
caseService.withCaseExecution(caseExecution.getId()).setVariable("status", "gold").manualStart();
return caseInstance;
}
use of org.camunda.bpm.engine.runtime.CaseInstance in project camunda-bpm-platform by camunda.
the class MultiTenancyDecisionTaskTest method testEvaluateDecisionWithVersionBinding.
public void testEvaluateDecisionWithVersionBinding() {
deploymentForTenant(TENANT_ONE, CMMN_VERSION, DMN_FILE);
deploymentForTenant(TENANT_ONE, DMN_FILE_VERSION_TWO);
deploymentForTenant(TENANT_TWO, CMMN_VERSION, DMN_FILE_VERSION_TWO);
deploymentForTenant(TENANT_TWO, DMN_FILE);
CaseInstance caseInstanceOne = createCaseInstance(CASE_DEFINITION_KEY, TENANT_ONE);
CaseInstance caseInstanceTwo = createCaseInstance(CASE_DEFINITION_KEY, TENANT_TWO);
assertThat((String) caseService.getVariable(caseInstanceOne.getId(), "decisionVar"), is(RESULT_OF_VERSION_ONE));
assertThat((String) caseService.getVariable(caseInstanceTwo.getId(), "decisionVar"), is(RESULT_OF_VERSION_TWO));
}
Aggregations