use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class HistoryServiceAsyncOperationsTest method testDeleteHistoryProcessInstancesAsyncWithQuery.
@Test
public void testDeleteHistoryProcessInstancesAsyncWithQuery() throws Exception {
// given
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processInstanceIds(new HashSet<String>(historicProcessInstances));
Batch batch = historyService.deleteHistoricProcessInstancesAsync(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.batch.Batch in project camunda-bpm-platform by camunda.
the class HistoryServiceAsyncOperationsTest method cleanBatch.
@After
public void cleanBatch() {
Batch batch = managementService.createBatchQuery().singleResult();
if (batch != null) {
managementService.deleteBatch(batch.getId(), true);
}
HistoricBatch historicBatch = historyService.createHistoricBatchQuery().singleResult();
if (historicBatch != null) {
historyService.deleteHistoricBatch(historicBatch.getId());
}
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method testCancelWithoutFlag2.
@Test
public void testCancelWithoutFlag2() {
// given
this.instance = Bpmn.createExecutableProcess("process1").startEvent("start").serviceTask("ser").camundaExpression("${true}").userTask("user").endEvent("end").done();
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
List<String> processInstanceIds = helper.startInstances("process1", 1);
// when
Batch batch = runtimeService.createModification(processDefinition.getId()).startBeforeActivity("ser").cancelAllForActivity("user", false).processInstanceIds(processInstanceIds).executeAsync();
helper.executeSeedJob(batch);
helper.executeJobs(batch);
// then
assertEquals(0, runtimeService.createExecutionQuery().list().size());
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method testCancelWithFlagForManyInstances.
@Test
public void testCancelWithFlagForManyInstances() {
// given
this.instance = Bpmn.createExecutableProcess("process1").startEvent("start").serviceTask("ser").camundaExpression("${true}").userTask("user").endEvent("end").done();
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
List<String> processInstanceIds = helper.startInstances("process1", 10);
// when
Batch batch = runtimeService.createModification(processDefinition.getId()).startBeforeActivity("ser").cancelAllForActivity("user", true).processInstanceIds(processInstanceIds).executeAsync();
helper.executeSeedJob(batch);
helper.executeJobs(batch);
// then
for (String processInstanceId : processInstanceIds) {
Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstanceId).singleResult();
assertNotNull(execution);
assertEquals("user", ((ExecutionEntity) execution).getActivityId());
}
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method executeModificationJobsForStartTransitionAndCancelAll.
@Test
public void executeModificationJobsForStartTransitionAndCancelAll() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0);
List<String> instances = helper.startInstances("process1", 10);
Batch batch = runtimeService.createModification(processDefinition.getId()).startTransition("seq").cancelAllForActivity("user1").processInstanceIds(instances).executeAsync();
helper.executeSeedJob(batch);
List<Job> modificationJobs = helper.getExecutionJobs(batch);
// when
for (Job modificationJob : modificationJobs) {
helper.executeJob(modificationJob);
}
// then all process instances where modified
for (String processInstanceId : helper.currentProcessInstances) {
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).activity("user2").done());
}
// and the no modification jobs exist
assertEquals(0, helper.getExecutionJobs(batch).size());
// but a monitor job exists
assertNotNull(helper.getMonitorJob(batch));
}
Aggregations