use of org.camunda.bpm.engine.filter.FilterQuery in project camunda-bpm-platform by camunda.
the class FilterQueryTest method testQueryPaging.
public void testQueryPaging() {
FilterQuery query = filterService.createFilterQuery();
assertEquals(4, query.listPage(0, Integer.MAX_VALUE).size());
// Verifying the un-paged results
assertEquals(4, query.count());
assertEquals(4, query.list().size());
// Verifying paged results
assertEquals(2, query.listPage(0, 2).size());
assertEquals(2, query.listPage(2, 2).size());
assertEquals(1, query.listPage(3, 1).size());
// Verifying odd usages
assertEquals(0, query.listPage(-1, -1).size());
// 4 is the last index with a result
assertEquals(0, query.listPage(4, 2).size());
// there are only 4 tasks
assertEquals(4, query.listPage(0, 15).size());
}
use of org.camunda.bpm.engine.filter.FilterQuery in project camunda-bpm-platform by camunda.
the class FilterQueryTest method testQueryByInvalidName.
public void testQueryByInvalidName() {
FilterQuery query = filterService.createFilterQuery().filterName("invalid");
assertNull(query.singleResult());
assertEquals(0, query.list().size());
assertEquals(0, query.count());
try {
filterService.createFilterQuery().filterName(null);
fail("Exception expected");
} catch (ProcessEngineException e) {
// expected
}
}
use of org.camunda.bpm.engine.filter.FilterQuery in project camunda-bpm-platform by camunda.
the class FilterQueryTest method testQueryByFilterId.
public void testQueryByFilterId() {
FilterQuery query = filterService.createFilterQuery().filterId(filterIds.get(0));
assertNotNull(query.singleResult());
assertEquals(1, query.list().size());
assertEquals(1, query.count());
}
use of org.camunda.bpm.engine.filter.FilterQuery in project camunda-bpm-platform by camunda.
the class ProcessEngineRestServiceTest method createFilterMock.
private void createFilterMock() {
List<Filter> filters = new ArrayList<Filter>();
Filter mockFilter = MockProvider.createMockFilter();
filters.add(mockFilter);
FilterQuery mockFilterQuery = mock(FilterQuery.class);
when(mockFilterQuery.list()).thenReturn(filters);
when(mockFilterService.createFilterQuery()).thenReturn(mockFilterQuery);
}
use of org.camunda.bpm.engine.filter.FilterQuery in project camunda-bpm-platform by camunda.
the class MockProvider method createMockFilterQuery.
public static FilterQuery createMockFilterQuery() {
List<Filter> mockFilters = createMockFilters();
FilterQuery query = mock(FilterQuery.class);
when(query.list()).thenReturn(mockFilters);
when(query.count()).thenReturn((long) mockFilters.size());
when(query.filterId(anyString())).thenReturn(query);
when(query.singleResult()).thenReturn(mockFilters.get(0));
FilterQuery nonExistingQuery = mock(FilterQuery.class);
when(query.filterId(NON_EXISTING_ID)).thenReturn(nonExistingQuery);
when(nonExistingQuery.singleResult()).thenReturn(null);
return query;
}
Aggregations