Search in sources :

Example 11 with ProcessInstanceQueryImpl

use of org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceInteractionTest method testSetRetriesForExternalTasksAsyncWithProcessInstanceQuery.

@Test
public void testSetRetriesForExternalTasksAsyncWithProcessInstanceQuery() {
    when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl());
    ProcessInstanceQueryDto processInstanceQuery = new ProcessInstanceQueryDto();
    processInstanceQuery.setProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID);
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("retries", "5");
    parameters.put("processInstanceQuery", processInstanceQuery);
    given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).then().expect().statusCode(Status.OK.getStatusCode()).when().post(RETRIES_EXTERNAL_TASKS_ASYNC_URL);
    ArgumentCaptor<ProcessInstanceQuery> queryCapture = ArgumentCaptor.forClass(ProcessInstanceQuery.class);
    verify(externalTaskService).updateRetries();
    verifyNoMoreInteractions(externalTaskService);
    verify(updateRetriesBuilder).externalTaskIds((List<String>) null);
    verify(updateRetriesBuilder).processInstanceIds((List<String>) null);
    verify(updateRetriesBuilder).externalTaskQuery(null);
    verify(updateRetriesBuilder).processInstanceQuery(queryCapture.capture());
    verify(updateRetriesBuilder).historicProcessInstanceQuery(null);
    verify(updateRetriesBuilder).setAsync(5);
    verifyNoMoreInteractions(updateRetriesBuilder);
    ProcessInstanceQueryImpl actualQuery = (ProcessInstanceQueryImpl) queryCapture.getValue();
    assertThat(actualQuery).isNotNull();
    assertThat(actualQuery.getProcessDefinitionId()).isEqualTo(EXAMPLE_PROCESS_DEFINITION_ID);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HashMap(java.util.HashMap) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 12 with ProcessInstanceQueryImpl

use of org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceInteractionTest method testSetRetriesWithProcessInstanceQuery.

@Test
public void testSetRetriesWithProcessInstanceQuery() {
    when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl());
    ProcessInstanceQueryDto processInstanceQuery = new ProcessInstanceQueryDto();
    processInstanceQuery.setProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID);
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("retries", "5");
    parameters.put("processInstanceQuery", processInstanceQuery);
    given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(RETRIES_EXTERNAL_TASK_SYNC_URL);
    ArgumentCaptor<ProcessInstanceQuery> queryCapture = ArgumentCaptor.forClass(ProcessInstanceQuery.class);
    verify(externalTaskService).updateRetries();
    verifyNoMoreInteractions(externalTaskService);
    verify(updateRetriesBuilder).externalTaskIds((List<String>) null);
    verify(updateRetriesBuilder).processInstanceIds((List<String>) null);
    verify(updateRetriesBuilder).externalTaskQuery(null);
    verify(updateRetriesBuilder).processInstanceQuery(queryCapture.capture());
    verify(updateRetriesBuilder).historicProcessInstanceQuery(null);
    verify(updateRetriesBuilder).set(5);
    verifyNoMoreInteractions(updateRetriesBuilder);
    ProcessInstanceQueryImpl actualQuery = (ProcessInstanceQueryImpl) queryCapture.getValue();
    assertThat(actualQuery).isNotNull();
    assertThat(actualQuery.getProcessDefinitionId()).isEqualTo(EXAMPLE_PROCESS_DEFINITION_ID);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HashMap(java.util.HashMap) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 13 with ProcessInstanceQueryImpl

use of org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.

the class AbstractSetProcessInstanceStateCmd method obtainProcessInstances.

protected List<ProcessInstance> obtainProcessInstances(CommandContext commandContext) {
    ProcessInstanceQueryImpl query = new ProcessInstanceQueryImpl();
    if (processInstanceId != null) {
        query.processInstanceId(processInstanceId);
    } else if (processDefinitionId != null) {
        query.processDefinitionId(processDefinitionId);
    } else if (isProcessDefinitionTenantIdSet) {
        query.processDefinitionKey(processDefinitionKey);
        if (processDefinitionTenantId != null) {
            query.tenantIdIn(processDefinitionTenantId);
        } else {
            query.withoutTenantId();
        }
    } else {
        query.processDefinitionKey(processDefinitionKey);
    }
    List<ProcessInstance> result = new ArrayList<ProcessInstance>();
    result.addAll(commandContext.getExecutionManager().findProcessInstancesByQueryCriteria(query, null));
    return result;
}
Also used : ArrayList(java.util.ArrayList) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl)

Example 14 with ProcessInstanceQueryImpl

use of org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.

the class DeleteProcessInstanceBatchCmd method collectProcessInstanceIds.

protected List<String> collectProcessInstanceIds() {
    Set<String> collectedProcessInstanceIds = new HashSet<String>();
    List<String> processInstanceIds = this.getProcessInstanceIds();
    if (processInstanceIds != null) {
        collectedProcessInstanceIds.addAll(processInstanceIds);
    }
    final ProcessInstanceQueryImpl processInstanceQuery = (ProcessInstanceQueryImpl) this.processInstanceQuery;
    if (processInstanceQuery != null) {
        collectedProcessInstanceIds.addAll(processInstanceQuery.listIds());
    }
    return new ArrayList<String>(collectedProcessInstanceIds);
}
Also used : ArrayList(java.util.ArrayList) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) HashSet(java.util.HashSet)

Example 15 with ProcessInstanceQueryImpl

use of org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.

the class ModificationRestServiceInteractionTest method executeModificationWithValidProcessInstanceQuerySync.

@Test
public void executeModificationWithValidProcessInstanceQuerySync() {
    when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl());
    Map<String, Object> json = new HashMap<String, Object>();
    List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
    instructions.add(ModificationInstructionBuilder.startAfter().activityId("activityId").getJson());
    json.put("processDefinitionId", "processDefinitionId");
    ProcessInstanceQueryDto processInstanceQueryDto = new ProcessInstanceQueryDto();
    processInstanceQueryDto.setBusinessKey("foo");
    json.put("processInstanceQuery", processInstanceQueryDto);
    json.put("instructions", instructions);
    given().contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(EXECUTE_MODIFICATION_SYNC_URL);
    verify(runtimeServiceMock, times(1)).createProcessInstanceQuery();
    verify(modificationBuilderMock).startAfterActivity("activityId");
    verify(modificationBuilderMock).processInstanceQuery(processInstanceQueryDto.toQuery(processEngine));
    verify(modificationBuilderMock).execute();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) Matchers.anyString(org.mockito.Matchers.anyString) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

ProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl)17 ProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto)8 Test (org.junit.Test)8 Matchers.anyString (org.mockito.Matchers.anyString)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)5 Map (java.util.Map)4 HistoricProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl)4 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)3 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)2 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)2 MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)2 List (java.util.List)1 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)1 Batch (org.camunda.bpm.engine.batch.Batch)1 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 MockProvider.createMockBatch (org.camunda.bpm.engine.rest.helper.MockProvider.createMockBatch)1 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1