use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class RuntimeServiceAsyncOperationsTest method cleanBatch.
@After
public void cleanBatch() {
List<Batch> batches = managementService.createBatchQuery().list();
if (batches.size() > 0) {
for (Batch batch : batches) 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 RuntimeServiceAsyncOperationsTest method testDeleteProcessInstancesAsyncWithSkipCustomListeners.
@Test
public void testDeleteProcessInstancesAsyncWithSkipCustomListeners() {
// given
IncrementCounterListener.counter = 0;
BpmnModelInstance instance = ProcessModels.newModel(ONE_TASK_PROCESS).startEvent().userTask().camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, IncrementCounterListener.class.getName()).endEvent().done();
testRule.deploy(instance);
List<String> processIds = startTestProcesses(1);
// when
Batch batch = runtimeService.deleteProcessInstancesAsync(processIds, null, TESTING_INSTANCE_DELETE, true);
executeSeedJob(batch);
executeBatchJobs(batch);
// then
assertThat(IncrementCounterListener.counter, is(0));
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class RuntimeServiceAsyncOperationsTest method testDeleteProcessInstancesAsyncWithQuery.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testDeleteProcessInstancesAsyncWithQuery() throws Exception {
// given
List<String> processIds = startTestProcesses(2);
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(new HashSet<String>(processIds));
// when
Batch batch = runtimeService.deleteProcessInstancesAsync(null, processInstanceQuery, TESTING_INSTANCE_DELETE);
executeSeedJob(batch);
executeBatchJobs(batch);
// then
assertHistoricTaskDeletionPresent(processIds, TESTING_INSTANCE_DELETE, testRule);
assertHistoricBatchExists(testRule);
assertProcessInstancesAreDeleted();
}
use of org.camunda.bpm.engine.batch.Batch 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.batch.Batch in project camunda-bpm-platform by camunda.
the class RuntimeServiceAsyncOperationsTest method testDeleteProcessInstancesAsyncWithListInDifferentDeployments.
@Test
public void testDeleteProcessInstancesAsyncWithListInDifferentDeployments() {
// given
ProcessDefinition sourceDefinition1 = testRule.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "ONE_TASK_PROCESS"));
ProcessDefinition sourceDefinition2 = testRule.deployAndGetDefinition(modify(ProcessModels.TWO_TASKS_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "TWO_TASKS_PROCESS"));
List<String> processInstanceIds = createProcessInstances(sourceDefinition1, sourceDefinition2, 15, 10);
final String firstDeploymentId = sourceDefinition1.getDeploymentId();
final String secondDeploymentId = sourceDefinition2.getDeploymentId();
List<String> processInstanceIdsFromFirstDeployment = getProcessInstanceIdsByDeploymentId(firstDeploymentId);
List<String> processInstanceIdsFromSecondDeployment = getProcessInstanceIdsByDeploymentId(secondDeploymentId);
engineRule.getProcessEngineConfiguration().setInvocationsPerBatchJob(2);
engineRule.getProcessEngineConfiguration().setBatchJobsPerSeed(3);
// when
Batch batch = runtimeService.deleteProcessInstancesAsync(processInstanceIds, null, "test_reason");
String seedJobDefinitionId = batch.getSeedJobDefinitionId();
// seed jobs
int expectedSeedJobsCount = 5;
createAndExecuteSeedJobs(seedJobDefinitionId, expectedSeedJobsCount);
// then
List<Job> jobs = managementService.createJobQuery().jobDefinitionId(batch.getBatchJobDefinitionId()).list();
// execute jobs related to the first deployment
List<String> jobIdsForFirstDeployment = getJobIdsByDeployment(jobs, firstDeploymentId);
assertNotNull(jobIdsForFirstDeployment);
for (String jobId : jobIdsForFirstDeployment) {
managementService.executeJob(jobId);
}
// the process instances related to the first deployment should be deleted
assertEquals(0, runtimeService.createProcessInstanceQuery().deploymentId(firstDeploymentId).count());
assertHistoricTaskDeletionPresent(processInstanceIdsFromFirstDeployment, "test_reason", testRule);
// and process instances related to the second deployment should not be deleted
assertEquals(processInstanceIdsFromSecondDeployment.size(), runtimeService.createProcessInstanceQuery().deploymentId(secondDeploymentId).count());
assertHistoricTaskDeletionPresent(processInstanceIdsFromSecondDeployment, null, testRule);
// execute jobs related to the second deployment
List<String> jobIdsForSecondDeployment = getJobIdsByDeployment(jobs, secondDeploymentId);
assertNotNull(jobIdsForSecondDeployment);
for (String jobId : jobIdsForSecondDeployment) {
managementService.executeJob(jobId);
}
// all of the process instances should be deleted
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
Aggregations