use of org.camunda.bpm.engine.batch.history.HistoricBatchQuery in project camunda-bpm-platform by camunda.
the class HistoricBatchRestServiceImpl method getHistoricBatchesCount.
@Override
public CountResultDto getHistoricBatchesCount(UriInfo uriInfo) {
HistoricBatchQueryDto queryDto = new HistoricBatchQueryDto(objectMapper, uriInfo.getQueryParameters());
HistoricBatchQuery query = queryDto.toQuery(processEngine);
long count = query.count();
return new CountResultDto(count);
}
use of org.camunda.bpm.engine.batch.history.HistoricBatchQuery in project camunda-bpm-platform by camunda.
the class HistoricBatchRestServiceInteractionTest method testGetNonExistingHistoricBatch.
@Test
public void testGetNonExistingHistoricBatch() {
String nonExistingId = MockProvider.NON_EXISTING_ID;
HistoricBatchQuery historicBatchQuery = mock(HistoricBatchQuery.class);
when(historicBatchQuery.batchId(nonExistingId)).thenReturn(historicBatchQuery);
when(historicBatchQuery.singleResult()).thenReturn(null);
when(historyServiceMock.createHistoricBatchQuery()).thenReturn(historicBatchQuery);
given().pathParam("id", nonExistingId).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Historic batch with id '" + nonExistingId + "' does not exist")).when().get(HISTORIC_SINGLE_BATCH_RESOURCE_URL);
}
use of org.camunda.bpm.engine.batch.history.HistoricBatchQuery in project camunda-bpm-platform by camunda.
the class HistoricBatchRestServiceImpl method getHistoricBatches.
@SuppressWarnings("unchecked")
@Override
public List<HistoricBatchDto> getHistoricBatches(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
HistoricBatchQueryDto queryDto = new HistoricBatchQueryDto(objectMapper, uriInfo.getQueryParameters());
HistoricBatchQuery query = queryDto.toQuery(processEngine);
List<HistoricBatch> matchingBatches;
if (firstResult != null || maxResults != null) {
matchingBatches = (List<HistoricBatch>) executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingBatches = query.list();
}
List<HistoricBatchDto> batchResults = new ArrayList<HistoricBatchDto>();
for (HistoricBatch matchingBatch : matchingBatches) {
batchResults.add(HistoricBatchDto.fromBatch(matchingBatch));
}
return batchResults;
}
Aggregations