use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method executeModificationJobsForStartTransition.
@Test
public void executeModificationJobsForStartTransition() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0);
Batch batch = helper.startTransitionAsync("process1", 10, "seq", processDefinition.getId());
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);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).activity("user1").activity("user2").done());
}
// and the no modification jobs exist
assertEquals(0, helper.getExecutionJobs(batch).size());
// but a monitor job exists
assertNotNull(helper.getMonitorJob(batch));
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method testMonitorJobPollingForCompletion.
@Test
public void testMonitorJobPollingForCompletion() {
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
Batch batch = helper.startAfterAsync("process1", 3, "user1", processDefinition.getId());
// when the seed job creates the monitor job
Date createDate = ClockTestUtil.setClockToDateWithoutMilliseconds();
helper.executeSeedJob(batch);
// then the monitor job has a no due date set
Job monitorJob = helper.getMonitorJob(batch);
assertNotNull(monitorJob);
assertNull(monitorJob.getDuedate());
// when the monitor job is executed
helper.executeMonitorJob(batch);
// then the monitor job has a due date of the default batch poll time
monitorJob = helper.getMonitorJob(batch);
Date dueDate = helper.addSeconds(createDate, 30);
assertEquals(dueDate, monitorJob.getDuedate());
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method testSkipListenerInvocationF.
@Test
public void testSkipListenerInvocationF() {
// given
DelegateEvent.clearEvents();
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(modify(instance).activityBuilder("user2").camundaExecutionListenerClass(ExecutionListener.EVENTNAME_START, DelegateExecutionListener.class.getName()).done());
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
Batch batch = runtimeService.createModification(processDefinition.getId()).cancelAllForActivity("user2").processInstanceIds(Arrays.asList(processInstance.getId())).skipCustomListeners().executeAsync();
helper.executeSeedJob(batch);
// when
helper.executeJobs(batch);
// then
assertEquals(0, DelegateEvent.getEvents().size());
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method executeModificationJobsForStartBeforeAndCancelAll.
@Test
public void executeModificationJobsForStartBeforeAndCancelAll() {
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
List<String> instances = helper.startInstances("process1", 10);
Batch batch = runtimeService.createModification(processDefinition.getId()).startBeforeActivity("user1").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);
assertNull(updatedTree);
}
// and the no modification jobs exist
assertEquals(0, helper.getExecutionJobs(batch).size());
// but a monitor job exists
assertNotNull(helper.getMonitorJob(batch));
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method testBatchWithFailedSeedJobDeletionWithCascade.
@Test
public void testBatchWithFailedSeedJobDeletionWithCascade() {
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
Batch batch = helper.cancelAllAsync("process1", 2, "user1", processDefinition.getId());
// create incident
Job seedJob = helper.getSeedJob(batch);
rule.getManagementService().setJobRetries(seedJob.getId(), 0);
// when
rule.getManagementService().deleteBatch(batch.getId(), true);
// then the no historic incidents exists
long historicIncidents = rule.getHistoryService().createHistoricIncidentQuery().count();
assertEquals(0, historicIncidents);
}
Aggregations