Search in sources :

Example 1 with JobQuery

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

the class JobRestServiceInteractionTest method testSetRetriesAsync.

@Test
public void testSetRetriesAsync() {
    List<String> ids = Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID);
    Batch batchEntity = MockProvider.createMockBatch();
    when(mockManagementService.setJobRetriesAsync(anyListOf(String.class), any(JobQuery.class), anyInt())).thenReturn(batchEntity);
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    messageBodyJson.put("jobIds", ids);
    messageBodyJson.put(RETRIES, 5);
    Response response = given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.OK.getStatusCode()).when().post(JOBS_SET_RETRIES_URL);
    verifyBatchJson(response.asString());
    verify(mockManagementService, times(1)).setJobRetriesAsync(eq(ids), eq((JobQuery) null), eq(5));
}
Also used : Response(com.jayway.restassured.response.Response) Batch(org.camunda.bpm.engine.batch.Batch) HashMap(java.util.HashMap) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 2 with JobQuery

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

the class JobRestServiceImpl method queryJobs.

@Override
public List<JobDto> queryJobs(JobQueryDto queryDto, Integer firstResult, Integer maxResults) {
    ProcessEngine engine = getProcessEngine();
    queryDto.setObjectMapper(getObjectMapper());
    JobQuery query = queryDto.toQuery(engine);
    List<Job> matchingJobs;
    if (firstResult != null || maxResults != null) {
        matchingJobs = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingJobs = query.list();
    }
    List<JobDto> jobResults = new ArrayList<JobDto>();
    for (Job job : matchingJobs) {
        JobDto resultJob = JobDto.fromJob(job);
        jobResults.add(resultJob);
    }
    return jobResults;
}
Also used : JobDto(org.camunda.bpm.engine.rest.dto.runtime.JobDto) ArrayList(java.util.ArrayList) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Job(org.camunda.bpm.engine.runtime.Job) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 3 with JobQuery

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

the class JobRestServiceImpl method queryJobsCount.

@Override
public CountResultDto queryJobsCount(JobQueryDto queryDto) {
    ProcessEngine engine = getProcessEngine();
    queryDto.setObjectMapper(getObjectMapper());
    JobQuery query = queryDto.toQuery(engine);
    long count = query.count();
    CountResultDto result = new CountResultDto();
    result.setCount(count);
    return result;
}
Also used : CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 4 with JobQuery

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

the class JobRestServiceQueryTest method setUpMockJobQuery.

private JobQuery setUpMockJobQuery(List<Job> mockedJobs) {
    JobQuery sampleJobQuery = mock(JobQuery.class);
    when(sampleJobQuery.list()).thenReturn(mockedJobs);
    when(sampleJobQuery.count()).thenReturn((long) mockedJobs.size());
    when(processEngine.getManagementService().createJobQuery()).thenReturn(sampleJobQuery);
    return sampleJobQuery;
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery)

Example 5 with JobQuery

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

the class JobAuthorizationTest method testQueryWithReadInstancePermissionOnTimerBoundaryProcessDefinition.

public void testQueryWithReadInstancePermissionOnTimerBoundaryProcessDefinition() {
    // given
    String processInstanceId = startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, TIMER_BOUNDARY_PROCESS_KEY, userId, READ_INSTANCE);
    // when
    JobQuery query = managementService.createJobQuery();
    // then
    verifyQueryResults(query, 1);
    Job job = query.singleResult();
    assertEquals(processInstanceId, job.getProcessInstanceId());
    assertEquals(TIMER_BOUNDARY_PROCESS_KEY, job.getProcessDefinitionKey());
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Job(org.camunda.bpm.engine.runtime.Job)

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