use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class BatchHistoricDecisionInstanceDeletionTest method createDeletionJobsByIdsAndQuery.
@Test
public void createDeletionJobsByIdsAndQuery() {
// given
rule.getProcessEngineConfiguration().setBatchJobsPerSeed(5);
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, null);
JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
JobDefinition deletionJobDefinition = helper.getExecutionJobDefinition(batch);
;
// when
helper.executeSeedJob(batch);
// then
List<Job> deletionJobs = helper.getJobsForDefinition(deletionJobDefinition);
assertEquals(5, deletionJobs.size());
for (Job deletionJob : deletionJobs) {
assertEquals(deletionJobDefinition.getId(), deletionJob.getJobDefinitionId());
assertNull(deletionJob.getDuedate());
assertNull(deletionJob.getProcessDefinitionId());
assertNull(deletionJob.getProcessDefinitionKey());
assertNull(deletionJob.getProcessInstanceId());
assertNull(deletionJob.getExecutionId());
}
// and the seed job still exists
Job seedJob = helper.getJobForDefinition(seedJobDefinition);
assertNotNull(seedJob);
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class BatchHistoricDecisionInstanceDeletionTest method createDeletionJobsByQuery.
@Test
public void createDeletionJobsByQuery() {
// given
rule.getProcessEngineConfiguration().setBatchJobsPerSeed(5);
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
Batch batch = historyService.deleteHistoricDecisionInstancesAsync(query, null);
JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
JobDefinition deletionJobDefinition = helper.getExecutionJobDefinition(batch);
;
// when
helper.executeSeedJob(batch);
// then
List<Job> deletionJobs = helper.getJobsForDefinition(deletionJobDefinition);
assertEquals(5, deletionJobs.size());
for (Job deletionJob : deletionJobs) {
assertEquals(deletionJobDefinition.getId(), deletionJob.getJobDefinitionId());
assertNull(deletionJob.getDuedate());
assertNull(deletionJob.getProcessDefinitionId());
assertNull(deletionJob.getProcessDefinitionKey());
assertNull(deletionJob.getProcessInstanceId());
assertNull(deletionJob.getExecutionId());
}
// and the seed job still exists
Job seedJob = helper.getJobForDefinition(seedJobDefinition);
assertNotNull(seedJob);
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class SetExternalTasksRetriesTest method executeBatchJobs.
/**
* Execute all batch jobs of batch once and collect exceptions during job execution.
*
* @param batch the batch for which the batch jobs should be executed
* @return the catched exceptions of the batch job executions, is empty if non where thrown
*/
protected List<Exception> executeBatchJobs(Batch batch) {
String batchJobDefinitionId = batch.getBatchJobDefinitionId();
List<Job> batchJobs = managementService.createJobQuery().jobDefinitionId(batchJobDefinitionId).list();
assertFalse(batchJobs.isEmpty());
List<Exception> catchedExceptions = new ArrayList<Exception>();
for (Job batchJob : batchJobs) {
try {
managementService.executeJob(batchJob.getId());
} catch (Exception e) {
catchedExceptions.add(e);
}
}
return catchedExceptions;
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class SetExternalTasksRetriesTest method executeSeedAndBatchJobs.
public void executeSeedAndBatchJobs(Batch batch) {
Job job = engineRule.getManagementService().createJobQuery().jobDefinitionId(batch.getSeedJobDefinitionId()).singleResult();
// seed job
managementService.executeJob(job.getId());
for (Job pending : managementService.createJobQuery().jobDefinitionId(batch.getBatchJobDefinitionId()).list()) {
managementService.executeJob(pending.getId());
}
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class SetJobPriorityAuthorizationTest method testSetJobPriority.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/authorization/oneIncidentProcess.bpmn20.xml")
public void testSetJobPriority() {
// given
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("process");
Job job = engineRule.getManagementService().createJobQuery().singleResult();
// when
authRule.init(scenario).withUser("userId").bindResource("processInstanceId", processInstance.getId()).bindResource("processDefinitionKey", "process").start();
engineRule.getManagementService().setJobPriority(job.getId(), 42);
// then
if (authRule.assertScenario(scenario)) {
Job updatedJob = engineRule.getManagementService().createJobQuery().singleResult();
Assert.assertEquals(42, updatedJob.getPriority());
}
}
Aggregations