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));
}
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;
}
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;
}
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;
}
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());
}
Aggregations