Search in sources :

Example 36 with CaseDefinition

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

the class TenantIdProviderTest method providerCalledWithSuperCaseInstance.

@Test
public void providerCalledWithSuperCaseInstance() {
    ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
    TestTenantIdProvider.delegate = tenantIdProvider;
    testRule.deploy(CMMN_SUBPROCESS_FILE, CMMN_FILE_WITH_MANUAL_ACTIVATION);
    CaseDefinition superCaseDefinition = engineRule.getRepositoryService().createCaseDefinitionQuery().caseDefinitionKey(CASE_DEFINITION_KEY).singleResult();
    // if a case instance is created
    engineRule.getCaseService().withCaseDefinitionByKey(CASE_DEFINITION_KEY).create();
    startCaseTask();
    // then the tenant id provider is passed in the case definition
    DelegateCaseExecution superCaseExecution = tenantIdProvider.caseParameters.get(1).getSuperCaseExecution();
    assertThat(superCaseExecution, is(notNullValue()));
    assertThat(superCaseExecution.getCaseDefinitionId(), is(superCaseDefinition.getId()));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) DelegateCaseExecution(org.camunda.bpm.engine.delegate.DelegateCaseExecution) Test(org.junit.Test)

Example 37 with CaseDefinition

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

the class TenantIdProviderTest method providerCalledWithCaseDefinition.

@Test
public void providerCalledWithCaseDefinition() {
    ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
    TestTenantIdProvider.delegate = tenantIdProvider;
    testRule.deploy(CMMN_FILE_WITH_MANUAL_ACTIVATION);
    CaseDefinition deployedCaseDefinition = engineRule.getRepositoryService().createCaseDefinitionQuery().singleResult();
    // if a case instance is created
    engineRule.getCaseService().withCaseDefinitionByKey(CASE_DEFINITION_KEY).create();
    // then the tenant id provider is passed in the case definition
    CaseDefinition passedCaseDefinition = tenantIdProvider.caseParameters.get(0).getCaseDefinition();
    assertThat(passedCaseDefinition, is(notNullValue()));
    assertThat(passedCaseDefinition.getId(), is(deployedCaseDefinition.getId()));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Test(org.junit.Test)

Example 38 with CaseDefinition

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

the class MultiTenancyCreateCaseInstanceTest method testFailToCreateCaseInstanceByIdWithTenantId.

public void testFailToCreateCaseInstanceByIdWithTenantId() {
    deploymentForTenant(TENANT_ONE, CMMN_FILE);
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
    try {
        caseService.withCaseDefinition(caseDefinition.getId()).caseDefinitionTenantId(TENANT_ONE).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 39 with CaseDefinition

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

the class MultiTenancyCreateCaseInstanceTest method testCreateCaseInstanceByIdAuthenticatedTenant.

public void testCreateCaseInstanceByIdAuthenticatedTenant() {
    deploymentForTenant(TENANT_ONE, CMMN_FILE);
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    caseService.withCaseDefinition(caseDefinition.getId()).create();
    CaseInstanceQuery query = caseService.createCaseInstanceQuery();
    assertThat(query.count(), is(1L));
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery)

Example 40 with CaseDefinition

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

the class MultiTenancyCreateCaseInstanceTest method testFailToCreateCaseInstanceByIdNoAuthenticatedTenants.

public void testFailToCreateCaseInstanceByIdNoAuthenticatedTenants() {
    deploymentForTenant(TENANT_ONE, CMMN_FILE);
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
    identityService.setAuthentication("user", null, null);
    try {
        caseService.withCaseDefinition(caseDefinition.getId()).create();
        fail("expected exception");
    } catch (ProcessEngineException e) {
        assertThat(e.getMessage(), containsString("Cannot create an instance of the case definition"));
    }
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

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