Search in sources :

Example 61 with ProcessInstanceQuery

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

the class RuntimeServiceAsyncOperationsTest method testDeleteProcessInstancesAsyncWithQueryOnly.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testDeleteProcessInstancesAsyncWithQueryOnly() throws Exception {
    // given
    List<String> processIds = startTestProcesses(2);
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(new HashSet<String>(processIds));
    // when
    Batch batch = runtimeService.deleteProcessInstancesAsync(processInstanceQuery, TESTING_INSTANCE_DELETE);
    executeSeedJob(batch);
    executeBatchJobs(batch);
    // then
    assertHistoricTaskDeletionPresent(processIds, TESTING_INSTANCE_DELETE, testRule);
    assertHistoricBatchExists(testRule);
    assertProcessInstancesAreDeleted();
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) AbstractAsyncOperationsTest(org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 62 with ProcessInstanceQuery

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

the class RuntimeServiceAsyncOperationsTest method testDeleteProcessInstancesAsyncWithQueryWithoutDeleteReason.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testDeleteProcessInstancesAsyncWithQueryWithoutDeleteReason() throws Exception {
    // given
    List<String> processIds = startTestProcesses(2);
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(new HashSet<String>(processIds));
    // when
    Batch batch = runtimeService.deleteProcessInstancesAsync(null, processInstanceQuery, null);
    executeSeedJob(batch);
    executeBatchJobs(batch);
    // then
    assertHistoricTaskDeletionPresent(processIds, "deleted", testRule);
    assertHistoricBatchExists(testRule);
    assertProcessInstancesAreDeleted();
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) AbstractAsyncOperationsTest(org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 63 with ProcessInstanceQuery

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

the class MigrationProcessInstanceTest method testProcessInstanceIdsAndQuery.

@Test
public void testProcessInstanceIdsAndQuery() {
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.getId());
    ProcessInstanceQuery targetProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(targetProcessDefinition.getId());
    assertEquals(0, targetProcessInstanceQuery.count());
    runtimeService.newMigration(migrationPlan).processInstanceIds(Collections.singletonList(processInstance1.getId())).processInstanceQuery(sourceProcessInstanceQuery).execute();
    assertEquals(2, targetProcessInstanceQuery.count());
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 64 with ProcessInstanceQuery

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

the class MigrationProcessInstanceTest method testOverlappingProcessInstanceIdsAndQuery.

@Test
public void testOverlappingProcessInstanceIdsAndQuery() {
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
    ProcessInstanceQuery targetProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(targetProcessDefinition.getId());
    assertEquals(0, targetProcessInstanceQuery.count());
    runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance1.getId(), processInstance2.getId())).processInstanceQuery(sourceProcessInstanceQuery).execute();
    assertEquals(2, targetProcessInstanceQuery.count());
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 65 with ProcessInstanceQuery

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

the class MigrationProcessInstanceTest method testMigrateProcessInstanceQuery.

@Test
public void testMigrateProcessInstanceQuery() {
    int processInstanceCount = 10;
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    for (int i = 0; i < processInstanceCount; i++) {
        runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    }
    ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
    ProcessInstanceQuery targetProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(targetProcessDefinition.getId());
    assertEquals(processInstanceCount, sourceProcessInstanceQuery.count());
    assertEquals(0, targetProcessInstanceQuery.count());
    runtimeService.newMigration(migrationPlan).processInstanceQuery(sourceProcessInstanceQuery).execute();
    assertEquals(0, sourceProcessInstanceQuery.count());
    assertEquals(processInstanceCount, targetProcessInstanceQuery.count());
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Aggregations

ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)201 Test (org.junit.Test)127 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)59 Deployment (org.camunda.bpm.engine.test.Deployment)42 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)34 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)27 HashMap (java.util.HashMap)24 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)19 Batch (org.camunda.bpm.engine.batch.Batch)18 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)17 ArrayList (java.util.ArrayList)16 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)15 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)15 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)14 ExecutionQuery (org.camunda.bpm.engine.runtime.ExecutionQuery)12 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)9 Job (org.camunda.bpm.engine.runtime.Job)9 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)8 AbstractAsyncOperationsTest (org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest)8 Response (com.jayway.restassured.response.Response)7