Search in sources :

Example 6 with FilterQuery

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());
}
Also used : FilterQuery(org.camunda.bpm.engine.filter.FilterQuery)

Example 7 with FilterQuery

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
    }
}
Also used : FilterQuery(org.camunda.bpm.engine.filter.FilterQuery) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 8 with FilterQuery

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());
}
Also used : FilterQuery(org.camunda.bpm.engine.filter.FilterQuery)

Example 9 with FilterQuery

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);
}
Also used : Filter(org.camunda.bpm.engine.filter.Filter) ArrayList(java.util.ArrayList) FilterQuery(org.camunda.bpm.engine.filter.FilterQuery)

Example 10 with FilterQuery

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;
}
Also used : Filter(org.camunda.bpm.engine.filter.Filter) FilterQuery(org.camunda.bpm.engine.filter.FilterQuery)

Aggregations

FilterQuery (org.camunda.bpm.engine.filter.FilterQuery)15 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)6 Filter (org.camunda.bpm.engine.filter.Filter)3 ArrayList (java.util.ArrayList)2 FilterService (org.camunda.bpm.engine.FilterService)2 ProcessEngineConfiguration (org.camunda.bpm.engine.ProcessEngineConfiguration)1 TaskService (org.camunda.bpm.engine.TaskService)1 NullValueException (org.camunda.bpm.engine.exception.NullValueException)1 AuthorizationServiceImpl (org.camunda.bpm.engine.impl.AuthorizationServiceImpl)1 IdentityServiceImpl (org.camunda.bpm.engine.impl.IdentityServiceImpl)1 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)1 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)1 Query (org.camunda.bpm.engine.query.Query)1 FilterDto (org.camunda.bpm.engine.rest.dto.runtime.FilterDto)1 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)1 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)1 Before (org.junit.Before)1