use of org.camunda.bpm.engine.history.HistoricCaseInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceRestServiceImpl method queryHistoricCaseInstances.
public List<HistoricCaseInstanceDto> queryHistoricCaseInstances(HistoricCaseInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
HistoricCaseInstanceQuery query = queryDto.toQuery(processEngine);
List<HistoricCaseInstance> matchingHistoricCaseInstances;
if (firstResult != null || maxResults != null) {
matchingHistoricCaseInstances = executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingHistoricCaseInstances = query.list();
}
List<HistoricCaseInstanceDto> historicCaseInstanceDtoResults = new ArrayList<HistoricCaseInstanceDto>();
for (HistoricCaseInstance historicCaseInstance : matchingHistoricCaseInstances) {
HistoricCaseInstanceDto resultHistoricCaseInstanceDto = HistoricCaseInstanceDto.fromHistoricCaseInstance(historicCaseInstance);
historicCaseInstanceDtoResults.add(resultHistoricCaseInstanceDto);
}
return historicCaseInstanceDtoResults;
}
use of org.camunda.bpm.engine.history.HistoricCaseInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceRestServiceImpl method queryHistoricCaseInstancesCount.
public CountResultDto queryHistoricCaseInstancesCount(HistoricCaseInstanceQueryDto queryDto) {
HistoricCaseInstanceQuery query = queryDto.toQuery(processEngine);
long count = query.count();
return new CountResultDto(count);
}
use of org.camunda.bpm.engine.history.HistoricCaseInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceRestServiceQueryTest method testCaseQueryNotClosed.
@Test
public void testCaseQueryNotClosed() {
List<HistoricCaseInstance> mockedHistoricCaseInstances = MockProvider.createMockRunningHistoricCaseInstances();
HistoricCaseInstanceQuery mockedHistoricCaseInstanceQuery = mock(HistoricCaseInstanceQuery.class);
when(mockedHistoricCaseInstanceQuery.list()).thenReturn(mockedHistoricCaseInstances);
when(processEngine.getHistoryService().createHistoricCaseInstanceQuery()).thenReturn(mockedHistoricCaseInstanceQuery);
Response response = given().queryParam("notClosed", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL);
InOrder inOrder = inOrder(mockedHistoricCaseInstanceQuery);
inOrder.verify(mockedHistoricCaseInstanceQuery).notClosed();
inOrder.verify(mockedHistoricCaseInstanceQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals(1, instances.size());
Assert.assertNotNull(instances.get(0));
String returnedCaseInstanceId = from(content).getString("[0].id");
String returnedCloseTime = from(content).getString("[0].closeTime");
Assert.assertEquals(MockProvider.EXAMPLE_CASE_INSTANCE_ID, returnedCaseInstanceId);
Assert.assertEquals(null, returnedCloseTime);
}
use of org.camunda.bpm.engine.history.HistoricCaseInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceRestServiceQueryTest method setUpMockHistoricCaseInstanceQuery.
protected HistoricCaseInstanceQuery setUpMockHistoricCaseInstanceQuery(List<HistoricCaseInstance> mockedHistoricCaseInstances) {
HistoricCaseInstanceQuery mockedHistoricCaseInstanceQuery = mock(HistoricCaseInstanceQuery.class);
when(mockedHistoricCaseInstanceQuery.list()).thenReturn(mockedHistoricCaseInstances);
when(mockedHistoricCaseInstanceQuery.count()).thenReturn((long) mockedHistoricCaseInstances.size());
when(processEngine.getHistoryService().createHistoricCaseInstanceQuery()).thenReturn(mockedHistoricCaseInstanceQuery);
return mockedHistoricCaseInstanceQuery;
}
use of org.camunda.bpm.engine.history.HistoricCaseInstanceQuery in project camunda-bpm-platform by camunda.
the class MultiTenancyHistoricCaseInstanceQueryTest method testQueryByNonExistingTenantId.
public void testQueryByNonExistingTenantId() {
HistoricCaseInstanceQuery query = historyService.createHistoricCaseInstanceQuery().tenantIdIn("nonExisting");
assertThat(query.count(), is(0L));
}
Aggregations