use of org.camunda.bpm.engine.impl.ExternalTaskQueryImpl in project camunda-bpm-platform by camunda.
the class AbstractSetExternalTaskRetriesCmd method collectExternalTaskIds.
protected List<String> collectExternalTaskIds() {
final Set<String> collectedIds = new HashSet<String>();
List<String> externalTaskIds = builder.getExternalTaskIds();
if (externalTaskIds != null) {
ensureNotContainsNull(BadUserRequestException.class, "External task id cannot be null", "externalTaskIds", externalTaskIds);
collectedIds.addAll(externalTaskIds);
}
ExternalTaskQueryImpl externalTaskQuery = (ExternalTaskQueryImpl) builder.getExternalTaskQuery();
if (externalTaskQuery != null) {
collectedIds.addAll(externalTaskQuery.listIds());
}
final List<String> collectedProcessInstanceIds = collectProcessInstanceIds();
if (!collectedProcessInstanceIds.isEmpty()) {
Context.getCommandContext().runWithoutAuthorization(new Callable<Void>() {
public Void call() throws Exception {
ExternalTaskQueryImpl query = new ExternalTaskQueryImpl();
query.processInstanceIdIn(collectedProcessInstanceIds.toArray(new String[collectedProcessInstanceIds.size()]));
collectedIds.addAll(query.listIds());
return null;
}
});
}
return new ArrayList<String>(collectedIds);
}
use of org.camunda.bpm.engine.impl.ExternalTaskQueryImpl 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.impl.ExternalTaskQueryImpl in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceInteractionTest method testSetRetriesAsyncWithExternalTaskQuery.
@Test
public void testSetRetriesAsyncWithExternalTaskQuery() {
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.OK.getStatusCode()).when().post(RETRIES_EXTERNAL_TASKS_ASYNC_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).setAsync(5);
verifyNoMoreInteractions(updateRetriesBuilder);
ExternalTaskQueryImpl actualQuery = (ExternalTaskQueryImpl) queryCapture.getValue();
assertThat(actualQuery).isNotNull();
assertThat(actualQuery.getProcessDefinitionId()).isEqualTo(EXAMPLE_PROCESS_DEFINITION_ID);
}
Aggregations