use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionMigrateJob.
@Deployment(resources = TEST_PROCESS_ONE_JOB)
public void testSetProcessDefinitionVersionMigrateJob() {
// given a process instance
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneJobProcess");
// with a job
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
// and a second deployment of the process
org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_ONE_JOB).deploy();
ProcessDefinition newDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
assertNotNull(newDefinition);
// when the process instance is migrated
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new SetProcessDefinitionVersionCmd(instance.getId(), 2));
// then the the job should also be migrated
Job migratedJob = managementService.createJobQuery().singleResult();
assertNotNull(migratedJob);
assertEquals(job.getId(), migratedJob.getId());
assertEquals(newDefinition.getId(), migratedJob.getProcessDefinitionId());
assertEquals(deployment.getId(), migratedJob.getDeploymentId());
JobDefinition newJobDefinition = managementService.createJobDefinitionQuery().processDefinitionId(newDefinition.getId()).singleResult();
assertNotNull(newJobDefinition);
assertEquals(newJobDefinition.getId(), migratedJob.getJobDefinitionId());
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionAuthorizationTest method testActivateByProcessDefinitionKeyWithUpdatePermissionOnProcessDefinition.
public void testActivateByProcessDefinitionKeyWithUpdatePermissionOnProcessDefinition() {
// given
suspendJobDefinitionByProcessDefinitionKey(TIMER_BOUNDARY_PROCESS_KEY);
createGrantAuthorization(PROCESS_DEFINITION, TIMER_BOUNDARY_PROCESS_KEY, userId, UPDATE);
// when
managementService.activateJobDefinitionByProcessDefinitionKey(TIMER_BOUNDARY_PROCESS_KEY);
// then
JobDefinition jobDefinition = selectJobDefinitionByProcessDefinitionKey(TIMER_BOUNDARY_PROCESS_KEY);
assertNotNull(jobDefinition);
assertFalse(jobDefinition.isSuspended());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionAuthorizationTest method testActivateIncludingJobsByIdWithUpdateInstancePermissionOnProcessDefinition.
public void testActivateIncludingJobsByIdWithUpdateInstancePermissionOnProcessDefinition() {
// given
String jobDefinitionId = selectJobDefinitionByProcessDefinitionKey(TIMER_BOUNDARY_PROCESS_KEY).getId();
String processInstanceId = startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY).getId();
suspendJobDefinitionIncludingJobsById(jobDefinitionId);
createGrantAuthorization(PROCESS_DEFINITION, TIMER_BOUNDARY_PROCESS_KEY, userId, UPDATE, UPDATE_INSTANCE);
// when
managementService.activateJobDefinitionById(jobDefinitionId, true);
// then
JobDefinition jobDefinition = selectJobDefinitionByProcessDefinitionKey(TIMER_BOUNDARY_PROCESS_KEY);
assertNotNull(jobDefinition);
assertFalse(jobDefinition.isSuspended());
Job job = selectJobByProcessInstanceId(processInstanceId);
assertNotNull(job);
assertFalse(job.isSuspended());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionAuthorizationTest method testSuspendIncludingJobsByProcessDefinitionIdWithUpdateInstancePermissionOnAnyProcessDefinition.
public void testSuspendIncludingJobsByProcessDefinitionIdWithUpdateInstancePermissionOnAnyProcessDefinition() {
// given
String processDefinitionId = selectProcessDefinitionByKey(TIMER_BOUNDARY_PROCESS_KEY).getId();
String processInstanceId = startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, TIMER_BOUNDARY_PROCESS_KEY, userId, UPDATE);
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, UPDATE_INSTANCE);
// when
managementService.suspendJobDefinitionByProcessDefinitionId(processDefinitionId, true);
// then
JobDefinition jobDefinition = selectJobDefinitionByProcessDefinitionKey(TIMER_BOUNDARY_PROCESS_KEY);
assertNotNull(jobDefinition);
assertTrue(jobDefinition.isSuspended());
Job job = selectJobByProcessInstanceId(processInstanceId);
assertNotNull(job);
assertTrue(job.isSuspended());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionAuthorizationTest method testSuspendByProcessDefinitionKeyWithUpdatePermissionOnProcessDefinition.
public void testSuspendByProcessDefinitionKeyWithUpdatePermissionOnProcessDefinition() {
// given
createGrantAuthorization(PROCESS_DEFINITION, TIMER_BOUNDARY_PROCESS_KEY, userId, UPDATE);
// when
managementService.suspendJobDefinitionByProcessDefinitionKey(TIMER_BOUNDARY_PROCESS_KEY);
// then
JobDefinition jobDefinition = selectJobDefinitionByProcessDefinitionKey(TIMER_BOUNDARY_PROCESS_KEY);
assertNotNull(jobDefinition);
assertTrue(jobDefinition.isSuspended());
}
Aggregations