Search in sources :

Example 86 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class MultiTenancyStatisticsQueryTest method testQueryNoAuthenticatedTenantForActivityStatistics.

public void testQueryNoAuthenticatedTenantForActivityStatistics() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("SingleTaskProcess");
    identityService.setAuthentication("user", null);
    ActivityStatisticsQuery query = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId());
    assertThat(query.count(), is(0L));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ActivityStatisticsQuery(org.camunda.bpm.engine.management.ActivityStatisticsQuery)

Example 87 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToProcessInstance.

public void testPropagateTenantIdToProcessInstance() {
    deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().userTask().endEvent().done());
    startProcessInstance(PROCESS_DEFINITION_KEY);
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
    assertThat(processInstance, is(notNullValue()));
    // inherit the tenant id from process definition
    assertThat(processInstance.getTenantId(), is(TENANT_ID));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance)

Example 88 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class MultiTenancyJobExecutorTest method dontSetAuthenticatedTenantForJobWithoutTenant.

@Test
public void dontSetAuthenticatedTenantForJobWithoutTenant() {
    testRule.deploy(Bpmn.createExecutableProcess("process").startEvent().serviceTask().camundaAsyncBefore().camundaClass(AssertingJavaDelegate.class.getName()).endEvent().done());
    ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("process");
    AssertingJavaDelegate.addAsserts(hasNoAuthenticatedTenantId());
    testRule.waitForJobExecutorToProcessAllJobs();
    testRule.assertProcessEnded(processInstance.getId());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 89 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class MultiTenancyProcessInstantiationTest method testRestartProcessInstanceAsyncWithTenantIdByHistoricProcessInstanceQuery.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testRestartProcessInstanceAsyncWithTenantIdByHistoricProcessInstanceQuery() {
    // given
    ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId());
    identityService.setAuthentication("user", null, Collections.singletonList(TENANT_ONE));
    // when
    Batch batch = runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()).startBeforeActivity("userTask").historicProcessInstanceQuery(query).executeAsync();
    batchHelper.completeBatch(batch);
    // then
    ProcessInstance restartedInstance = runtimeService.createProcessInstanceQuery().active().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
    assertNotNull(restartedInstance);
    assertEquals(restartedInstance.getTenantId(), TENANT_ONE);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) Batch(org.camunda.bpm.engine.batch.Batch) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 90 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class MultiTenancyProcessInstantiationTest method testFailToRestartProcessInstanceAsyncWithOtherTenantId.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testFailToRestartProcessInstanceAsyncWithOtherTenantId() {
    // given
    ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
    identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO));
    try {
        // when
        runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()).startBeforeActivity("userTask").processInstanceIds(processInstance.getId()).executeAsync();
    } catch (ProcessEngineException e) {
        assertThat(e.getMessage(), containsString("Cannot restart process instances of process definition '" + processInstance.getProcessDefinitionId() + "' because it belongs to no authenticated tenant."));
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Aggregations

ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)2392 Deployment (org.camunda.bpm.engine.test.Deployment)1325 Test (org.junit.Test)1168 Task (org.camunda.bpm.engine.task.Task)660 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)415 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)372 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)272 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)258 HashMap (java.util.HashMap)235 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)230 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)203 Job (org.camunda.bpm.engine.runtime.Job)189 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)184 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)149 Execution (org.camunda.bpm.engine.runtime.Execution)144 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)130 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)129 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)122 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)86 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)84