use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionAuthorizationTest method testSuspendByProcessDefinitionIdWithUpdatePermissionOnProcessDefinition.
public void testSuspendByProcessDefinitionIdWithUpdatePermissionOnProcessDefinition() {
// given
createGrantAuthorization(PROCESS_DEFINITION, TIMER_BOUNDARY_PROCESS_KEY, userId, UPDATE);
String processDefinitionId = selectProcessDefinitionByKey(TIMER_BOUNDARY_PROCESS_KEY).getId();
// when
managementService.suspendJobDefinitionByProcessDefinitionId(processDefinitionId);
// then
JobDefinition jobDefinition = selectJobDefinitionByProcessDefinitionKey(TIMER_BOUNDARY_PROCESS_KEY);
assertNotNull(jobDefinition);
assertTrue(jobDefinition.isSuspended());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionPriorityTest method testResetJobDefinitionPriorityWhenPriorityIsNull.
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/asyncTaskProcess.bpmn20.xml")
public void testResetJobDefinitionPriorityWhenPriorityIsNull() {
// given a job definition with null priority
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
assertNull(jobDefinition.getOverridingJobPriority());
// when I set a priority
managementService.clearOverridingJobPriorityForJobDefinition(jobDefinition.getId());
// then the priority remains unchanged
JobDefinition updatedDefinition = managementService.createJobDefinitionQuery().jobDefinitionId(jobDefinition.getId()).singleResult();
assertNull(updatedDefinition.getOverridingJobPriority());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionPriorityTest method testSetJobDefinitionPriorityWithCascade.
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/asyncTaskProcess.bpmn20.xml")
public void testSetJobDefinitionPriorityWithCascade() {
// given a process instance with a job with default priority and a corresponding job definition
ProcessInstance instance = runtimeService.createProcessInstanceByKey("asyncTaskProcess").startBeforeActivity("task").execute();
Job job = managementService.createJobQuery().singleResult();
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().jobDefinitionId(job.getJobDefinitionId()).singleResult();
// when I set the job definition's priority
managementService.setOverridingJobPriorityForJobDefinition(jobDefinition.getId(), 52, true);
// then the job definition's priority value has changed
JobDefinition updatedDefinition = managementService.createJobDefinitionQuery().jobDefinitionId(jobDefinition.getId()).singleResult();
assertEquals(52, (long) updatedDefinition.getOverridingJobPriority());
// the existing job's priority has changed as well
Job updatedExistingJob = managementService.createJobQuery().singleResult();
assertEquals(52, updatedExistingJob.getPriority());
// and a new job of that definition receives the updated priority
runtimeService.createProcessInstanceModification(instance.getId()).startBeforeActivity("task").execute();
Job newJob = getJobThatIsNot(updatedExistingJob);
assertEquals(52, newJob.getPriority());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionPriorityTest method testSetJobDefinitionPriorityToExtremeValues.
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/asyncTaskProcess.bpmn20.xml")
public void testSetJobDefinitionPriorityToExtremeValues() {
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
// it is possible to set the max long value
managementService.setOverridingJobPriorityForJobDefinition(jobDefinition.getId(), Long.MAX_VALUE);
jobDefinition = managementService.createJobDefinitionQuery().singleResult();
assertEquals(Long.MAX_VALUE, (long) jobDefinition.getOverridingJobPriority());
// it is possible to set the min long value
// +1 for informix
managementService.setOverridingJobPriorityForJobDefinition(jobDefinition.getId(), Long.MIN_VALUE + 1);
jobDefinition = managementService.createJobDefinitionQuery().singleResult();
assertEquals(Long.MIN_VALUE + 1, (long) jobDefinition.getOverridingJobPriority());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionPriorityTest method testRedeployOverridesSetJobDefinitionPriority.
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/jobPrioProcess.bpmn20.xml")
public void testRedeployOverridesSetJobDefinitionPriority() {
// given a process instance with a job with default priority and a corresponding job definition
runtimeService.createProcessInstanceByKey("jobPrioProcess").startBeforeActivity("task2").execute();
Job job = managementService.createJobQuery().singleResult();
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().jobDefinitionId(job.getJobDefinitionId()).singleResult();
// when I set the job definition's priority
managementService.setOverridingJobPriorityForJobDefinition(jobDefinition.getId(), 72, true);
// then the job definition's priority value has changed
JobDefinition updatedDefinition = managementService.createJobDefinitionQuery().jobDefinitionId(jobDefinition.getId()).singleResult();
assertEquals(72, (long) updatedDefinition.getOverridingJobPriority());
// the existing job's priority has changed as well
Job updatedExistingJob = managementService.createJobQuery().singleResult();
assertEquals(72, updatedExistingJob.getPriority());
// if the process definition is redeployed
String secondDeploymentId = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/jobPrioProcess.bpmn20.xml").deploy().getId();
// then a new job will have the priority from the BPMN xml
ProcessInstance secondInstance = runtimeService.createProcessInstanceByKey("jobPrioProcess").startBeforeActivity("task2").execute();
Job newJob = managementService.createJobQuery().processInstanceId(secondInstance.getId()).singleResult();
assertEquals(5, newJob.getPriority());
repositoryService.deleteDeployment(secondDeploymentId, true);
}
Aggregations