当前位置: 首页>>代码示例>>Java>>正文


Java Filter类代码示例

本文整理汇总了Java中org.camunda.bpm.engine.filter.Filter的典型用法代码示例。如果您正苦于以下问题:Java Filter类的具体用法?Java Filter怎么用?Java Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Filter类属于org.camunda.bpm.engine.filter包,在下文中一共展示了Filter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: do_not_create_when_already_exist

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
@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);
  when(engine.getFilterService()).thenReturn(filterService);
  Filter filter = mock(Filter.class);

  FilterQuery filterQuery = CamundaMockito.mockFilterQuery(filterService).singleResult(filter);


  configuration.postProcessEngineBuild(engine);

  verify(filterService).createFilterQuery();
  verify(filterQuery).filterName("All");
  verify(filterService, never()).newTaskFilter("All");

}
 
开发者ID:camunda,项目名称:camunda-bpm-spring-boot-starter,代码行数:24,代码来源:CreateFilterConfigurationTest.java

示例2: testGetFilterWithVariableSortOrderSorting

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
@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);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:24,代码来源:FilterRestServiceInteractionTest.java

示例3: testHalTaskQueryWithWrongFormatVariablesProperties

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
@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();
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:22,代码来源:FilterRestServiceInteractionTest.java

示例4: insertOrUpdateFilter

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
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;
  }
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:18,代码来源:FilterManager.java

示例5: testExtendStoredFilterByExpression

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
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());
  }
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:19,代码来源:TaskQueryDisabledAdhocExpressionsTest.java

示例6: testExtendStoredFilterByScalar

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
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());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:19,代码来源:TaskQueryDisabledAdhocExpressionsTest.java

示例7: testUpdateFilterWithExpression

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
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());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:22,代码来源:TaskQueryDisabledStoredExpressionsTest.java

示例8: testNativeQuery

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
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());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:19,代码来源:FilterQueryTest.java

示例9: testHalTaskQueryWithEmptyVariablesProperties

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
@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();
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:23,代码来源:FilterRestServiceInteractionTest.java

示例10: testReadFilterPermittedWithMultiple

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
public void testReadFilterPermittedWithMultiple() {
  Filter filter = createTestFilter();

  grantReadFilter(filter.getId());
  Authorization authorization = processEngine.getAuthorizationService().createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
  authorization.addPermission(Permissions.READ);
  authorization.setUserId(Authorization.ANY);
  authorization.setResource(Resources.FILTER);
  authorization.setResourceId(Authorization.ANY);
  processEngine.getAuthorizationService().saveAuthorization(authorization);

  long count = filterService.createFilterQuery().count();
  assertEquals(1, count);

  Filter returnedFilter = filterService.createFilterQuery().filterId(filter.getId()).singleResult();
  assertNotNull(returnedFilter);

  returnedFilter = filterService.getFilter(filter.getId());
  assertNotNull(returnedFilter);

  processEngine.getAuthorizationService().deleteAuthorization(authorization.getId());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:23,代码来源:FilterAuthorizationsTest.java

示例11: testQueryFilter

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
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);
  }
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:FilterServiceTest.java

示例12: tearDown

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:22,代码来源:FilterTaskQueryTest.java

示例13: testTaskQueryByBusinessKeyExpression

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
public void testTaskQueryByBusinessKeyExpression() {
  // given
  String aBusinessKey = "business key";
  Mocks.register("aBusinessKey", aBusinessKey);

  createDeploymentWithBusinessKey(aBusinessKey);

  // when
  TaskQueryImpl extendedQuery = (TaskQueryImpl)taskService.createTaskQuery()
    .processInstanceBusinessKeyExpression("${ " + 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("processInstanceBusinessKey"),
    filterQuery.getExpressions().get("processInstanceBusinessKey"));
  assertEquals(1, filterService.list(filter.getId()).size());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:23,代码来源:FilterTaskQueryTest.java

示例14: testTaskQueryByBusinessKeyExpressionInAdhocQuery

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
public void testTaskQueryByBusinessKeyExpressionInAdhocQuery() {
  // given
  processEngineConfiguration.setEnableExpressionsInAdhocQueries(true);

  String aBusinessKey = "business key";
  Mocks.register("aBusinessKey", aBusinessKey);

  createDeploymentWithBusinessKey(aBusinessKey);

  // when
  Filter filter = filterService.newTaskFilter("aFilterName");
  filter.setQuery(taskService.createTaskQuery());
  filterService.saveFilter(filter);

  TaskQueryImpl extendingQuery = (TaskQueryImpl)taskService.createTaskQuery()
    .processInstanceBusinessKeyExpression("${ " + Mocks.getMocks().keySet().toArray()[0] + " }");

  // then
  assertEquals(extendingQuery.getExpressions().get("processInstanceBusinessKey"),
    "${ " + Mocks.getMocks().keySet().toArray()[0] + " }");
  assertEquals(1, filterService.list(filter.getId(), extendingQuery).size());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:23,代码来源:FilterTaskQueryTest.java

示例15: testTaskQueryByBusinessKeyLikeExpression

import org.camunda.bpm.engine.filter.Filter; //导入依赖的package包/类
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());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:23,代码来源:FilterTaskQueryTest.java


注:本文中的org.camunda.bpm.engine.filter.Filter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。