use of org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceRestServiceImpl method queryHistoricCaseActivityInstances.
public List<HistoricCaseActivityInstanceDto> queryHistoricCaseActivityInstances(HistoricCaseActivityInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
HistoricCaseActivityInstanceQuery query = queryDto.toQuery(processEngine);
List<HistoricCaseActivityInstance> matchingHistoricCaseActivityInstances;
if (firstResult != null || maxResults != null) {
matchingHistoricCaseActivityInstances = executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingHistoricCaseActivityInstances = query.list();
}
List<HistoricCaseActivityInstanceDto> historicCaseActivityInstanceResults = new ArrayList<HistoricCaseActivityInstanceDto>();
for (HistoricCaseActivityInstance historicCaseActivityInstance : matchingHistoricCaseActivityInstances) {
HistoricCaseActivityInstanceDto resultHistoricCaseActivityInstance = HistoricCaseActivityInstanceDto.fromHistoricCaseActivityInstance(historicCaseActivityInstance);
historicCaseActivityInstanceResults.add(resultHistoricCaseActivityInstance);
}
return historicCaseActivityInstanceResults;
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceRestServiceImpl method queryHistoricCaseActivityInstancesCount.
public CountResultDto queryHistoricCaseActivityInstancesCount(HistoricCaseActivityInstanceQueryDto queryDto) {
HistoricCaseActivityInstanceQuery query = queryDto.toQuery(processEngine);
long count = query.count();
return new CountResultDto(count);
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceRestServiceQueryTest method setUpMockHistoricCaseActivityInstanceQuery.
protected HistoricCaseActivityInstanceQuery setUpMockHistoricCaseActivityInstanceQuery(List<HistoricCaseActivityInstance> mockedHistoricCaseActivityInstances) {
HistoricCaseActivityInstanceQuery mockedHistoricCaseActivityInstanceQuery = mock(HistoricCaseActivityInstanceQuery.class);
when(mockedHistoricCaseActivityInstanceQuery.list()).thenReturn(mockedHistoricCaseActivityInstances);
when(mockedHistoricCaseActivityInstanceQuery.count()).thenReturn((long) mockedHistoricCaseActivityInstances.size());
when(processEngine.getHistoryService().createHistoricCaseActivityInstanceQuery()).thenReturn(mockedHistoricCaseActivityInstanceQuery);
return mockedHistoricCaseActivityInstanceQuery;
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceRestServiceQueryTest method testUnfinishedHistoricCaseActivityQuery.
@Test
public void testUnfinishedHistoricCaseActivityQuery() {
List<HistoricCaseActivityInstance> mockedHistoricCaseActivityInstances = MockProvider.createMockRunningHistoricCaseActivityInstances();
HistoricCaseActivityInstanceQuery mockedHistoricCaseActivityInstanceQuery = mock(HistoricCaseActivityInstanceQuery.class);
when(mockedHistoricCaseActivityInstanceQuery.list()).thenReturn(mockedHistoricCaseActivityInstances);
when(processEngine.getHistoryService().createHistoricCaseActivityInstanceQuery()).thenReturn(mockedHistoricCaseActivityInstanceQuery);
Response response = given().queryParam("unfinished", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(HISTORIC_CASE_ACTIVITY_INSTANCE_RESOURCE_URL);
InOrder inOrder = inOrder(mockedHistoricCaseActivityInstanceQuery);
inOrder.verify(mockedHistoricCaseActivityInstanceQuery).notEnded();
inOrder.verify(mockedHistoricCaseActivityInstanceQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals(1, instances.size());
Assert.assertNotNull(instances.get(0));
String returnedCaseDefinitionId = from(content).getString("[0].caseDefinitionId");
String returnedActivityEndTime = from(content).getString("[0].endTime");
Assert.assertEquals(MockProvider.EXAMPLE_CASE_DEFINITION_ID, returnedCaseDefinitionId);
Assert.assertNull(returnedActivityEndTime);
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class MultiTenancyHistoricCaseActivityInstanceQueryTest method testQueryByTenantId.
public void testQueryByTenantId() {
HistoricCaseActivityInstanceQuery query = historyService.createHistoricCaseActivityInstanceQuery().tenantIdIn(TENANT_ONE);
assertThat(query.count(), is(1L));
query = historyService.createHistoricCaseActivityInstanceQuery().tenantIdIn(TENANT_TWO);
assertThat(query.count(), is(1L));
}
Aggregations