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);
}
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;
}
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));
}
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));
}
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));
}
Aggregations