Search in sources :

Example 36 with ExecutionQuery

use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.

the class ExecutionRestServiceInteractionTest method testGetNonExistingExecution.

@Test
public void testGetNonExistingExecution() {
    ExecutionQuery sampleExecutionQuery = mock(ExecutionQuery.class);
    when(runtimeServiceMock.createExecutionQuery()).thenReturn(sampleExecutionQuery);
    when(sampleExecutionQuery.executionId(anyString())).thenReturn(sampleExecutionQuery);
    when(sampleExecutionQuery.singleResult()).thenReturn(null);
    String nonExistingExecutionId = "aNonExistingInstanceId";
    given().pathParam("id", nonExistingExecutionId).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Execution with id " + nonExistingExecutionId + " does not exist")).when().get(EXECUTION_URL);
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) ExecutionQuery(org.camunda.bpm.engine.runtime.ExecutionQuery) Test(org.junit.Test)

Example 37 with ExecutionQuery

use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.

the class ExecutionRestServiceImpl method queryExecutions.

@Override
public List<ExecutionDto> queryExecutions(ExecutionQueryDto queryDto, Integer firstResult, Integer maxResults) {
    ProcessEngine engine = getProcessEngine();
    queryDto.setObjectMapper(getObjectMapper());
    ExecutionQuery query = queryDto.toQuery(engine);
    List<Execution> matchingExecutions;
    if (firstResult != null || maxResults != null) {
        matchingExecutions = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingExecutions = query.list();
    }
    List<ExecutionDto> executionResults = new ArrayList<ExecutionDto>();
    for (Execution execution : matchingExecutions) {
        ExecutionDto resultExecution = ExecutionDto.fromExecution(execution);
        executionResults.add(resultExecution);
    }
    return executionResults;
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) ArrayList(java.util.ArrayList) ExecutionDto(org.camunda.bpm.engine.rest.dto.runtime.ExecutionDto) ExecutionQuery(org.camunda.bpm.engine.runtime.ExecutionQuery) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 38 with ExecutionQuery

use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyExecutionQueryTest method testQueryAuthenticatedTenants.

public void testQueryAuthenticatedTenants() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO));
    ExecutionQuery query = runtimeService.createExecutionQuery();
    assertThat(query.count(), is(3L));
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
    assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L));
    assertThat(query.withoutTenantId().count(), is(1L));
}
Also used : ExecutionQuery(org.camunda.bpm.engine.runtime.ExecutionQuery)

Example 39 with ExecutionQuery

use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyExecutionQueryTest method testQueryByNonExistingTenantId.

public void testQueryByNonExistingTenantId() {
    ExecutionQuery query = runtimeService.createExecutionQuery().tenantIdIn("nonExisting");
    assertThat(query.count(), is(0L));
}
Also used : ExecutionQuery(org.camunda.bpm.engine.runtime.ExecutionQuery)

Example 40 with ExecutionQuery

use of org.camunda.bpm.engine.runtime.ExecutionQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyExecutionQueryTest method testQueryByTenantId.

public void testQueryByTenantId() {
    ExecutionQuery query = runtimeService.createExecutionQuery().tenantIdIn(TENANT_ONE);
    assertThat(query.count(), is(1L));
    query = runtimeService.createExecutionQuery().tenantIdIn(TENANT_TWO);
    assertThat(query.count(), is(1L));
}
Also used : ExecutionQuery(org.camunda.bpm.engine.runtime.ExecutionQuery)

Aggregations

ExecutionQuery (org.camunda.bpm.engine.runtime.ExecutionQuery)59 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)27 Deployment (org.camunda.bpm.engine.test.Deployment)26 Execution (org.camunda.bpm.engine.runtime.Execution)17 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)17 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)14 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)12 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)7 Job (org.camunda.bpm.engine.runtime.Job)6 Test (org.junit.Test)4 Date (java.util.Date)2 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 ExecutionDto (org.camunda.bpm.engine.rest.dto.runtime.ExecutionDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)1