use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoryServiceAsyncOperationsTest method testDeleteHistoryProcessInstancesAsyncWithNonExistingIDAsQuery.
@Test
public void testDeleteHistoryProcessInstancesAsyncWithNonExistingIDAsQuery() throws Exception {
// given
ArrayList<String> processInstanceIds = new ArrayList<String>();
processInstanceIds.add(historicProcessInstances.get(0));
processInstanceIds.add("aFakeId");
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processInstanceIds(new HashSet(processInstanceIds));
// when
Batch batch = historyService.deleteHistoricProcessInstancesAsync(query, TEST_REASON);
executeSeedJob(batch);
executeBatchJobs(batch);
// then
assertHistoricBatchExists(testRule);
}
use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoryServiceAsyncOperationsTest method testDeleteHistoryProcessInstancesAsyncWithQueryAndList.
@Test
public void testDeleteHistoryProcessInstancesAsyncWithQueryAndList() throws Exception {
// given
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processInstanceId(historicProcessInstances.get(0));
Batch batch = historyService.deleteHistoricProcessInstancesAsync(historicProcessInstances.subList(1, historicProcessInstances.size()), query, TEST_REASON);
executeSeedJob(batch);
// when
List<Exception> exceptions = executeBatchJobs(batch);
// then
assertThat(exceptions.size(), is(0));
assertNoHistoryForTasks();
assertHistoricBatchExists(testRule);
assertAllHistoricProcessInstancesAreDeleted();
}
use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoryServiceAsyncOperationsTest method testDeleteHistoryProcessInstancesAsyncWithEmptyQuery.
@Test
public void testDeleteHistoryProcessInstancesAsyncWithEmptyQuery() throws Exception {
// expect
thrown.expect(ProcessEngineException.class);
// given
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().unfinished();
// when
historyService.deleteHistoricProcessInstancesAsync(query, TEST_REASON);
}
use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method testBatchCreationWithOverlappingProcessInstanceIdsAndQuery.
@Test
public void testBatchCreationWithOverlappingProcessInstanceIdsAndQuery() {
// given
int processInstanceCount = 2;
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
// when
HistoricProcessInstanceQuery processInstanceQuery = engineRule.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionId(processDefinition.getId());
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startTransition("flow1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).historicProcessInstanceQuery(processInstanceQuery).executeAsync();
helper.completeBatch(batch);
// then
List<ProcessInstance> restartedProcessInstances = engineRule.getRuntimeService().createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).list();
assertEquals(restartedProcessInstances.size(), processInstanceCount);
}
use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method shouldRestartProcessInstanceUsingHistoricProcessInstanceQuery.
@Test
public void shouldRestartProcessInstanceUsingHistoricProcessInstanceQuery() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
Task task1 = taskService.createTaskQuery().processInstanceId(processInstance1.getId()).active().singleResult();
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");
Task task2 = taskService.createTaskQuery().processInstanceId(processInstance2.getId()).active().singleResult();
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
// when
HistoricProcessInstanceQuery historicProcessInstanceQuery = engineRule.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionId(processDefinition.getId());
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").historicProcessInstanceQuery(historicProcessInstanceQuery).executeAsync();
helper.completeBatch(batch);
// then
List<ProcessInstance> restartedProcessInstances = runtimeService.createProcessInstanceQuery().active().list();
ProcessInstance restartedProcessInstance = restartedProcessInstances.get(0);
Task restartedTask = taskService.createTaskQuery().processInstanceId(restartedProcessInstance.getId()).active().singleResult();
Assert.assertEquals(task1.getTaskDefinitionKey(), restartedTask.getTaskDefinitionKey());
restartedProcessInstance = restartedProcessInstances.get(1);
restartedTask = taskService.createTaskQuery().processInstanceId(restartedProcessInstance.getId()).active().singleResult();
Assert.assertEquals(task2.getTaskDefinitionKey(), restartedTask.getTaskDefinitionKey());
}
Aggregations