org.camunda.bpm.engine.filter.FilterQuery Java Examples
The following examples show how to use
org.camunda.bpm.engine.filter.FilterQuery.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreateFilterConfigurationTest.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 6 votes |
@Test public void do_not_create_when_already_exist() throws Exception { CamundaBpmProperties camundaBpmProperties = new CamundaBpmProperties(); camundaBpmProperties.getFilter().setCreate("All"); final CreateFilterConfiguration configuration = new CreateFilterConfiguration(); ReflectionTestUtils.setField(configuration, "camundaBpmProperties", camundaBpmProperties); configuration.init(); ProcessEngine engine = mock(ProcessEngine.class); FilterService filterService = mock(FilterService.class); FilterQuery filterQuery = mock(FilterQuery.class); Filter filter = mock(Filter.class); when(engine.getFilterService()).thenReturn(filterService); when(filterService.createFilterQuery()).thenReturn(filterQuery); when(filterQuery.filterName(anyString())).thenReturn(filterQuery); when(filterQuery.singleResult()).thenReturn(filter); configuration.postProcessEngineBuild(engine); verify(filterService).createFilterQuery(); verify(filterQuery).filterName("All"); verify(filterService, never()).newTaskFilter("All"); }
Example #2
Source File: CreateFilterConfigurationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void do_not_create_when_already_exist() throws Exception { CamundaBpmProperties camundaBpmProperties = new CamundaBpmProperties(); camundaBpmProperties.getFilter().setCreate("All"); final CreateFilterConfiguration configuration = new CreateFilterConfiguration(); ReflectionTestUtils.setField(configuration, "camundaBpmProperties", camundaBpmProperties); configuration.init(); ProcessEngine engine = mock(ProcessEngine.class); FilterService filterService = mock(FilterService.class); FilterQuery filterQuery = mock(FilterQuery.class); Filter filter = mock(Filter.class); when(engine.getFilterService()).thenReturn(filterService); when(filterService.createFilterQuery()).thenReturn(filterQuery); when(filterQuery.filterName(anyString())).thenReturn(filterQuery); when(filterQuery.count()).thenReturn(1L); configuration.postProcessEngineBuild(engine); verifyLogs(Level.INFO, "the filter with this name already exists"); verify(filterService).createFilterQuery(); verify(filterQuery).filterName("All"); verify(filterService, never()).newTaskFilter("All"); }
Example #3
Source File: MockProvider.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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; }
Example #4
Source File: FilterRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public List<FilterDto> getFilters(UriInfo uriInfo, Boolean itemCount, Integer firstResult, Integer maxResults) { FilterService filterService = getProcessEngine().getFilterService(); FilterQuery query = getQueryFromQueryParameters(uriInfo.getQueryParameters()); List<Filter> matchingFilters = executeFilterQuery(query, firstResult, maxResults); List<FilterDto> filters = new ArrayList<FilterDto>(); for (Filter filter : matchingFilters) { FilterDto dto = FilterDto.fromFilter(filter); if (itemCount != null && itemCount) { dto.setItemCount(filterService.count(filter.getId())); } filters.add(dto); } return filters; }
Example #5
Source File: FilterQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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()); assertEquals(0, query.listPage(4, 2).size()); // 4 is the last index with a result assertEquals(4, query.listPage(0, 15).size()); // there are only 4 tasks }
Example #6
Source File: FilterQueryDto.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void applyFilters(FilterQuery query) { if (filterId != null) { query.filterId(filterId); } if (resourceType != null) { query.filterResourceType(resourceType); } if (name != null) { query.filterName(name); } if (nameLike != null) { query.filterNameLike(nameLike); } if (owner != null) { query.filterOwner(owner); } }
Example #7
Source File: FilterQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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 } }
Example #8
Source File: FilterQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testQueryByInvalidResourceType() { FilterQuery query = filterService.createFilterQuery().filterResourceType("invalid"); assertNull(query.singleResult()); assertEquals(0, query.list().size()); assertEquals(0, query.count()); try { filterService.createFilterQuery().filterResourceType(null); fail("Exception expected"); } catch (ProcessEngineException e) { // expected } }
Example #9
Source File: FilterQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testQueryByResourceType() { FilterQuery query = filterService.createFilterQuery().filterResourceType(EntityTypes.TASK); try { query.singleResult(); fail("Exception expected"); } catch (ProcessEngineException e) { // expected } assertEquals(4, query.list().size()); assertEquals(4, query.count()); }
Example #10
Source File: FilterQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testQueryByInvalidFilterId() { FilterQuery query = filterService.createFilterQuery().filterId("invalid"); assertNull(query.singleResult()); assertEquals(0, query.list().size()); assertEquals(0, query.count()); try { filterService.createFilterQuery().filterId(null); fail("Exception expected"); } catch (ProcessEngineException e) { // expected } }
Example #11
Source File: FilterQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testQueryNoCriteria() { FilterQuery query = filterService.createFilterQuery(); assertEquals(4, query.count()); assertEquals(4, query.list().size()); try { query.singleResult(); fail("Exception expected"); } catch (ProcessEngineException e) { // expected } }
Example #12
Source File: FilterQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testQueryByInvalidOwner() { FilterQuery query = filterService.createFilterQuery().filterOwner("invalid"); assertNull(query.singleResult()); assertEquals(0, query.list().size()); assertEquals(0, query.count()); try { filterService.createFilterQuery().filterOwner(null); fail("Exception expected"); } catch (ProcessEngineException e) { // expected } }
Example #13
Source File: FilterQueryDto.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected void applySortBy(FilterQuery query, String sortBy, Map<String, Object> parameters, ProcessEngine engine) { if (sortBy.equals(SORT_BY_ID_VALUE)) { query.orderByFilterId(); } else if (sortBy.equals(SORT_BY_RESOURCE_TYPE_VALUE)) { query.orderByFilterResourceType(); } else if (sortBy.equals(SORT_BY_NAME_VALUE)) { query.orderByFilterName(); } else if (sortBy.equals(SORT_BY_OWNER_VALUE)) { query.orderByFilterOwner(); } }
Example #14
Source File: FilterRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public List<Filter> executeFilterQuery(FilterQuery query, Integer firstResult, Integer maxResults) { if (firstResult != null || maxResults != null) { return executePaginatedQuery(query, firstResult, maxResults); } else { return query.list(); } }
Example #15
Source File: FilterRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected List<Filter> executePaginatedQuery(FilterQuery query, Integer firstResult, Integer maxResults) { if (firstResult == null) { firstResult = 0; } if (maxResults == null) { maxResults = Integer.MAX_VALUE; } return query.listPage(firstResult, maxResults); }
Example #16
Source File: ProcessEngineRestServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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); }
Example #17
Source File: FilterQueryDto.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected FilterQuery createNewQuery(ProcessEngine engine) { return engine.getFilterService().createFilterQuery(); }
Example #18
Source File: FilterQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void testQueryByOwner() { FilterQuery query = filterService.createFilterQuery().filterOwner("a"); assertNotNull(query.singleResult()); assertEquals(1, query.list().size()); assertEquals(1, query.count()); }
Example #19
Source File: FilterRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public CountResultDto getFiltersCount(UriInfo uriInfo) { FilterQuery query = getQueryFromQueryParameters(uriInfo.getQueryParameters()); return new CountResultDto(query.count()); }
Example #20
Source File: FilterRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected FilterQuery getQueryFromQueryParameters(MultivaluedMap<String, String> queryParameters) { ProcessEngine engine = getProcessEngine(); FilterQueryDto queryDto = new FilterQueryDto(getObjectMapper(), queryParameters); return queryDto.toQuery(engine); }
Example #21
Source File: FilterRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Before @SuppressWarnings("unchecked") public void setUpRuntimeData() { filterServiceMock = mock(FilterService.class); when(processEngine.getFilterService()).thenReturn(filterServiceMock); FilterQuery filterQuery = MockProvider.createMockFilterQuery(); when(filterServiceMock.createFilterQuery()).thenReturn(filterQuery); filterMock = MockProvider.createMockFilter(); when(filterServiceMock.newTaskFilter()).thenReturn(filterMock); when(filterServiceMock.saveFilter(eq(filterMock))).thenReturn(filterMock); when(filterServiceMock.getFilter(eq(EXAMPLE_FILTER_ID))).thenReturn(filterMock); when(filterServiceMock.getFilter(eq(MockProvider.NON_EXISTING_ID))).thenReturn(null); List<Object> mockTasks = Collections.<Object>singletonList(new TaskEntity()); when(filterServiceMock.singleResult(eq(EXAMPLE_FILTER_ID))) .thenReturn(mockTasks.get(0)); when(filterServiceMock.singleResult(eq(EXAMPLE_FILTER_ID), any(Query.class))) .thenReturn(mockTasks.get(0)); when(filterServiceMock.list(eq(EXAMPLE_FILTER_ID))) .thenReturn(mockTasks); when(filterServiceMock.list(eq(EXAMPLE_FILTER_ID), any(Query.class))) .thenReturn(mockTasks); when(filterServiceMock.listPage(eq(EXAMPLE_FILTER_ID), anyInt(), anyInt())) .thenReturn(mockTasks); when(filterServiceMock.listPage(eq(EXAMPLE_FILTER_ID), any(Query.class), anyInt(), anyInt())) .thenReturn(mockTasks); when(filterServiceMock.count(eq(EXAMPLE_FILTER_ID))) .thenReturn((long) 1); when(filterServiceMock.count(eq(EXAMPLE_FILTER_ID), any(Query.class))) .thenReturn((long) 1); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).singleResult(eq(MockProvider.NON_EXISTING_ID)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).singleResult(eq(MockProvider.NON_EXISTING_ID), any(Query.class)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).list(eq(MockProvider.NON_EXISTING_ID)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).list(eq(MockProvider.NON_EXISTING_ID), any(Query.class)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).listPage(eq(MockProvider.NON_EXISTING_ID), anyInt(), anyInt()); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).listPage(eq(MockProvider.NON_EXISTING_ID), any(Query.class), anyInt(), anyInt()); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).count(eq(MockProvider.NON_EXISTING_ID)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).count(eq(MockProvider.NON_EXISTING_ID), any(Query.class)); doThrow(new NullValueException("No filter found with given id")) .when(filterServiceMock).deleteFilter(eq(MockProvider.NON_EXISTING_ID)); authorizationServiceMock = mock(AuthorizationServiceImpl.class); identityServiceMock = mock(IdentityServiceImpl.class); processEngineConfigurationMock = mock(ProcessEngineConfiguration.class); when(processEngine.getAuthorizationService()).thenReturn(authorizationServiceMock); when(processEngine.getIdentityService()).thenReturn(identityServiceMock); when(processEngine.getProcessEngineConfiguration()).thenReturn(processEngineConfigurationMock); TaskService taskService = processEngine.getTaskService(); when(taskService.createTaskQuery()).thenReturn(new TaskQueryImpl()); variableInstanceQueryMock = mock(VariableInstanceQueryImpl.class); when(processEngine.getRuntimeService().createVariableInstanceQuery()) .thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.variableScopeIdIn((String) anyVararg())) .thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.variableNameIn((String) anyVararg())) .thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock); }
Example #22
Source File: FilterQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void testQueryByNameLike() { FilterQuery query = filterService.createFilterQuery().filterNameLike("%\\_"); assertNotNull(query.singleResult()); assertEquals(1, query.list().size()); assertEquals(1, query.count()); }
Example #23
Source File: FilterQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void testQueryByName() { FilterQuery query = filterService.createFilterQuery().filterName("a"); assertNotNull(query.singleResult()); assertEquals(1, query.list().size()); assertEquals(1, query.count()); }
Example #24
Source File: FilterQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void testQueryByFilterId() { FilterQuery query = filterService.createFilterQuery().filterId(filterIds.get(0)); assertNotNull(query.singleResult()); assertEquals(1, query.list().size()); assertEquals(1, query.count()); }
Example #25
Source File: FilterQueryImpl.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public FilterQuery orderByFilterOwner() { return orderBy(FilterQueryProperty.OWNER); }
Example #26
Source File: FilterQueryImpl.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public FilterQuery orderByFilterName() { return orderBy(FilterQueryProperty.NAME); }
Example #27
Source File: FilterQueryImpl.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public FilterQuery orderByFilterResourceType() { return orderBy(FilterQueryProperty.RESOURCE_TYPE); }
Example #28
Source File: FilterQueryImpl.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public FilterQuery orderByFilterId() { return orderBy(FilterQueryProperty.FILTER_ID); }
Example #29
Source File: FilterQueryImpl.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public FilterQuery filterOwner(String owner) { ensureNotNull("owner", owner); this.owner = owner; return this; }
Example #30
Source File: FilterQueryImpl.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public FilterQuery filterNameLike(String nameLike) { ensureNotNull("nameLike", nameLike); this.nameLike = nameLike; return this; }