use of org.camunda.bpm.engine.batch.BatchQuery in project camunda-bpm-platform by camunda.
the class BatchRestServiceImpl method getBatches.
public List<BatchDto> getBatches(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
BatchQueryDto queryDto = new BatchQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
BatchQuery query = queryDto.toQuery(getProcessEngine());
List<Batch> matchingBatches;
if (firstResult != null || maxResults != null) {
matchingBatches = executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingBatches = query.list();
}
List<BatchDto> batchResults = new ArrayList<BatchDto>();
for (Batch matchingBatch : matchingBatches) {
batchResults.add(BatchDto.fromBatch(matchingBatch));
}
return batchResults;
}
use of org.camunda.bpm.engine.batch.BatchQuery in project camunda-bpm-platform by camunda.
the class BatchRestServiceImpl method getBatchesCount.
public CountResultDto getBatchesCount(UriInfo uriInfo) {
ProcessEngine processEngine = getProcessEngine();
BatchQueryDto queryDto = new BatchQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
BatchQuery query = queryDto.toQuery(processEngine);
long count = query.count();
return new CountResultDto(count);
}
use of org.camunda.bpm.engine.batch.BatchQuery in project camunda-bpm-platform by camunda.
the class BatchQueryTest method testBatchQueryBySuspendedBatches.
@Test
public void testBatchQueryBySuspendedBatches() {
// given
Batch batch1 = helper.migrateProcessInstancesAsync(1);
Batch batch2 = helper.migrateProcessInstancesAsync(1);
helper.migrateProcessInstancesAsync(1);
// when
managementService.suspendBatchById(batch1.getId());
managementService.suspendBatchById(batch2.getId());
managementService.activateBatchById(batch1.getId());
// then
BatchQuery query = managementService.createBatchQuery().suspended();
Assert.assertEquals(1, query.count());
Assert.assertEquals(1, query.list().size());
Assert.assertEquals(batch2.getId(), query.singleResult().getId());
}
use of org.camunda.bpm.engine.batch.BatchQuery in project camunda-bpm-platform by camunda.
the class BatchRestServiceInteractionTest method testGetNonExistingBatch.
@Test
public void testGetNonExistingBatch() {
String nonExistingId = MockProvider.NON_EXISTING_ID;
BatchQuery batchQuery = mock(BatchQuery.class);
when(batchQuery.batchId(nonExistingId)).thenReturn(batchQuery);
when(batchQuery.singleResult()).thenReturn(null);
when(managementServiceMock.createBatchQuery()).thenReturn(batchQuery);
given().pathParam("id", nonExistingId).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Batch with id '" + nonExistingId + "' does not exist")).when().get(SINGLE_BATCH_RESOURCE_URL);
}
use of org.camunda.bpm.engine.batch.BatchQuery in project camunda-bpm-platform by camunda.
the class BatchQueryTest method testBatchQueryByActiveBatches.
@Test
public void testBatchQueryByActiveBatches() {
// given
Batch batch1 = helper.migrateProcessInstancesAsync(1);
Batch batch2 = helper.migrateProcessInstancesAsync(1);
Batch batch3 = helper.migrateProcessInstancesAsync(1);
// when
managementService.suspendBatchById(batch1.getId());
managementService.suspendBatchById(batch2.getId());
managementService.activateBatchById(batch1.getId());
// then
BatchQuery query = managementService.createBatchQuery().active();
Assert.assertEquals(2, query.count());
Assert.assertEquals(2, query.list().size());
List<String> foundIds = new ArrayList<String>();
for (Batch batch : query.list()) {
foundIds.add(batch.getId());
}
Assert.assertThat(foundIds, hasItems(batch1.getId(), batch3.getId()));
}
Aggregations