Search in sources :

Example 16 with Job

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);
    }
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) Job(org.camunda.bpm.engine.runtime.Job)

Example 17 with Job

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);
}
Also used : Job(org.camunda.bpm.engine.runtime.Job) Date(java.util.Date)

Example 18 with Job

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);
}
Also used : Job(org.camunda.bpm.engine.runtime.Job) Date(java.util.Date)

Example 19 with Job

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());
}
Also used : Job(org.camunda.bpm.engine.runtime.Job)

Example 20 with Job

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());
}
Also used : Job(org.camunda.bpm.engine.runtime.Job)

Aggregations

Job (org.camunda.bpm.engine.runtime.Job)696 Deployment (org.camunda.bpm.engine.test.Deployment)310 Test (org.junit.Test)232 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)189 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)148 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)135 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)116 HashMap (java.util.HashMap)98 Batch (org.camunda.bpm.engine.batch.Batch)78 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)78 Task (org.camunda.bpm.engine.task.Task)71 Date (java.util.Date)67 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)48 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)24 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)23 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)21 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)20 Incident (org.camunda.bpm.engine.runtime.Incident)17 HistoricJobLog (org.camunda.bpm.engine.history.HistoricJobLog)15 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)15