use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method setNullTenantId.
@Test
public void setNullTenantId() {
String tenantId = null;
StaticTenantIdTestProvider tenantIdProvider = new StaticTenantIdTestProvider(tenantId);
TestTenantIdProvider.delegate = tenantIdProvider;
testRule.deploy(Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().userTask().done());
// if a process instance is started
engineRule.getRuntimeService().startProcessInstanceByKey(PROCESS_DEFINITION_KEY);
// then the tenant id provider can set the tenant id to null
ProcessInstance processInstance = engineRule.getRuntimeService().createProcessInstanceQuery().singleResult();
assertThat(processInstance.getTenantId(), is(nullValue()));
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method setsTenantId.
@Test
public void setsTenantId() {
String tenantId = TENANT_ID;
StaticTenantIdTestProvider tenantIdProvider = new StaticTenantIdTestProvider(tenantId);
TestTenantIdProvider.delegate = tenantIdProvider;
testRule.deploy(Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().userTask().done());
// if a process instance is started
engineRule.getRuntimeService().startProcessInstanceByKey(PROCESS_DEFINITION_KEY);
// then the tenant id provider can set the tenant id to a value
ProcessInstance processInstance = engineRule.getRuntimeService().createProcessInstanceQuery().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 providerNotCalledForStartedProcessInstanceByStartFormWithTenantId.
@Test
public void providerNotCalledForStartedProcessInstanceByStartFormWithTenantId() {
ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
TestTenantIdProvider.delegate = tenantIdProvider;
// given a deployment with a tenant id
testRule.deployForTenant(TENANT_ID, 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 not invoked
assertThat(tenantIdProvider.parameters.size(), is(0));
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method setsTenantId_SubProcessInstance.
@Test
public void setsTenantId_SubProcessInstance() {
String tenantId = TENANT_ID;
SetValueOnSubProcessInstanceTenantIdProvider tenantIdProvider = new SetValueOnSubProcessInstanceTenantIdProvider(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 provider can set the tenant id to a value
ProcessInstance subProcessInstance = engineRule.getRuntimeService().createProcessInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
assertThat(subProcessInstance.getTenantId(), is(tenantId));
// and the super process instance is not assigned a tenant id
ProcessInstance superProcessInstance = engineRule.getRuntimeService().createProcessInstanceQuery().processDefinitionKey("superProcess").singleResult();
assertThat(superProcessInstance.getTenantId(), is(nullValue()));
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class MultiTenancyFormServiceCmdsTenantCheckTest method testGetStartFormWithNoAuthenticatedTenant.
@Test
public void testGetStartFormWithNoAuthenticatedTenant() {
testRule.deployForTenant(TENANT_ONE, "org/camunda/bpm/engine/test/api/authorization/formKeyProcess.bpmn20.xml");
ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY);
identityService.setAuthentication("aUserId", null);
// then
thrown.expect(ProcessEngineException.class);
thrown.expectMessage("Cannot get the process definition '" + instance.getProcessDefinitionId() + "' because it belongs to no authenticated tenant.");
// when
formService.getStartFormData(instance.getProcessDefinitionId());
}
Aggregations