use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class JobAuthorizationTest method testExecuteJobWithoutAuthorization.
// execute job ////////////////////////////////////////////////
public void testExecuteJobWithoutAuthorization() {
// given
Job job = selectAnyJob();
String jobId = job.getId();
try {
// when
managementService.executeJob(jobId);
fail("Exception expected: It should not be possible to execute the job");
} catch (AuthorizationException e) {
// then
String message = e.getMessage();
assertTextPresent(userId, message);
assertTextPresent(UPDATE.getName(), message);
assertTextPresent(PROCESS_INSTANCE.resourceName(), message);
assertTextPresent(UPDATE_INSTANCE.getName(), message);
assertTextPresent(job.getProcessDefinitionKey(), message);
assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
}
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class JobAuthorizationTest method testActivateStandaloneJobById.
public void testActivateStandaloneJobById() {
// given
createGrantAuthorization(PROCESS_DEFINITION, TIMER_START_PROCESS_KEY, userId, UPDATE);
Date startTime = new Date();
ClockUtil.setCurrentTime(startTime);
long oneWeekFromStartTime = startTime.getTime() + (7 * 24 * 60 * 60 * 1000);
disableAuthorization();
// creates a new "standalone" job
managementService.suspendJobDefinitionByProcessDefinitionKey(TIMER_START_PROCESS_KEY, false, new Date(oneWeekFromStartTime));
enableAuthorization();
String jobId = managementService.createJobQuery().singleResult().getId();
suspendJobById(jobId);
// when
managementService.activateJobById(jobId);
// then
Job job = selectJobById(jobId);
assertNotNull(job);
assertFalse(job.isSuspended());
deleteJob(jobId);
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class JobAuthorizationTest method testSuspendStandaloneJobById.
public void testSuspendStandaloneJobById() {
// given
createGrantAuthorization(PROCESS_DEFINITION, TIMER_START_PROCESS_KEY, userId, UPDATE);
Date startTime = new Date();
ClockUtil.setCurrentTime(startTime);
long oneWeekFromStartTime = startTime.getTime() + (7 * 24 * 60 * 60 * 1000);
disableAuthorization();
// creates a new "standalone" job
managementService.suspendJobDefinitionByProcessDefinitionKey(TIMER_START_PROCESS_KEY, false, new Date(oneWeekFromStartTime));
enableAuthorization();
String jobId = managementService.createJobQuery().singleResult().getId();
// when
managementService.suspendJobById(jobId);
// then
Job job = selectJobById(jobId);
assertNotNull(job);
assertTrue(job.isSuspended());
deleteJob(jobId);
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class JobAuthorizationTest method testSuspendJobByProcessDefinitionKeyWihtUpdatePermissionOnProcessDefinition.
public void testSuspendJobByProcessDefinitionKeyWihtUpdatePermissionOnProcessDefinition() {
// given
String processInstanceId = startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, TIMER_BOUNDARY_PROCESS_KEY, userId, UPDATE_INSTANCE);
// when
managementService.suspendJobByProcessDefinitionKey(TIMER_BOUNDARY_PROCESS_KEY);
// then
Job job = selectJobByProcessInstanceId(processInstanceId);
assertNotNull(job);
assertTrue(job.isSuspended());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class JobAuthorizationTest method testSetJobRetriesWithUpdateInstancePermissionOnProcessDefinition.
public void testSetJobRetriesWithUpdateInstancePermissionOnProcessDefinition() {
// given
String processInstanceId = startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, TIMER_BOUNDARY_PROCESS_KEY, userId, UPDATE_INSTANCE);
String jobId = selectJobByProcessInstanceId(processInstanceId).getId();
// when
managementService.setJobRetries(jobId, 1);
// then
Job job = selectJobById(jobId);
assertNotNull(job);
assertEquals(1, job.getRetries());
}
Aggregations