Search in sources :

Example 11 with FilterEntity

use of org.camunda.bpm.engine.impl.persistence.entity.FilterEntity in project camunda-bpm-platform by camunda.

the class TaskQueryDisabledStoredExpressionsTest method testCannotExecuteStoredFilter.

public void testCannotExecuteStoredFilter() {
    final TaskQuery filterQuery = taskService.createTaskQuery().dueAfterExpression(STATE_MANIPULATING_EXPRESSION);
    // store a filter bypassing validation
    // the API way of doing this would be by reconfiguring the engine
    String filterId = processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<String>() {

        public String execute(CommandContext commandContext) {
            FilterEntity filter = new FilterEntity(EntityTypes.TASK);
            filter.setQuery(filterQuery);
            filter.setName("filter");
            commandContext.getDbEntityManager().insert(filter);
            return filter.getId();
        }
    });
    extendFilterAndValidateFailingQuery(filterId, null);
    // cleanup
    filterService.deleteFilter(filterId);
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) TaskQuery(org.camunda.bpm.engine.task.TaskQuery)

Example 12 with FilterEntity

use of org.camunda.bpm.engine.impl.persistence.entity.FilterEntity in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method testGetFilterWithVariableValueTypeSorting.

@Test
public void testGetFilterWithVariableValueTypeSorting() {
    TaskQuery query = new TaskQueryImpl().orderByExecutionVariable("foo", ValueType.STRING).asc().orderByExecutionVariable("foo", ValueType.INTEGER).asc().orderByExecutionVariable("foo", ValueType.SHORT).asc().orderByExecutionVariable("foo", ValueType.DATE).asc().orderByExecutionVariable("foo", ValueType.BOOLEAN).asc().orderByExecutionVariable("foo", ValueType.LONG).asc().orderByExecutionVariable("foo", ValueType.DOUBLE).asc();
    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(7);
    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_ASC_VALUE, "foo", ValueType.INTEGER);
    assertSorting(sortings.get(2), SORT_BY_EXECUTION_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.SHORT);
    assertSorting(sortings.get(3), SORT_BY_EXECUTION_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.DATE);
    assertSorting(sortings.get(4), SORT_BY_EXECUTION_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.BOOLEAN);
    assertSorting(sortings.get(5), SORT_BY_EXECUTION_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.LONG);
    assertSorting(sortings.get(6), SORT_BY_EXECUTION_VARIABLE, SORT_ORDER_ASC_VALUE, "foo", ValueType.DOUBLE);
}
Also used : Response(com.jayway.restassured.response.Response) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) MockProvider.mockFilter(org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.anyString(org.mockito.Matchers.anyString) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 13 with FilterEntity

use of org.camunda.bpm.engine.impl.persistence.entity.FilterEntity in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method testGetFilterWithoutTenantIdQuery.

@Test
public void testGetFilterWithoutTenantIdQuery() {
    TaskQueryImpl query = new TaskQueryImpl();
    query.withoutTenantId();
    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.withoutTenantId", is(true)).when().get(SINGLE_FILTER_URL);
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) MockProvider.mockFilter(org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) Test(org.junit.Test)

Example 14 with FilterEntity

use of org.camunda.bpm.engine.impl.persistence.entity.FilterEntity in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method testGetFilterWithFollowUpBeforeOrNotExistentExpression.

@Test
public void testGetFilterWithFollowUpBeforeOrNotExistentExpression() {
    TaskQueryImpl query = new TaskQueryImpl();
    query.followUpBeforeOrNotExistentExpression("#{now()}");
    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.followUpBeforeOrNotExistentExpression", equalTo("#{now()}")).when().get(SINGLE_FILTER_URL);
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) MockProvider.mockFilter(org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) Test(org.junit.Test)

Example 15 with FilterEntity

use of org.camunda.bpm.engine.impl.persistence.entity.FilterEntity in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method testGetFilterWithSingleSorting.

@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);
}
Also used : Response(com.jayway.restassured.response.Response) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) MockProvider.mockFilter(org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.anyString(org.mockito.Matchers.anyString) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

FilterEntity (org.camunda.bpm.engine.impl.persistence.entity.FilterEntity)16 Filter (org.camunda.bpm.engine.filter.Filter)14 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)12 MockProvider.mockFilter (org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter)12 Test (org.junit.Test)12 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)8 Response (com.jayway.restassured.response.Response)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)6 Matchers.anyString (org.mockito.Matchers.anyString)6 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)1 AbstractQuery (org.camunda.bpm.engine.impl.AbstractQuery)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1