Search in sources :

Example 56 with JobDefinition

use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.

the class JobDefinitionQueryTest method testQueryBySuspended.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/JobDefinitionQueryTest.testBase.bpmn" })
public void testQueryBySuspended() {
    JobDefinitionQuery query = managementService.createJobDefinitionQuery().suspended();
    verifyQueryResults(query, 0);
    // suspend first one
    JobDefinition jobDefinition = managementService.createJobDefinitionQuery().jobType(AsyncContinuationJobHandler.TYPE).singleResult();
    managementService.suspendJobDefinitionById(jobDefinition.getId());
    // only one is suspended
    verifyQueryResults(query, 1);
    // Suspend second one
    jobDefinition = managementService.createJobDefinitionQuery().jobType(TimerStartEventJobHandler.TYPE).singleResult();
    managementService.suspendJobDefinitionById(jobDefinition.getId());
    // only two are suspended
    verifyQueryResults(query, 2);
    // suspend third one
    jobDefinition = managementService.createJobDefinitionQuery().jobType(TimerCatchIntermediateEventJobHandler.TYPE).singleResult();
    managementService.suspendJobDefinitionById(jobDefinition.getId());
    // only three are suspended
    verifyQueryResults(query, 3);
    // suspend fourth one
    jobDefinition = managementService.createJobDefinitionQuery().jobType(TimerExecuteNestedActivityJobHandler.TYPE).singleResult();
    managementService.suspendJobDefinitionById(jobDefinition.getId());
    // all are suspended
    verifyQueryResults(query, 4);
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 57 with JobDefinition

use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.

the class JobQueryTest method testQueryByActivityId.

public void testQueryByActivityId() {
    JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
    JobQuery query = managementService.createJobQuery().activityId(jobDefinition.getActivityId());
    verifyQueryResults(query, 3);
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery) JobDefinition(org.camunda.bpm.engine.management.JobDefinition)

Example 58 with JobDefinition

use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.

the class BatchPriorityTest method seedJobShouldGetPriorityFromOverridingJobDefinitionPriority.

@Test
public void seedJobShouldGetPriorityFromOverridingJobDefinitionPriority() {
    // given
    Batch batch = helper.migrateProcessInstancesAsync(2);
    JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
    managementService.setOverridingJobPriorityForJobDefinition(seedJobDefinition.getId(), CUSTOM_PRIORITY);
    // when
    helper.executeSeedJob(batch);
    // then
    Job seedJob = helper.getSeedJob(batch);
    assertEquals(CUSTOM_PRIORITY, seedJob.getPriority());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 59 with JobDefinition

use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.

the class BatchPriorityTest method monitorJobShouldGetPriorityOverridingJobDefinitionPriority.

@Test
public void monitorJobShouldGetPriorityOverridingJobDefinitionPriority() {
    // given
    Batch batch = helper.migrateProcessInstancesAsync(1);
    JobDefinition monitorJobDefinition = helper.getMonitorJobDefinition(batch);
    managementService.setOverridingJobPriorityForJobDefinition(monitorJobDefinition.getId(), CUSTOM_PRIORITY);
    // when
    helper.executeSeedJob(batch);
    // then
    Job monitorJob = helper.getMonitorJob(batch);
    assertEquals(CUSTOM_PRIORITY, monitorJob.getPriority());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 60 with JobDefinition

use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.

the class ActivateJobTest method testActivateByProcessInstanceId_shouldActivateJob.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" })
public void testActivateByProcessInstanceId_shouldActivateJob() {
    // given
    // a running process instance with a failed job
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("fail", Boolean.TRUE);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("suspensionProcess", params);
    // suspended job definitions and corresponding jobs
    managementService.suspendJobDefinitionByProcessDefinitionKey("suspensionProcess", true);
    // the job definition
    JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
    // the failed job
    JobQuery jobQuery = managementService.createJobQuery();
    Job job = jobQuery.singleResult();
    assertTrue(job.isSuspended());
    // when
    // the job will be activate
    managementService.activateJobByProcessInstanceId(processInstance.getId());
    // then
    // the job should be suspended
    assertEquals(1, jobQuery.active().count());
    assertEquals(0, jobQuery.suspended().count());
    Job suspendedJob = jobQuery.active().singleResult();
    assertEquals(job.getId(), suspendedJob.getId());
    assertEquals(jobDefinition.getId(), suspendedJob.getJobDefinitionId());
    assertFalse(suspendedJob.isSuspended());
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

JobDefinition (org.camunda.bpm.engine.management.JobDefinition)219 Job (org.camunda.bpm.engine.runtime.Job)135 Deployment (org.camunda.bpm.engine.test.Deployment)112 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)86 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)73 HashMap (java.util.HashMap)67 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)64 Test (org.junit.Test)63 Batch (org.camunda.bpm.engine.batch.Batch)28 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)16 Date (java.util.Date)11 InputStream (java.io.InputStream)8 Deployment (org.camunda.bpm.engine.repository.Deployment)8 DeploymentBuilder (org.camunda.bpm.engine.repository.DeploymentBuilder)8 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)6 UserOperationLogEntry (org.camunda.bpm.engine.history.UserOperationLogEntry)4 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)4 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)3 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)3 Response (com.jayway.restassured.response.Response)2