use of org.camunda.bpm.engine.externaltask.ExternalTaskQuery in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryAuthorizationTest method testQueryWithReadOnProcessInstance.
public void testQueryWithReadOnProcessInstance() {
// given
createGrantAuthorization(PROCESS_INSTANCE, instance1Id, userId, READ);
// when
ExternalTaskQuery query = externalTaskService.createExternalTaskQuery();
// then
verifyQueryResults(query, 1);
assertEquals(instance1Id, query.list().get(0).getProcessInstanceId());
}
use of org.camunda.bpm.engine.externaltask.ExternalTaskQuery in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryAuthorizationTest method testQueryWithReadOnAnyProcessInstance.
public void testQueryWithReadOnAnyProcessInstance() {
// given
createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
// when
ExternalTaskQuery query = externalTaskService.createExternalTaskQuery();
// then
verifyQueryResults(query, 2);
}
use of org.camunda.bpm.engine.externaltask.ExternalTaskQuery in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceInteractionTest method testSetRetriesSyncWithExternalTaskQuery.
@Test
public void testSetRetriesSyncWithExternalTaskQuery() {
when(externalTaskService.createExternalTaskQuery()).thenReturn(new ExternalTaskQueryImpl());
ExternalTaskQueryDto query = new ExternalTaskQueryDto();
query.setProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("retries", "5");
parameters.put("externalTaskQuery", query);
given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(RETRIES_EXTERNAL_TASK_SYNC_URL);
ArgumentCaptor<ExternalTaskQuery> queryCapture = ArgumentCaptor.forClass(ExternalTaskQuery.class);
verify(externalTaskService).updateRetries();
verify(externalTaskService).createExternalTaskQuery();
verifyNoMoreInteractions(externalTaskService);
verify(updateRetriesBuilder).externalTaskIds((List<String>) null);
verify(updateRetriesBuilder).processInstanceIds((List<String>) null);
verify(updateRetriesBuilder).externalTaskQuery(queryCapture.capture());
verify(updateRetriesBuilder).processInstanceQuery(null);
verify(updateRetriesBuilder).historicProcessInstanceQuery(null);
verify(updateRetriesBuilder).set(5);
verifyNoMoreInteractions(updateRetriesBuilder);
ExternalTaskQueryImpl actualQuery = (ExternalTaskQueryImpl) queryCapture.getValue();
assertThat(actualQuery).isNotNull();
assertThat(actualQuery.getProcessDefinitionId()).isEqualTo(EXAMPLE_PROCESS_DEFINITION_ID);
}
use of org.camunda.bpm.engine.externaltask.ExternalTaskQuery in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceImpl method queryExternalTasks.
@Override
public List<ExternalTaskDto> queryExternalTasks(ExternalTaskQueryDto queryDto, Integer firstResult, Integer maxResults) {
ProcessEngine engine = getProcessEngine();
queryDto.setObjectMapper(getObjectMapper());
ExternalTaskQuery query = queryDto.toQuery(engine);
List<ExternalTask> matchingTasks;
if (firstResult != null || maxResults != null) {
matchingTasks = executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingTasks = query.list();
}
List<ExternalTaskDto> taskResults = new ArrayList<ExternalTaskDto>();
for (ExternalTask task : matchingTasks) {
ExternalTaskDto resultInstance = ExternalTaskDto.fromExternalTask(task);
taskResults.add(resultInstance);
}
return taskResults;
}
use of org.camunda.bpm.engine.externaltask.ExternalTaskQuery in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryAuthorizationTest method testQueryWithoutAuthorization.
public void testQueryWithoutAuthorization() {
// when
ExternalTaskQuery query = externalTaskService.createExternalTaskQuery();
// then
verifyQueryResults(query, 0);
}
Aggregations