Search in sources :

Example 26 with ProcessDefinition

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

the class MultiTenancyProcessDefinitionQueryTest method testQueryByLatestNoTenantIdSet.

public void testQueryByLatestNoTenantIdSet() {
    // deploy a second version for tenant one
    deploymentForTenant(TENANT_ONE, emptyProcess);
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).latestVersion();
    // one definition for each tenant
    assertThat(query.count(), is(3L));
    Map<String, ProcessDefinition> processDefinitionsForTenant = getProcessDefinitionsForTenant(query.list());
    assertThat(processDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2));
    assertThat(processDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1));
    assertThat(processDefinitionsForTenant.get(null).getVersion(), is(1));
}
Also used : ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition)

Example 27 with ProcessDefinition

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

the class MultiTenancyHistoricIdentityLinkLogQueryTest method addAndRemoveHistoricIdentityLinksForProcessDefinitionWithTenantId.

@Test
public void addAndRemoveHistoricIdentityLinksForProcessDefinitionWithTenantId() throws Exception {
    String resourceName = "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml";
    testRule.deployForTenant(TENANT_1, resourceName);
    testRule.deployForTenant(TENANT_2, resourceName);
    ProcessDefinition processDefinition1 = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).list().get(0);
    ProcessDefinition processDefinition2 = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).list().get(1);
    assertNotNull(processDefinition1);
    assertNotNull(processDefinition2);
    testTenantsByProcessDefinition(processDefinition1.getId());
    testTenantsByProcessDefinition(processDefinition2.getId());
    List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicIdentityLinks.size(), 8);
    // Query test
    HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.tenantIdIn(TENANT_1).count(), 4);
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.tenantIdIn(TENANT_2).count(), 4);
}
Also used : HistoricIdentityLinkLog(org.camunda.bpm.engine.history.HistoricIdentityLinkLog) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricIdentityLinkLogQuery(org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery) Test(org.junit.Test)

Example 28 with ProcessDefinition

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

the class MultiTenancyProcessInstantiationTest method testFailToStartProcessInstanceAtActivityByIdWithoutTenantId.

public void testFailToStartProcessInstanceAtActivityByIdWithoutTenantId() {
    deployment(PROCESS);
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    try {
        runtimeService.createProcessInstanceById(processDefinition.getId()).processDefinitionWithoutTenantId().startBeforeActivity("userTask").execute();
        fail("expected exception");
    } catch (BadUserRequestException e) {
        assertThat(e.getMessage(), containsString("Cannot specify a tenant-id"));
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 29 with ProcessDefinition

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

the class MultiTenancyProcessInstantiationTest method testStartProcessInstanceByIdAuthenticatedTenant.

public void testStartProcessInstanceByIdAuthenticatedTenant() {
    deploymentForTenant(TENANT_ONE, PROCESS);
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    runtimeService.createProcessInstanceById(processDefinition.getId()).execute();
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
    assertThat(query.count(), is(1L));
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition)

Example 30 with ProcessDefinition

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

the class MultiTenancyProcessInstantiationTest method testFailToStartProcessInstanceAtActivityByIdAndTenantId.

public void testFailToStartProcessInstanceAtActivityByIdAndTenantId() {
    deploymentForTenant(TENANT_ONE, PROCESS);
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    try {
        runtimeService.createProcessInstanceById(processDefinition.getId()).processDefinitionTenantId(TENANT_ONE).startBeforeActivity("userTask").execute();
        fail("expected exception");
    } catch (BadUserRequestException e) {
        assertThat(e.getMessage(), containsString("Cannot specify a tenant-id"));
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Aggregations

ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1093 Test (org.junit.Test)761 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)474 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)415 Deployment (org.camunda.bpm.engine.test.Deployment)230 Job (org.camunda.bpm.engine.runtime.Job)148 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)119 Batch (org.camunda.bpm.engine.batch.Batch)95 Task (org.camunda.bpm.engine.task.Task)87 HashMap (java.util.HashMap)77 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)64 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)55 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)54 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)47 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)41 MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)40 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)39 Date (java.util.Date)38 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)35