Search in sources :

Example 6 with FilterEntity

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

the class FilterRestServiceInteractionTest method testGetFilterWithAllPropertiesSorting.

@Test
public void testGetFilterWithAllPropertiesSorting() {
    TaskQuery query = new TaskQueryImpl().orderByProcessInstanceId().asc().orderByCaseInstanceId().asc().orderByDueDate().asc().orderByFollowUpDate().asc().orderByExecutionId().asc().orderByCaseExecutionId().asc().orderByTaskAssignee().asc().orderByTaskCreateTime().asc().orderByTaskDescription().asc().orderByTaskId().asc().orderByTaskName().asc().orderByTaskNameCaseInsensitive().asc().orderByTaskPriority().asc().orderByTenantId().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(14);
    assertSorting(sortings.get(0), SORT_BY_PROCESS_INSTANCE_ID_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(1), SORT_BY_CASE_INSTANCE_ID_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(2), SORT_BY_DUE_DATE_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(3), SORT_BY_FOLLOW_UP_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(4), SORT_BY_EXECUTION_ID_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(5), SORT_BY_CASE_EXECUTION_ID_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(6), SORT_BY_ASSIGNEE_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(7), SORT_BY_CREATE_TIME_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(8), SORT_BY_DESCRIPTION_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(9), SORT_BY_ID_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(10), SORT_BY_NAME_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(11), SORT_BY_NAME_CASE_INSENSITIVE_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(12), SORT_BY_PRIORITY_VALUE, SORT_ORDER_ASC_VALUE);
    assertSorting(sortings.get(13), SORT_BY_TENANT_ID_VALUE, SORT_ORDER_ASC_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)

Example 7 with FilterEntity

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

the class FilterRestServiceInteractionTest method testGetFilterWithCandidateUserQuery.

@Test
public void testGetFilterWithCandidateUserQuery() {
    TaskQueryImpl query = new TaskQueryImpl();
    query.taskCandidateUser("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.candidateUser", equalTo("abc")).body("query.containsKey('candidateGroups')", is(false)).body("query.containsKey('includeAssignedTasks')", is(false)).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 8 with FilterEntity

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

the class FilterRestServiceInteractionTest method testGetFilterWithCandidateIncludeAssignedTasks.

@Test
public void testGetFilterWithCandidateIncludeAssignedTasks() {
    TaskQueryImpl query = new TaskQueryImpl();
    query.taskCandidateUser("abc").includeAssignedTasks();
    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.candidateUser", equalTo("abc")).body("query.containsKey('candidateGroups')", is(false)).body("query.includeAssignedTasks", 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 9 with FilterEntity

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

the class FilterAuthorizationsTest method testSaveFilterNotPermitted.

public void testSaveFilterNotPermitted() {
    Filter filter = new FilterEntity(EntityTypes.TASK);
    try {
        filterService.saveFilter(filter);
        fail("Exception expected");
    } catch (AuthorizationException e) {
    // expected
    }
}
Also used : Filter(org.camunda.bpm.engine.filter.Filter) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) AuthorizationException(org.camunda.bpm.engine.AuthorizationException)

Example 10 with FilterEntity

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

the class FilterAuthorizationsTest method testSaveFilterPermitted.

public void testSaveFilterPermitted() {
    Filter filter = new FilterEntity(EntityTypes.TASK).setName("testFilter");
    grantCreateFilter();
    filterService.saveFilter(filter);
    assertNotNull(filter.getId());
}
Also used : Filter(org.camunda.bpm.engine.filter.Filter) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity)

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