use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery 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);
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceQueryTest method testInstanceRetrievalByListWithDuplicate.
@Test
public void testInstanceRetrievalByListWithDuplicate() {
List<ProcessInstance> mockProcessInstanceList = new ArrayList<ProcessInstance>();
mockProcessInstanceList.add(MockProvider.createMockInstance());
mockProcessInstanceList.add(MockProvider.createAnotherMockInstance());
ProcessInstanceQuery instanceQuery = mock(ProcessInstanceQuery.class);
when(instanceQuery.list()).thenReturn(mockProcessInstanceList);
when(processEngine.getRuntimeService().createProcessInstanceQuery()).thenReturn(instanceQuery);
Response response = given().queryParam("processInstanceIds", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID_LIST_WITH_DUP).then().expect().statusCode(Status.OK.getStatusCode()).when().get(PROCESS_INSTANCE_QUERY_URL);
// assert query invocation
InOrder inOrder = Mockito.inOrder(instanceQuery);
Set<String> expectedSet = MockProvider.createMockSetFromList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID_LIST);
inOrder.verify(instanceQuery).processInstanceIds(expectedSet);
inOrder.verify(instanceQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals("There should be two process definitions returned.", 2, instances.size());
String returnedInstanceId1 = from(content).getString("[0].id");
String returnedInstanceId2 = from(content).getString("[1].id");
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedInstanceId1);
Assert.assertEquals(MockProvider.ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID, returnedInstanceId2);
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceQueryTest method setUpMockInstanceQuery.
private ProcessInstanceQuery setUpMockInstanceQuery(List<ProcessInstance> mockedInstances) {
ProcessInstanceQuery sampleInstanceQuery = mock(ProcessInstanceQuery.class);
when(sampleInstanceQuery.list()).thenReturn(mockedInstances);
when(sampleInstanceQuery.count()).thenReturn((long) mockedInstances.size());
when(processEngine.getRuntimeService().createProcessInstanceQuery()).thenReturn(sampleInstanceQuery);
return sampleInstanceQuery;
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceQueryTest method testInstanceRetrievalByList.
@Test
public void testInstanceRetrievalByList() {
List<ProcessInstance> mockProcessInstanceList = new ArrayList<ProcessInstance>();
mockProcessInstanceList.add(MockProvider.createMockInstance());
mockProcessInstanceList.add(MockProvider.createAnotherMockInstance());
ProcessInstanceQuery instanceQuery = mock(ProcessInstanceQuery.class);
when(processEngine.getRuntimeService().createProcessInstanceQuery()).thenReturn(instanceQuery);
when(instanceQuery.list()).thenReturn(mockProcessInstanceList);
Response response = given().queryParam("processInstanceIds", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID_LIST).then().expect().statusCode(Status.OK.getStatusCode()).when().get(PROCESS_INSTANCE_QUERY_URL);
// assert query invocation
InOrder inOrder = Mockito.inOrder(instanceQuery);
Set<String> expectedSet = MockProvider.createMockSetFromList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID_LIST);
inOrder.verify(instanceQuery).processInstanceIds(expectedSet);
inOrder.verify(instanceQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals("There should be two process definitions returned.", 2, instances.size());
String returnedInstanceId1 = from(content).getString("[0].id");
String returnedInstanceId2 = from(content).getString("[1].id");
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedInstanceId1);
Assert.assertEquals(MockProvider.ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID, returnedInstanceId2);
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery 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);
}
Aggregations