Search in sources :

Example 1 with ProcessInstanceQueryImpl

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

the class MigrationRestServiceInteractionTest method verifyMigrationPlanExecutionProcessInstanceQuery.

protected void verifyMigrationPlanExecutionProcessInstanceQuery(InOrder inOrder) {
    ArgumentCaptor<ProcessInstanceQuery> queryCapture = ArgumentCaptor.forClass(ProcessInstanceQuery.class);
    inOrder.verify(migrationPlanExecutionBuilderMock).processInstanceQuery(queryCapture.capture());
    ProcessInstanceQueryImpl actualQuery = (ProcessInstanceQueryImpl) queryCapture.getValue();
    assertThat(actualQuery).isNotNull();
    assertThat(actualQuery.getProcessDefinitionId()).isEqualTo(EXAMPLE_PROCESS_DEFINITION_ID);
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl)

Example 2 with ProcessInstanceQueryImpl

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

the class ModificationRestServiceInteractionTest method executeModificationWithInvalidProcessInstanceQueryAsync.

@Test
public void executeModificationWithInvalidProcessInstanceQueryAsync() {
    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("acivityId").getJson());
    ProcessInstanceQueryDto processInstanceQueryDto = new ProcessInstanceQueryDto();
    processInstanceQueryDto.setBusinessKey("foo");
    json.put("processInstanceQuery", processInstanceQueryDto);
    json.put("instructions", instructions);
    json.put("processDefinitionId", "processDefinitionId");
    given().contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.OK.getStatusCode()).when().post(EXECUTE_MODIFICATION_ASYNC_URL);
}
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)

Example 3 with ProcessInstanceQueryImpl

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

the class ModificationRestServiceInteractionTest method executeModificationWithInvalidProcessInstanceQuerySync.

@Test
public void executeModificationWithInvalidProcessInstanceQuerySync() {
    when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl());
    Map<String, Object> json = new HashMap<String, Object>();
    String message = "Process instance ids is null";
    doThrow(new BadUserRequestException(message)).when(modificationBuilderMock).execute();
    List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
    instructions.add(ModificationInstructionBuilder.startAfter().activityId("acivityId").getJson());
    ProcessInstanceQueryDto processInstanceQueryDto = new ProcessInstanceQueryDto();
    processInstanceQueryDto.setBusinessKey("foo");
    json.put("processInstanceQuery", processInstanceQueryDto);
    json.put("instructions", instructions);
    json.put("processDefinitionId", "processDefinitionId");
    given().contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(EXECUTE_MODIFICATION_SYNC_URL);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 4 with ProcessInstanceQueryImpl

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

the class ModificationRestServiceInteractionTest method executeModificationWithValidProcessInstanceQueryAsync.

@Test
public void executeModificationWithValidProcessInstanceQueryAsync() {
    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());
    ProcessInstanceQueryDto processInstanceQueryDto = new ProcessInstanceQueryDto();
    processInstanceQueryDto.setBusinessKey("foo");
    json.put("processInstanceQuery", processInstanceQueryDto);
    json.put("instructions", instructions);
    json.put("processDefinitionId", "processDefinitionId");
    given().contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.OK.getStatusCode()).when().post(EXECUTE_MODIFICATION_ASYNC_URL);
    verify(runtimeServiceMock, times(1)).createProcessInstanceQuery();
    verify(modificationBuilderMock).startAfterActivity("activityId");
    verify(modificationBuilderMock).processInstanceQuery(processInstanceQueryDto.toQuery(processEngine));
    verify(modificationBuilderMock).executeAsync();
}
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)

Example 5 with ProcessInstanceQueryImpl

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

the class AbstractUpdateProcessInstancesSuspendStateCmd method collectProcessInstanceIds.

protected Collection<String> collectProcessInstanceIds() {
    HashSet<String> allProcessInstanceIds = new HashSet<String>();
    List<String> processInstanceIds = builder.getProcessInstanceIds();
    if (processInstanceIds != null) {
        allProcessInstanceIds.addAll(processInstanceIds);
    }
    ProcessInstanceQueryImpl processInstanceQuery = (ProcessInstanceQueryImpl) builder.getProcessInstanceQuery();
    if (processInstanceQuery != null) {
        allProcessInstanceIds.addAll(processInstanceQuery.listIds());
    }
    HistoricProcessInstanceQueryImpl historicProcessInstanceQuery = (HistoricProcessInstanceQueryImpl) builder.getHistoricProcessInstanceQuery();
    if (historicProcessInstanceQuery != null) {
        allProcessInstanceIds.addAll(historicProcessInstanceQuery.listIds());
    }
    return allProcessInstanceIds;
}
Also used : HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) HashSet(java.util.HashSet) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl)

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