Search in sources :

Example 21 with RuntimeService

use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.

the class BatchMigrationTest method testBatchCreationWithOverlappingProcessInstanceIdsAndQuery.

@Test
public void testBatchCreationWithOverlappingProcessInstanceIdsAndQuery() {
    RuntimeService runtimeService = engineRule.getRuntimeService();
    int processInstanceCount = 15;
    ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    List<String> processInstanceIds = new ArrayList<String>();
    for (int i = 0; i < processInstanceCount; i++) {
        processInstanceIds.add(runtimeService.startProcessInstanceById(sourceProcessDefinition.getId()).getId());
    }
    MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
    assertEquals(processInstanceCount, sourceProcessInstanceQuery.count());
    // when
    Batch batch = runtimeService.newMigration(migrationPlan).processInstanceIds(processInstanceIds).processInstanceQuery(sourceProcessInstanceQuery).executeAsync();
    // then a batch is created
    assertBatchCreated(batch, processInstanceCount);
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) RuntimeService(org.camunda.bpm.engine.RuntimeService) Batch(org.camunda.bpm.engine.batch.Batch) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ArrayList(java.util.ArrayList) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 22 with RuntimeService

use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.

the class ProcessEngineRuleParameterizedJunit4Test method ruleUsageExample.

/**
 * Unnamed @Deployment annotations don't work with parameterized Unit tests
 */
@Ignore
@Test
@Deployment
public void ruleUsageExample() {
    RuntimeService runtimeService = engineRule.getRuntimeService();
    runtimeService.startProcessInstanceByKey("ruleUsage");
    TaskService taskService = engineRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("My Task", task.getName());
    taskService.complete(task.getId());
    assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
Also used : Task(org.camunda.bpm.engine.task.Task) RuntimeService(org.camunda.bpm.engine.RuntimeService) TaskService(org.camunda.bpm.engine.TaskService) Ignore(org.junit.Ignore) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 23 with RuntimeService

use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.

the class SequenceFlowListener method execute.

@Override
public void execute(DelegateExecution execution) throws Exception {
    ProcessEngineServices processEngineServices = execution.getProcessEngineServices();
    RuntimeService runtimeService = processEngineServices.getRuntimeService();
    runtimeService.getActivityInstance(execution.getProcessInstanceId());
}
Also used : ProcessEngineServices(org.camunda.bpm.engine.ProcessEngineServices) RuntimeService(org.camunda.bpm.engine.RuntimeService)

Example 24 with RuntimeService

use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.

the class RuntimeServiceDelegate method execute.

public void execute(DelegateExecution execution) throws Exception {
    RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
    ObjectValue jsonSerializeable = Variables.objectValue(createJsonSerializable()).serializationDataFormat(SerializationDataFormats.JSON).create();
    // this should be executed in the context of the current process application
    runtimeService.setVariable(execution.getProcessInstanceId(), VARIABLE_NAME, jsonSerializeable);
}
Also used : ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) RuntimeService(org.camunda.bpm.engine.RuntimeService)

Example 25 with RuntimeService

use of org.camunda.bpm.engine.RuntimeService in project camunda-bpm-platform by camunda.

the class MockedProcessEngineProvider method mockServices.

private void mockServices(ProcessEngine engine) {
    RepositoryService repoService = mock(RepositoryService.class);
    IdentityService identityService = mock(IdentityService.class);
    TaskService taskService = mock(TaskService.class);
    RuntimeService runtimeService = mock(RuntimeService.class);
    FormService formService = mock(FormService.class);
    HistoryService historyService = mock(HistoryService.class);
    ManagementService managementService = mock(ManagementService.class);
    CaseService caseService = mock(CaseService.class);
    FilterService filterService = mock(FilterService.class);
    ExternalTaskService externalTaskService = mock(ExternalTaskService.class);
    when(engine.getRepositoryService()).thenReturn(repoService);
    when(engine.getIdentityService()).thenReturn(identityService);
    when(engine.getTaskService()).thenReturn(taskService);
    when(engine.getRuntimeService()).thenReturn(runtimeService);
    when(engine.getFormService()).thenReturn(formService);
    when(engine.getHistoryService()).thenReturn(historyService);
    when(engine.getManagementService()).thenReturn(managementService);
    when(engine.getCaseService()).thenReturn(caseService);
    when(engine.getFilterService()).thenReturn(filterService);
    when(engine.getExternalTaskService()).thenReturn(externalTaskService);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) ManagementService(org.camunda.bpm.engine.ManagementService) RuntimeService(org.camunda.bpm.engine.RuntimeService) TaskService(org.camunda.bpm.engine.TaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) FormService(org.camunda.bpm.engine.FormService) FilterService(org.camunda.bpm.engine.FilterService) HistoryService(org.camunda.bpm.engine.HistoryService) CaseService(org.camunda.bpm.engine.CaseService) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Aggregations

RuntimeService (org.camunda.bpm.engine.RuntimeService)51 Test (org.junit.Test)12 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)10 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)9 IdentityService (org.camunda.bpm.engine.IdentityService)6 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)6 TaskService (org.camunda.bpm.engine.TaskService)5 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)5 Batch (org.camunda.bpm.engine.batch.Batch)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)4 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)4 Task (org.camunda.bpm.engine.task.Task)4 ArrayList (java.util.ArrayList)3 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)3 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 ProcessEngineServices (org.camunda.bpm.engine.ProcessEngineServices)3 RepositoryService (org.camunda.bpm.engine.RepositoryService)3 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)3