Search in sources :

Example 41 with CaseDefinition

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

Example 42 with CaseDefinition

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

Example 43 with CaseDefinition

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

Example 44 with CaseDefinition

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);
    }
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) TenantIdProvider(org.camunda.bpm.engine.impl.cfg.multitenancy.TenantIdProvider) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) TenantIdProviderCaseInstanceContext(org.camunda.bpm.engine.impl.cfg.multitenancy.TenantIdProviderCaseInstanceContext)

Example 45 with CaseDefinition

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

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