use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessInstantiationTest method testFailToRestartProcessInstanceAsyncWithOtherTenantIdByHistoricProcessInstanceQuery.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testFailToRestartProcessInstanceAsyncWithOtherTenantIdByHistoricProcessInstanceQuery() {
// given
ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId());
identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO));
try {
// when
runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()).startBeforeActivity("userTask").historicProcessInstanceQuery(query).executeAsync();
} catch (ProcessEngineException e) {
assertThat(e.getMessage(), containsString("processInstanceIds is empty"));
}
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessInstantiationTest method testFailToRestartProcessInstanceSyncWithOtherTenantIdByHistoricProcessInstanceQuery.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testFailToRestartProcessInstanceSyncWithOtherTenantIdByHistoricProcessInstanceQuery() {
// given
ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId());
identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO));
try {
// when
runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()).startBeforeActivity("userTask").historicProcessInstanceQuery(query).execute();
fail("expected exception");
} catch (BadUserRequestException e) {
// then
assertThat(e.getMessage(), containsString("processInstanceIds is empty"));
}
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class MultiTenancyMigrationTest method canMigrateInstanceWithTenantIdToDefinitionWithoutTenantId.
@Test
public void canMigrateInstanceWithTenantIdToDefinitionWithoutTenantId() {
// given
ProcessDefinition sourceDefinition = testHelper.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId());
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapEqualActivities().build();
// when
engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).execute();
// then
assertMigratedTo(processInstance, targetDefinition);
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method tenantIdInheritedFromSuperProcessInstance.
@Test
public void tenantIdInheritedFromSuperProcessInstance() {
String tenantId = TENANT_ID;
SetValueOnRootProcessInstanceTenantIdProvider tenantIdProvider = new SetValueOnRootProcessInstanceTenantIdProvider(tenantId);
TestTenantIdProvider.delegate = tenantIdProvider;
testRule.deploy(Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().userTask().done(), Bpmn.createExecutableProcess("superProcess").startEvent().callActivity().calledElement(PROCESS_DEFINITION_KEY).done());
// if a process instance is started
engineRule.getRuntimeService().startProcessInstanceByKey("superProcess");
// then the tenant id is inherited to the sub process instance even tough it is not set by the provider
ProcessInstance processInstance = engineRule.getRuntimeService().createProcessInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
assertThat(processInstance.getTenantId(), is(tenantId));
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method providerCalledForStartedProcessInstanceByStartFormWithoutTenantId.
@Test
public void providerCalledForStartedProcessInstanceByStartFormWithoutTenantId() {
ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
TestTenantIdProvider.delegate = tenantIdProvider;
// given a deployment without a tenant id
testRule.deploy(Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().done(), "org/camunda/bpm/engine/test/api/form/util/request.form");
// when a process instance is started with a start form
String processDefinitionId = engineRule.getRepositoryService().createProcessDefinitionQuery().singleResult().getId();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("employeeName", "demo");
ProcessInstance procInstance = engineRule.getFormService().submitStartForm(processDefinitionId, properties);
assertNotNull(procInstance);
// then the tenant id provider is invoked
assertThat(tenantIdProvider.parameters.size(), is(1));
}
Aggregations