Search in sources :

Example 1 with ExternalTaskQueryImpl

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);
}
Also used : ArrayList(java.util.ArrayList) ExternalTaskQueryImpl(org.camunda.bpm.engine.impl.ExternalTaskQueryImpl) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) HashSet(java.util.HashSet)

Example 2 with ExternalTaskQueryImpl

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);
}
Also used : ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) ExternalTaskQueryDto(org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) ExternalTaskQueryImpl(org.camunda.bpm.engine.impl.ExternalTaskQueryImpl) Test(org.junit.Test)

Example 3 with ExternalTaskQueryImpl

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);
}
Also used : ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) ExternalTaskQueryDto(org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) ExternalTaskQueryImpl(org.camunda.bpm.engine.impl.ExternalTaskQueryImpl) Test(org.junit.Test)

Aggregations

ExternalTaskQueryImpl (org.camunda.bpm.engine.impl.ExternalTaskQueryImpl)3 HashMap (java.util.HashMap)2 ExternalTaskQuery (org.camunda.bpm.engine.externaltask.ExternalTaskQuery)2 ExternalTaskQueryDto (org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)1