Search in sources :

Example 6 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class CaseServiceTest method testCaseExecutionQuery.

@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/loan-application.cmmn")
public void testCaseExecutionQuery() {
    // given
    // there exists a deployment containing a case definition with key "loanApplication"
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionKey("loanApplication").singleResult();
    assertNotNull(caseDefinition);
    // when
    // create a new case instance by key
    CaseInstance caseInstance = caseService.withCaseDefinitionByKey(caseDefinition.getKey()).create();
    // then
    // the returned caseInstance is not null
    assertNotNull(caseInstance);
    // verify that there are three case execution:
    // - the case instance itself (ie. for the casePlanModel)
    // - a case execution for the stage
    // - a case execution for the humanTask
    List<CaseExecution> caseExecutions = caseService.createCaseExecutionQuery().caseInstanceId(caseInstance.getId()).list();
    assertEquals(3, caseExecutions.size());
    CaseExecution casePlanModelExecution = caseService.createCaseExecutionQuery().activityId("CasePlanModel_1").singleResult();
    assertNotNull(casePlanModelExecution);
    CaseExecution stageExecution = caseService.createCaseExecutionQuery().activityId("PI_Stage_1").singleResult();
    assertNotNull(stageExecution);
    CaseExecution humanTaskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_6").singleResult();
    assertNotNull(humanTaskExecution);
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToVariableInstanceOnCreateCaseInstance.

public void testPropagateTenantIdToVariableInstanceOnCreateCaseInstance() {
    deploymentForTenant(TENANT_ID, CMMN_FILE);
    VariableMap variables = Variables.putValue("var", "test");
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
    caseService.createCaseInstanceById(caseDefinition.getId(), variables);
    VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();
    assertThat(variableInstance, is(notNullValue()));
    // inherit the tenant id from case instance
    assertThat(variableInstance.getTenantId(), is(TENANT_ID));
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance)

Example 8 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class MultiTenancyExecutionPropagationTest method createCaseInstance.

protected void createCaseInstance() {
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
    caseService.createCaseInstanceById(caseDefinition.getId());
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition)

Example 9 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class MultiTenancyRepositoryServiceTest method getPreviousCaseDefinitionWithTenantId.

@Test
public void getPreviousCaseDefinitionWithTenantId() {
    testRule.deployForTenant(TENANT_ONE, CMMN);
    testRule.deployForTenant(TENANT_ONE, CMMN);
    testRule.deployForTenant(TENANT_ONE, CMMN);
    testRule.deployForTenant(TENANT_TWO, CMMN);
    testRule.deployForTenant(TENANT_TWO, CMMN);
    List<CaseDefinition> latestCaseDefinitions = repositoryService.createCaseDefinitionQuery().latestVersion().orderByTenantId().asc().list();
    CaseDefinitionEntity previousDefinitionTenantOne = getPreviousDefinition((CaseDefinitionEntity) latestCaseDefinitions.get(0));
    CaseDefinitionEntity previousDefinitionTenantTwo = getPreviousDefinition((CaseDefinitionEntity) latestCaseDefinitions.get(1));
    assertThat(previousDefinitionTenantOne.getVersion(), is(2));
    assertThat(previousDefinitionTenantOne.getTenantId(), is(TENANT_ONE));
    assertThat(previousDefinitionTenantTwo.getVersion(), is(1));
    assertThat(previousDefinitionTenantTwo.getTenantId(), is(TENANT_TWO));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) Test(org.junit.Test)

Example 10 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class MultiTenancyCaseDefinitionCmdsTenantCheckTest method getCaseDefinitionDisabledTenantCheck.

@Test
public void getCaseDefinitionDisabledTenantCheck() {
    processEngineConfiguration.setTenantCheckEnabled(false);
    identityService.setAuthentication("user", null, null);
    CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinitionId);
    assertThat(definition.getTenantId(), is(TENANT_ONE));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Test(org.junit.Test)

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