Search in sources :

Example 11 with CaseDefinition

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));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Test(org.junit.Test)

Example 12 with CaseDefinition

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);
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Date(java.util.Date)

Example 13 with CaseDefinition

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));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) CaseDefinitionQuery(org.camunda.bpm.engine.repository.CaseDefinitionQuery)

Example 14 with CaseDefinition

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));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) CaseDefinitionQuery(org.camunda.bpm.engine.repository.CaseDefinitionQuery)

Example 15 with CaseDefinition

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));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) CaseDefinitionQuery(org.camunda.bpm.engine.repository.CaseDefinitionQuery)

Aggregations

CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)65 Deployment (org.camunda.bpm.engine.test.Deployment)17 Test (org.junit.Test)14 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)13 CaseDefinitionQuery (org.camunda.bpm.engine.repository.CaseDefinitionQuery)12 ArrayList (java.util.ArrayList)8 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)5 Response (com.jayway.restassured.response.Response)4 Date (java.util.Date)4 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)4 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)3 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)3 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)2 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 User (org.camunda.bpm.engine.identity.User)2