Search in sources :

Example 96 with ProcessInstance

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()));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 97 with ProcessInstance

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));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 98 with ProcessInstance

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));
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 99 with ProcessInstance

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()));
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 100 with ProcessInstance

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());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

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