use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method providerCalledWithProcessDefinition_SubProcessInstance.
@Test
public void providerCalledWithProcessDefinition_SubProcessInstance() {
ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
TestTenantIdProvider.delegate = tenantIdProvider;
testRule.deploy(Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().done(), Bpmn.createExecutableProcess("superProcess").startEvent().callActivity().calledElement(PROCESS_DEFINITION_KEY).done());
ProcessDefinition deployedProcessDefinition = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
// if a process instance is started
engineRule.getRuntimeService().startProcessInstanceByKey("superProcess");
// then the tenant id provider is passed in the process definition
ProcessDefinition passedProcessDefinition = tenantIdProvider.parameters.get(1).getProcessDefinition();
assertThat(passedProcessDefinition, is(notNullValue()));
assertThat(passedProcessDefinition.getId(), is(deployedProcessDefinition.getId()));
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyHistoricProcessInstanceStateTest method testSuspensionWithTenancy.
@Test
public void testSuspensionWithTenancy() throws Exception {
BpmnModelInstance instance = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().userTask().endEvent().done();
ProcessDefinition processDefinition = processEngineTestRule.deployAndGetDefinition(instance);
ProcessDefinition processDefinition1 = processEngineTestRule.deployForTenantAndGetDefinition(TENANT_ONE, instance);
ProcessDefinition processDefinition2 = processEngineTestRule.deployForTenantAndGetDefinition(TENANT_TWO, instance);
ProcessInstance processInstance = processEngineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId());
ProcessInstance processInstance1 = processEngineRule.getRuntimeService().startProcessInstanceById(processDefinition1.getId());
ProcessInstance processInstance2 = processEngineRule.getRuntimeService().startProcessInstanceById(processDefinition2.getId());
// suspend Tenant one
processEngineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(processDefinition1.getKey()).processDefinitionTenantId(processDefinition1.getTenantId()).suspend();
String[] processInstances = { processInstance1.getId(), processInstance2.getId(), processInstance.getId() };
verifyStates(processInstances, new String[] { HistoricProcessInstance.STATE_SUSPENDED, HistoricProcessInstance.STATE_ACTIVE, HistoricProcessInstance.STATE_ACTIVE });
// suspend without tenant
processEngineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(processDefinition.getKey()).processDefinitionWithoutTenantId().suspend();
verifyStates(processInstances, new String[] { HistoricProcessInstance.STATE_SUSPENDED, HistoricProcessInstance.STATE_ACTIVE, HistoricProcessInstance.STATE_SUSPENDED });
// reactivate without tenant
processEngineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(processDefinition.getKey()).processDefinitionWithoutTenantId().activate();
verifyStates(processInstances, new String[] { HistoricProcessInstance.STATE_SUSPENDED, HistoricProcessInstance.STATE_ACTIVE, HistoricProcessInstance.STATE_ACTIVE });
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessDefinitionSuspensionStateTest method failToSuspendProcessDefinitionByIdNoAuthenticatedTenants.
@Test
public void failToSuspendProcessDefinitionByIdNoAuthenticatedTenants() {
ProcessDefinition processDefinition = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).tenantIdIn(TENANT_ONE).singleResult();
// declare expected exception
thrown.expect(ProcessEngineException.class);
thrown.expectMessage("Cannot update the process definition '" + processDefinition.getId() + "' because it belongs to no authenticated tenant");
engineRule.getIdentityService().setAuthentication("user", null, null);
engineRule.getRepositoryService().updateProcessDefinitionSuspensionState().byProcessDefinitionId(processDefinition.getId()).suspend();
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessInstanceSuspensionStateTest method failToSuspendProcessInstanceByProcessDefinitionIdNoAuthenticatedTenants.
@Test
public void failToSuspendProcessInstanceByProcessDefinitionIdNoAuthenticatedTenants() {
ProcessDefinition processDefinition = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).tenantIdIn(TENANT_ONE).singleResult();
// declare expected exception
thrown.expect(ProcessEngineException.class);
thrown.expectMessage("Cannot update the process definition '" + processDefinition.getId() + "' because it belongs to no authenticated tenant");
engineRule.getIdentityService().setAuthentication("user", null, null);
engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionId(processDefinition.getId()).suspend();
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByLeafActivityId.
@Test
public void testQueryByLeafActivityId() {
// given
ProcessDefinition oneTaskDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition gatewaySubProcessDefinition = testHelper.deployAndGetDefinition(FORK_JOIN_SUB_PROCESS_MODEL);
// when
ProcessInstance oneTaskInstance1 = runtimeService.startProcessInstanceById(oneTaskDefinition.getId());
ProcessInstance oneTaskInstance2 = runtimeService.startProcessInstanceById(oneTaskDefinition.getId());
ProcessInstance gatewaySubProcessInstance1 = runtimeService.startProcessInstanceById(gatewaySubProcessDefinition.getId());
ProcessInstance gatewaySubProcessInstance2 = runtimeService.startProcessInstanceById(gatewaySubProcessDefinition.getId());
Task task = engineRule.getTaskService().createTaskQuery().processInstanceId(gatewaySubProcessInstance2.getId()).taskName("completeMe").singleResult();
engineRule.getTaskService().complete(task.getId());
// then
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("userTask");
assertReturnedProcessInstances(query, oneTaskInstance1, oneTaskInstance2);
query = runtimeService.createProcessInstanceQuery().activityIdIn("userTask1", "userTask2");
assertReturnedProcessInstances(query, gatewaySubProcessInstance1, gatewaySubProcessInstance2);
query = runtimeService.createProcessInstanceQuery().activityIdIn("userTask", "userTask1");
assertReturnedProcessInstances(query, oneTaskInstance1, oneTaskInstance2, gatewaySubProcessInstance1);
query = runtimeService.createProcessInstanceQuery().activityIdIn("userTask", "userTask1", "userTask2");
assertReturnedProcessInstances(query, oneTaskInstance1, oneTaskInstance2, gatewaySubProcessInstance1, gatewaySubProcessInstance2);
query = runtimeService.createProcessInstanceQuery().activityIdIn("join");
assertReturnedProcessInstances(query, gatewaySubProcessInstance2);
}
Aggregations