use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyCaseDefinitionCmdsTenantCheckTest method updateHistoryTimeToLiveDisabledTenantCheck.
@Test
public void updateHistoryTimeToLiveDisabledTenantCheck() {
processEngineConfiguration.setTenantCheckEnabled(false);
identityService.setAuthentication("user", null, null);
repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinitionId, 6);
CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinitionId);
assertThat(definition.getTenantId(), is(TENANT_ONE));
assertThat(definition.getHistoryTimeToLive(), is(6));
}
use of org.camunda.bpm.engine.repository.CaseDefinition 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.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyCaseDefinitionQueryTest method testQueryByLatestWithTenantId.
public void testQueryByLatestWithTenantId() {
// deploy a second version for tenant one
deploymentForTenant(TENANT_ONE, CMMN);
CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(CASE_DEFINITION_KEY).latestVersion().tenantIdIn(TENANT_ONE);
assertThat(query.count(), is(1L));
CaseDefinition caseDefinition = query.singleResult();
assertThat(caseDefinition.getTenantId(), is(TENANT_ONE));
assertThat(caseDefinition.getVersion(), is(2));
query = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(CASE_DEFINITION_KEY).latestVersion().tenantIdIn(TENANT_TWO);
assertThat(query.count(), is(1L));
caseDefinition = query.singleResult();
assertThat(caseDefinition.getTenantId(), is(TENANT_TWO));
assertThat(caseDefinition.getVersion(), is(1));
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyCaseDefinitionQueryTest method testQueryByLatestWithTenantIds.
public void testQueryByLatestWithTenantIds() {
// deploy a second version for tenant one
deploymentForTenant(TENANT_ONE, CMMN);
CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(CASE_DEFINITION_KEY).latestVersion().tenantIdIn(TENANT_ONE, TENANT_TWO);
// one definition for each tenant
assertThat(query.count(), is(2L));
Map<String, CaseDefinition> caseDefinitionsForTenant = getCaseDefinitionsForTenant(query.list());
assertThat(caseDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2));
assertThat(caseDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1));
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyCaseDefinitionQueryTest method testQueryByLatestWithTenantIdsIncludeDefinitionsWithoutTenantId.
public void testQueryByLatestWithTenantIdsIncludeDefinitionsWithoutTenantId() {
// deploy a second version without tenant id
deployment(CMMN);
// deploy a third version for tenant one
deploymentForTenant(TENANT_ONE, CMMN);
deploymentForTenant(TENANT_ONE, CMMN);
CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(CASE_DEFINITION_KEY).latestVersion().tenantIdIn(TENANT_ONE, TENANT_TWO).includeCaseDefinitionsWithoutTenantId();
assertThat(query.count(), is(3L));
Map<String, CaseDefinition> caseDefinitionsForTenant = getCaseDefinitionsForTenant(query.list());
assertThat(caseDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(3));
assertThat(caseDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1));
assertThat(caseDefinitionsForTenant.get(null).getVersion(), is(2));
}
Aggregations