Search in sources :

Example 1 with ExternalTaskQueryDto

use of org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceImpl method updateRetries.

protected UpdateExternalTaskRetriesBuilder updateRetries(SetRetriesForExternalTasksDto retriesDto) {
    ExternalTaskService externalTaskService = getProcessEngine().getExternalTaskService();
    List<String> externalTaskIds = retriesDto.getExternalTaskIds();
    List<String> processInstanceIds = retriesDto.getProcessInstanceIds();
    ExternalTaskQuery externalTaskQuery = null;
    ProcessInstanceQuery processInstanceQuery = null;
    HistoricProcessInstanceQuery historicProcessInstanceQuery = null;
    ExternalTaskQueryDto externalTaskQueryDto = retriesDto.getExternalTaskQuery();
    if (externalTaskQueryDto != null) {
        externalTaskQuery = externalTaskQueryDto.toQuery(getProcessEngine());
    }
    ProcessInstanceQueryDto processInstanceQueryDto = retriesDto.getProcessInstanceQuery();
    if (processInstanceQueryDto != null) {
        processInstanceQuery = processInstanceQueryDto.toQuery(getProcessEngine());
    }
    HistoricProcessInstanceQueryDto historicProcessInstanceQueryDto = retriesDto.getHistoricProcessInstanceQuery();
    if (historicProcessInstanceQueryDto != null) {
        historicProcessInstanceQuery = historicProcessInstanceQueryDto.toQuery(getProcessEngine());
    }
    return externalTaskService.updateRetries().externalTaskIds(externalTaskIds).processInstanceIds(processInstanceIds).externalTaskQuery(externalTaskQuery).processInstanceQuery(processInstanceQuery).historicProcessInstanceQuery(historicProcessInstanceQuery);
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ExternalTaskQueryDto(org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)

Example 2 with ExternalTaskQueryDto

use of org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto 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 ExternalTaskQueryDto

use of org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto 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

ExternalTaskQuery (org.camunda.bpm.engine.externaltask.ExternalTaskQuery)3 ExternalTaskQueryDto (org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto)3 HashMap (java.util.HashMap)2 ExternalTaskQueryImpl (org.camunda.bpm.engine.impl.ExternalTaskQueryImpl)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ExternalTaskService (org.camunda.bpm.engine.ExternalTaskService)1 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)1 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)1 ProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto)1 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)1