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();
}
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();
}
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());
}
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());
}
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());
}
Aggregations