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);
}
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);
}
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;
}
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);
}
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();
}
Aggregations