Search in sources :

Example 61 with JobQuery

use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.

the class JobQueryTest method testQuerySorting.

// sorting //////////////////////////////////////////
public void testQuerySorting() {
    // asc
    assertEquals(4, managementService.createJobQuery().orderByJobId().asc().count());
    assertEquals(4, managementService.createJobQuery().orderByJobDuedate().asc().count());
    assertEquals(4, managementService.createJobQuery().orderByExecutionId().asc().count());
    assertEquals(4, managementService.createJobQuery().orderByProcessInstanceId().asc().count());
    assertEquals(4, managementService.createJobQuery().orderByJobRetries().asc().count());
    assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionId().asc().count());
    assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionKey().asc().count());
    // desc
    assertEquals(4, managementService.createJobQuery().orderByJobId().desc().count());
    assertEquals(4, managementService.createJobQuery().orderByJobDuedate().desc().count());
    assertEquals(4, managementService.createJobQuery().orderByExecutionId().desc().count());
    assertEquals(4, managementService.createJobQuery().orderByProcessInstanceId().desc().count());
    assertEquals(4, managementService.createJobQuery().orderByJobRetries().desc().count());
    assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionId().desc().count());
    assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionKey().desc().count());
    // sorting on multiple fields
    setRetries(processInstanceIdTwo, 2);
    // make sure all timers can fire
    ClockUtil.setCurrentTime(new Date(timerThreeFireTime.getTime() + ONE_SECOND));
    JobQuery query = managementService.createJobQuery().timers().executable().orderByJobRetries().asc().orderByJobDuedate().desc();
    List<Job> jobs = query.list();
    assertEquals(3, jobs.size());
    assertEquals(2, jobs.get(0).getRetries());
    assertEquals(3, jobs.get(1).getRetries());
    assertEquals(3, jobs.get(2).getRetries());
    assertEquals(processInstanceIdTwo, jobs.get(0).getProcessInstanceId());
    assertEquals(processInstanceIdThree, jobs.get(1).getProcessInstanceId());
    assertEquals(processInstanceIdOne, jobs.get(2).getProcessInstanceId());
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Job(org.camunda.bpm.engine.runtime.Job) Date(java.util.Date)

Example 62 with JobQuery

use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.

the class JobQueryTest method testQueryByNoCriteria.

public void testQueryByNoCriteria() {
    JobQuery query = managementService.createJobQuery();
    verifyQueryResults(query, 4);
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery)

Example 63 with JobQuery

use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.

the class JobQueryTest method testQueryByOnlyTimers.

public void testQueryByOnlyTimers() {
    JobQuery query = managementService.createJobQuery().timers();
    verifyQueryResults(query, 3);
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery)

Example 64 with JobQuery

use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.

the class JobQueryTest method testQueryByInvalidProcessDefinitionKey.

public void testQueryByInvalidProcessDefinitionKey() {
    JobQuery query = managementService.createJobQuery().processDefinitionKey("invalid");
    verifyQueryResults(query, 0);
    try {
        managementService.createJobQuery().processDefinitionKey(null).list();
        fail();
    } catch (ProcessEngineException e) {
    }
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 65 with JobQuery

use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.

the class JobQueryTest method testQueryByException.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml" })
public void testQueryByException() {
    JobQuery query = managementService.createJobQuery().withException();
    verifyQueryResults(query, 0);
    ProcessInstance processInstance = startProcessInstanceWithFailingJob();
    query = managementService.createJobQuery().withException();
    verifyFailedJob(query, processInstance);
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

JobQuery (org.camunda.bpm.engine.runtime.JobQuery)255 Deployment (org.camunda.bpm.engine.test.Deployment)143 Job (org.camunda.bpm.engine.runtime.Job)115 HashMap (java.util.HashMap)105 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)88 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)73 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)55 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)41 Test (org.junit.Test)32 Date (java.util.Date)30 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)23 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)17 ExecutionQuery (org.camunda.bpm.engine.runtime.ExecutionQuery)14 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)9 Task (org.camunda.bpm.engine.task.Task)8 Batch (org.camunda.bpm.engine.batch.Batch)5 AbstractAsyncOperationsTest (org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest)5 ActivitySequenceCounterMap (org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap)5 Matchers.anyString (org.mockito.Matchers.anyString)5 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3