Search in sources :

Example 56 with TaskQueryImpl

use of org.camunda.bpm.engine.impl.TaskQueryImpl 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 57 with TaskQueryImpl

use of org.camunda.bpm.engine.impl.TaskQueryImpl 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 58 with TaskQueryImpl

use of org.camunda.bpm.engine.impl.TaskQueryImpl 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)

Example 59 with TaskQueryImpl

use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method setUpRuntimeData.

@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(VariableInstanceQuery.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);
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) FilterQuery(org.camunda.bpm.engine.filter.FilterQuery) Query(org.camunda.bpm.engine.query.Query) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) IdentityServiceImpl(org.camunda.bpm.engine.impl.IdentityServiceImpl) TaskService(org.camunda.bpm.engine.TaskService) FilterService(org.camunda.bpm.engine.FilterService) FilterQuery(org.camunda.bpm.engine.filter.FilterQuery) NullValueException(org.camunda.bpm.engine.exception.NullValueException) ProcessEngineConfiguration(org.camunda.bpm.engine.ProcessEngineConfiguration) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) AuthorizationServiceImpl(org.camunda.bpm.engine.impl.AuthorizationServiceImpl) Before(org.junit.Before)

Example 60 with TaskQueryImpl

use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method testGetFilterWithoutSorting.

@Test
public void testGetFilterWithoutSorting() {
    TaskQuery query = new TaskQueryImpl();
    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.sorting", isEmptyOrNullString()).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) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) Test(org.junit.Test)

Aggregations

TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)60 Filter (org.camunda.bpm.engine.filter.Filter)26 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)25 Test (org.junit.Test)17 FilterEntity (org.camunda.bpm.engine.impl.persistence.entity.FilterEntity)12 MockProvider.mockFilter (org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter)12 QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)8 Map (java.util.Map)7 Response (com.jayway.restassured.response.Response)6 HashMap (java.util.HashMap)6 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)6 Matchers.anyString (org.mockito.Matchers.anyString)6 JSONObject (org.camunda.bpm.engine.impl.util.json.JSONObject)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Date (java.util.Date)3 TaskQueryVariableValue (org.camunda.bpm.engine.impl.TaskQueryVariableValue)3 JsonTaskQueryConverter (org.camunda.bpm.engine.impl.json.JsonTaskQueryConverter)3 ArrayList (java.util.ArrayList)2 JSONArray (org.camunda.bpm.engine.impl.util.json.JSONArray)2 VariableQueryParameterDto (org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto)2