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));
}
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));
}
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());
}
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);
}
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."));
}
}
Aggregations