Search in sources :

Example 36 with ProcessDefinition

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

Example 37 with ProcessDefinition

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 });
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 38 with ProcessDefinition

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

Example 39 with ProcessDefinition

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

Example 40 with ProcessDefinition

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

Aggregations

ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1093 Test (org.junit.Test)761 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)474 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)415 Deployment (org.camunda.bpm.engine.test.Deployment)230 Job (org.camunda.bpm.engine.runtime.Job)148 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)119 Batch (org.camunda.bpm.engine.batch.Batch)95 Task (org.camunda.bpm.engine.task.Task)87 HashMap (java.util.HashMap)77 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)64 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)55 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)54 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)47 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)41 MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)40 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)39 Date (java.util.Date)38 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)35