org.camunda.bpm.engine.filter.Filter Java Examples

The following examples show how to use org.camunda.bpm.engine.filter.Filter. 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: FilterRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetFilterWithCandidateGroupQuery() {
  TaskQueryImpl query = new TaskQueryImpl();
  query.taskCandidateGroup("abc");
  Filter filter = new FilterEntity("Task").setName("test").setQuery(query);
  when(filterServiceMock.getFilter(EXAMPLE_FILTER_ID)).thenReturn(filter);

  given()
    .pathParam("id", EXAMPLE_FILTER_ID)
  .then().expect()
    .statusCode(Status.OK.getStatusCode())
    .body("query.candidateGroup", equalTo("abc"))
    .body("query.containsKey('candidateGroups')", is(false))
    .body("query.containsKey('includeAssignedTasks')", is(false))
  .when()
    .get(SINGLE_FILTER_URL);
}
 
Example #2
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * See CAM-9613
 */
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void FAILING_testShortVariable() {
  // given
  runtimeService.startProcessInstanceByKey("oneTaskProcess",
    Variables.createVariables().putValue("shortVariable", (short) 7));

  TaskQuery query = taskService.createTaskQuery()
    .processVariableValueEquals("shortVariable", (short) 7);

  Filter filter = filterService.newTaskFilter("filter");
  filter.setQuery(query);

  // when
  filterService.saveFilter(filter);

  // then
  assertThat(filterService.count(filter.getId()), is(1L));
}
 
Example #3
Source File: FilterRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testHalTaskQueryWithEmptyVariablesProperties() {
  // mock properties with variable name list in wrong format
  Map<String, Object> properties = new HashMap<String, Object>();
  properties.put("variables", Collections.emptyList());
  Filter filter =  mockFilter().properties(properties).build();
  when(filterServiceMock.getFilter(eq(EXAMPLE_FILTER_ID))).thenReturn(filter);

  given()
    .pathParam("id", EXAMPLE_FILTER_ID)
    .header(ACCEPT_HAL_HEADER)
  .expect()
    .statusCode(Status.OK.getStatusCode())
    .body("_embedded", equalTo(null))
  .when()
    .get(EXECUTE_SINGLE_RESULT_FILTER_URL);

  verify(filterServiceMock, times(1)).getFilter(eq(EXAMPLE_FILTER_ID));
  verify(variableInstanceQueryMock, never()).variableScopeIdIn((String) anyVararg());
  verify(variableInstanceQueryMock, never()).variableNameIn((String) anyVararg());
  verify(variableInstanceQueryMock, never()).list();
}
 
Example #4
Source File: FilterManager.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public Filter insertOrUpdateFilter(Filter filter) {

    AbstractQuery<?, ?> query = filter.getQuery();
    query.validate(StoredQueryValidator.get());

    if (filter.getId() == null) {
      checkAuthorization(CREATE, FILTER, ANY);
      getDbEntityManager().insert((FilterEntity) filter);
      createDefaultAuthorizations(filter);
    }
    else {
      checkAuthorization(UPDATE, FILTER, filter.getId());
      getDbEntityManager().merge((FilterEntity) filter);
    }

    return filter;
  }
 
Example #5
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testDoubleVariable() {
  // given
  runtimeService.startProcessInstanceByKey("oneTaskProcess",
    Variables.createVariables().putValue("doubleVariable", 88.89D));

  TaskQuery query = taskService.createTaskQuery()
    .processVariableValueEquals("doubleVariable", 88.89D);

  Filter filter = filterService.newTaskFilter("filter");
  filter.setQuery(query);

  // when
  filterService.saveFilter(filter);

  // then
  assertThat(filterService.count(filter.getId()), is(1L));
}
 
Example #6
Source File: CreateFilterConfigurationTest.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
@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 #7
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void tearDown() {
  processEngineConfiguration.setEnableExpressionsInAdhocQueries(false);

  Mocks.reset();

  for (Filter filter : filterService.createTaskFilterQuery().list()) {
    filterService.deleteFilter(filter.getId());
  }
  for (Group group : identityService.createGroupQuery().list()) {
    identityService.deleteGroup(group.getId());
  }
  for (User user : identityService.createUserQuery().list()) {
    identityService.deleteUser(user.getId());
  }
  for (Task task : taskService.createTaskQuery().list()) {
    if (task.getProcessInstanceId() == null) {
      taskService.deleteTask(task.getId(), true);
    }
  }
}
 
Example #8
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testExtendTaskQueryWithCandidateUserExpressionAndIncludeAssignedTasks() {
  // create an empty query and save it as a filter
  TaskQuery emptyQuery = taskService.createTaskQuery();
  Filter emptyFilter = filterService.newTaskFilter("empty");
  emptyFilter.setQuery(emptyQuery);

  // create a query with candidate user expression and include assigned tasks
  // and save it as filter
  TaskQuery query = taskService.createTaskQuery();
  query.taskCandidateUserExpression("${'test'}").includeAssignedTasks();
  Filter filter = filterService.newTaskFilter("filter");
  filter.setQuery(query);

  // extend empty query by query with candidate user expression and include assigned tasks
  Filter extendedFilter = emptyFilter.extend(query);
  TaskQueryImpl extendedQuery = extendedFilter.getQuery();
  assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateUser"));
  assertTrue(extendedQuery.isIncludeAssignedTasks());

  // extend query with candidate user expression and include assigned tasks with empty query
  extendedFilter = filter.extend(emptyQuery);
  extendedQuery = extendedFilter.getQuery();
  assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateUser"));
  assertTrue(extendedQuery.isIncludeAssignedTasks());
}
 
Example #9
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * See CAM-9613
 */
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void FAILING_testByteArrayVariable() {
  // given
  runtimeService.startProcessInstanceByKey("oneTaskProcess",
    Variables.createVariables().putValue("bytesVariable", "aByteArray".getBytes()));

  TaskQuery query = taskService.createTaskQuery()
    .processVariableValueEquals("bytesVariable", "aByteArray".getBytes());

  Filter filter = filterService.newTaskFilter("filter");
  filter.setQuery(query);

  // when
  filterService.saveFilter(filter);

  // then
  assertThat(filterService.count(filter.getId()), is(1L));
}
 
Example #10
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testIntOutOfRangeVariable() {
  // given
  runtimeService.startProcessInstanceByKey("oneTaskProcess",
    Variables.createVariables().putValue("longVariable", Integer.MAX_VALUE+1L));

  TaskQuery query = taskService.createTaskQuery()
    .processVariableValueEquals("longVariable", Integer.MAX_VALUE+1L);

  Filter filter = filterService.newTaskFilter("filter");
  filter.setQuery(query);

  // when
  filterService.saveFilter(filter);

  // then
  assertThat(filterService.count(filter.getId()), is(1L));
}
 
Example #11
Source File: FilterRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetFilterWithSingleSorting() {
  TaskQuery query = new TaskQueryImpl()
    .orderByTaskName().desc();

  Filter filter = new FilterEntity("Task").setName("test").setQuery(query);
  when(filterServiceMock.getFilter(EXAMPLE_FILTER_ID)).thenReturn(filter);

  Response response = given()
    .pathParam("id", EXAMPLE_FILTER_ID)
  .then().expect()
    .statusCode(Status.OK.getStatusCode())
  .when()
    .get(SINGLE_FILTER_URL);

  // validate sorting content
  String content = response.asString();
  List<Map<String, Object>> sortings = from(content).getJsonObject("query.sorting");
  assertThat(sortings).hasSize(1);
  assertSorting(sortings.get(0), SORT_BY_NAME_VALUE, SORT_ORDER_DESC_VALUE);
}
 
Example #12
Source File: FilterRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected Filter mockFilterWithVariableNames() {
  // mock properties with variable name list (names are ignored but variable names list must not be empty)
  List<Map<String, String>> variables = new ArrayList<Map<String, String>>();
  Map<String, String> foo = new HashMap<String, String>();
  foo.put("name", "foo");
  foo.put("label", "Foo");
  variables.add(foo);
  Map<String, String> bar = new HashMap<String, String>();
  bar.put("name", "bar");
  bar.put("label", "Bar");
  variables.add(bar);

  Map<String, Object> properties = new HashMap<String, Object>();
  properties.put("variables", variables);

  Filter filter = mockFilter().properties(properties).build();
  when(filterServiceMock.getFilter(eq(EXAMPLE_FILTER_ID))).thenReturn(filter);

  return filter;
}
 
Example #13
Source File: BoundedNumberOfMaxResultsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldThrowExceptionWhenFilterQueryList_MaxResultsLimitExceeded() {
  // given
  Filter foo = engineRule.getFilterService().newTaskFilter("foo");
  foo.setQuery(taskService.createTaskQuery());
  engineRule.getFilterService().saveFilter(foo);

  String filterId = engineRule.getFilterService()
      .createFilterQuery()
      .singleResult()
      .getId();

  try {
    // when
    engineRule.getFilterService().list(filterId);
    fail("Exception expected!");
  } catch (BadUserRequestException e) {
    // then
    assertThat(e).hasMessage("An unbound number of results is forbidden!");
  }

  // clear
  engineRule.getFilterService().deleteFilter(filterId);
}
 
Example #14
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testTaskQueryByBusinessKeyLikeExpression() {
  // given
  String aBusinessKey = "business key";
  Mocks.register("aBusinessKeyLike", "%" + aBusinessKey.substring(5));

  createDeploymentWithBusinessKey(aBusinessKey);

  // when
  TaskQueryImpl extendedQuery = (TaskQueryImpl)taskService.createTaskQuery()
    .processInstanceBusinessKeyLikeExpression("${ " + Mocks.getMocks().keySet().toArray()[0] + " }");

  Filter filter = filterService.newTaskFilter("aFilterName");
  filter.setQuery(extendedQuery);
  filterService.saveFilter(filter);

  TaskQueryImpl filterQuery = filterService.getFilter(filter.getId()).getQuery();

  // then
  assertEquals(extendedQuery.getExpressions().get("processInstanceBusinessKeyLike"),
    filterQuery.getExpressions().get("processInstanceBusinessKeyLike"));
  assertEquals(1, filterService.list(filter.getId()).size());
}
 
Example #15
Source File: MockProvider.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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 #16
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testExtendTaskQueryWithCandidateGroupInExpressionAndIncludeAssignedTasks() {
  // create an empty query and save it as a filter
  TaskQuery emptyQuery = taskService.createTaskQuery();
  Filter emptyFilter = filterService.newTaskFilter("empty");
  emptyFilter.setQuery(emptyQuery);

  // create a query with candidate group in expression and include assigned tasks
  // and save it as filter
  TaskQuery query = taskService.createTaskQuery();
  query.taskCandidateGroupInExpression("${'test'}").includeAssignedTasks();
  Filter filter = filterService.newTaskFilter("filter");
  filter.setQuery(query);

  // extend empty query by query with candidate group in expression and include assigned tasks
  Filter extendedFilter = emptyFilter.extend(query);
  TaskQueryImpl extendedQuery = extendedFilter.getQuery();
  assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateGroupIn"));
  assertTrue(extendedQuery.isIncludeAssignedTasks());

  // extend query with candidate group in expression and include assigned tasks with empty query
  extendedFilter = filter.extend(emptyQuery);
  extendedQuery = extendedFilter.getQuery();
  assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateGroupIn"));
  assertTrue(extendedQuery.isIncludeAssignedTasks());
}
 
Example #17
Source File: TaskQueryDisabledAdhocExpressionsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testExtendStoredFilterByExpression() {

    // given a stored filter
    TaskQuery taskQuery = taskService.createTaskQuery().dueAfterExpression("${now()}");
    Filter filter = filterService.newTaskFilter("filter");
    filter.setQuery(taskQuery);
    filterService.saveFilter(filter);

    // it is possible to execute the stored query with an expression
    assertEquals(new Long(0), filterService.count(filter.getId()));
    assertEquals(0, filterService.list(filter.getId()).size());

    // but it is not possible to executed the filter with an extended query that uses expressions
    extendFilterAndValidateFailingQuery(filter, taskService.createTaskQuery().dueAfterExpression(STATE_MANIPULATING_EXPRESSION));

    // cleanup
    filterService.deleteFilter(filter.getId());
  }
 
Example #18
Source File: TaskQueryDisabledAdhocExpressionsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testExtendStoredFilterByScalar() {
  // given a stored filter
  TaskQuery taskQuery = taskService.createTaskQuery().dueAfterExpression("${now()}");
  Filter filter = filterService.newTaskFilter("filter");
  filter.setQuery(taskQuery);
  filterService.saveFilter(filter);

  // it is possible to execute the stored query with an expression
  assertEquals(new Long(0), filterService.count(filter.getId()));
  assertEquals(0, filterService.list(filter.getId()).size());

  // and it is possible to extend the filter query when not using an expression
  assertEquals(new Long(0), filterService.count(filter.getId(), taskService.createTaskQuery().dueAfter(new Date())));
  assertEquals(0, filterService.list(filter.getId(), taskService.createTaskQuery().dueAfter(new Date())).size());

  // cleanup
  filterService.deleteFilter(filter.getId());
}
 
Example #19
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testDueDate() {
  // given
  Date date = new Date();
  String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId();

  Task task = taskService.createTaskQuery()
    .processInstanceId(processInstanceId)
    .singleResult();

  task.setDueDate(date);

  taskService.saveTask(task);

  TaskQuery query = taskService.createTaskQuery()
    .dueDate(date);

  Filter filter = filterService.newTaskFilter("filter");
  filter.setQuery(query);

  // when
  filterService.saveFilter(filter);

  // then
  assertThat(filterService.count(filter.getId()), is(1L));
}
 
Example #20
Source File: TaskQueryDisabledStoredExpressionsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testUpdateFilterWithExpression() {
  // given a stored filter
  TaskQuery taskQuery = taskService.createTaskQuery().dueAfter(new Date());
  Filter filter = filterService.newTaskFilter("filter");
  filter.setQuery(taskQuery);
  filterService.saveFilter(filter);

  // updating the filter with an expression does not suceed
  filter.setQuery(taskQuery.dueBeforeExpression(STATE_MANIPULATING_EXPRESSION));
  assertEquals(1, filterService.createFilterQuery().count());

  try {
    filterService.saveFilter(filter);
  } catch (ProcessEngineException e) {
    assertTextPresent(EXPECTED_STORED_QUERY_FAILURE_MESSAGE, e.getMessage());
  }
  assertTrue(fieldIsUnchanged());

  // cleanup
  filterService.deleteFilter(filter.getId());
}
 
Example #21
Source File: FilterQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testNativeQuery() {
  String tablePrefix = processEngineConfiguration.getDatabaseTablePrefix();
  assertEquals(tablePrefix + "ACT_RU_FILTER", managementService.getTableName(Filter.class));
  assertEquals(tablePrefix + "ACT_RU_FILTER", managementService.getTableName(FilterEntity.class));
  assertEquals(4, taskService.createNativeTaskQuery().sql("SELECT * FROM " + managementService.getTableName(Filter.class)).list().size());
  assertEquals(4, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM " + managementService.getTableName(Filter.class)).count());

  assertEquals(16, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM " + tablePrefix + "ACT_RU_FILTER F1, " + tablePrefix + "ACT_RU_FILTER F2").count());

  // select with distinct
  assertEquals(4, taskService.createNativeTaskQuery().sql("SELECT F1.* FROM "+ tablePrefix + "ACT_RU_FILTER F1").list().size());

  assertEquals(1, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM " + managementService.getTableName(Filter.class) + " F WHERE F.NAME_ = 'a'").count());
  assertEquals(1, taskService.createNativeTaskQuery().sql("SELECT * FROM " + managementService.getTableName(Filter.class) + " F WHERE F.NAME_ = 'a'").list().size());

  // use parameters
  assertEquals(1, taskService.createNativeTaskQuery().sql("SELECT count(*) FROM " + managementService.getTableName(Filter.class) + " F WHERE F.NAME_ = #{filterName}").parameter("filterName", "a").count());
}
 
Example #22
Source File: FilterRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetFilterWithVariableSortOrderSorting() {
  TaskQuery query = new TaskQueryImpl()
    .orderByExecutionVariable("foo", ValueType.STRING).asc()
    .orderByExecutionVariable("foo", ValueType.STRING).desc();

  Filter filter = new FilterEntity("Task").setName("test").setQuery(query);
  when(filterServiceMock.getFilter(EXAMPLE_FILTER_ID)).thenReturn(filter);

  Response response = given()
    .pathParam("id", EXAMPLE_FILTER_ID)
  .then().expect()
    .statusCode(Status.OK.getStatusCode())
  .when()
    .get(SINGLE_FILTER_URL);

  // validate sorting content
  String content = response.asString();
  List<Map<String, Object>> sortings = from(content).getJsonObject("query.sorting");
  assertThat(sortings).hasSize(2);
  assertSorting(sortings.get(0), SORT_BY_EXECUTION_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.STRING);
  assertSorting(sortings.get(1), SORT_BY_EXECUTION_VARIABLE, SORT_ORDER_DESC_VALUE, "foo", ValueType.STRING);
}
 
Example #23
Source File: FilterRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testHalTaskQueryWithWrongFormatVariablesProperties() {
  // mock properties with variable name list in wrong format
  Map<String, Object> properties = new HashMap<String, Object>();
  properties.put("variables", "foo");
  Filter filter =  mockFilter().properties(properties).build();
  when(filterServiceMock.getFilter(eq(EXAMPLE_FILTER_ID))).thenReturn(filter);

  given()
    .pathParam("id", EXAMPLE_FILTER_ID)
    .header(ACCEPT_HAL_HEADER)
  .expect()
    .statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode())
  .when()
    .get(EXECUTE_SINGLE_RESULT_FILTER_URL);

  verify(filterServiceMock, times(1)).getFilter(eq(EXAMPLE_FILTER_ID));
  verify(variableInstanceQueryMock, never()).variableScopeIdIn((String) anyVararg());
  verify(variableInstanceQueryMock, never()).variableNameIn((String) anyVararg());
  verify(variableInstanceQueryMock, never()).list();

}
 
Example #24
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testExtendTaskQueryWithCandidateGroupInAndCandidateGroup() {
  // create an query with candidate group in and save it as a filter
  TaskQueryImpl candidateGroupInQuery = (TaskQueryImpl)taskService.createTaskQuery().taskCandidateGroupIn(Arrays.asList("testGroup", "testGroup2"));
  assertEquals(2, candidateGroupInQuery.getCandidateGroups().size());
  assertEquals("testGroup", candidateGroupInQuery.getCandidateGroups().get(0));
  assertEquals("testGroup2", candidateGroupInQuery.getCandidateGroups().get(1));
  Filter candidateGroupInFilter = filterService.newTaskFilter("Groups filter");
  candidateGroupInFilter.setQuery(candidateGroupInQuery);

  // create a query with candidate group
  // and save it as filter
  TaskQuery candidateGroupQuery = taskService.createTaskQuery().taskCandidateGroup("testGroup2");

  // extend candidate group in filter by query with candidate group
  Filter extendedFilter = candidateGroupInFilter.extend(candidateGroupQuery);
  TaskQueryImpl extendedQuery = extendedFilter.getQuery();
  assertEquals(1, extendedQuery.getCandidateGroups().size());
  assertEquals("testGroup2", extendedQuery.getCandidateGroups().get(0));
}
 
Example #25
Source File: FilterAuthorizationsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * CAM-4889
 */
public void FAILING_testUpdateFilterGenericOwnerId() {
  grantCreateFilter();

  Filter filter = filterService.newTaskFilter("someName");
  filterService.saveFilter(filter);

  grantUpdateFilter(filter.getId());
  filter.setOwner("*");

  try {
    filterService.saveFilter(filter);
    fail("it should not be possible to save a filter with the generic owner id");
  } catch (ProcessEngineException e) {
    assertTextPresent("foo", e.getMessage());
  }
}
 
Example #26
Source File: FilterServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testQueryFilter() {

    Filter filter2 = filterService.createTaskFilterQuery()
      .filterId(filter.getId())
      .filterName("name")
      .filterOwner("owner")
      .singleResult();

    compareFilter(filter, filter2);

    filter2 = filterService.createTaskFilterQuery()
      .filterNameLike("%m%")
      .singleResult();

    compareFilter(filter, filter2);
  }
 
Example #27
Source File: BoundedNumberOfMaxResultsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldThrowExceptionWhenFilterQueryListPage_MaxResultsLimitExceeded() {
  // given
  Filter foo = engineRule.getFilterService().newTaskFilter("foo");
  foo.setQuery(taskService.createTaskQuery());
  engineRule.getFilterService().saveFilter(foo);

  String filterId = engineRule.getFilterService()
      .createFilterQuery()
      .singleResult()
      .getId();

  try {
    // when
    engineRule.getFilterService().listPage(filterId, 0, 11);
    fail("Exception expected!");
  } catch (BadUserRequestException e) {
    // then
    assertThat(e).hasMessage("Max results limit of 10 exceeded!");
  }

  // clear
  engineRule.getFilterService().deleteFilter(filterId);
}
 
Example #28
Source File: FilterQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void saveFilter(String name, String owner) {
  Filter filter = filterService.newTaskFilter()
    .setName(name)
    .setOwner(owner);
  filterService.saveFilter(filter);
  filterIds.add(filter.getId());
}
 
Example #29
Source File: FilterDto.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static FilterDto fromFilter(Filter filter) {
  FilterDto dto = new FilterDto();
  dto.id = filter.getId();
  dto.resourceType = filter.getResourceType();
  dto.name = filter.getName();
  dto.owner = filter.getOwner();

  if (EntityTypes.TASK.equals(filter.getResourceType())) {
    dto.query = TaskQueryDto.fromQuery(filter.getQuery());
  }

  dto.properties = filter.getProperties();
  return dto;
}
 
Example #30
Source File: FilterAuthorizationsTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testSaveFilterNotPermitted() {
  Filter filter = new FilterEntity(EntityTypes.TASK);
  try {
    filterService.saveFilter(filter);
    fail("Exception expected");
  }
  catch (AuthorizationException e) {
    // expected
  }
}