Search in sources :

Example 1 with HistoricCaseInstanceQuery

use of org.camunda.bpm.engine.history.HistoricCaseInstanceQuery in project camunda-bpm-platform by camunda.

the class HistoricCaseInstanceRestServiceImpl method queryHistoricCaseInstances.

public List<HistoricCaseInstanceDto> queryHistoricCaseInstances(HistoricCaseInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
    HistoricCaseInstanceQuery query = queryDto.toQuery(processEngine);
    List<HistoricCaseInstance> matchingHistoricCaseInstances;
    if (firstResult != null || maxResults != null) {
        matchingHistoricCaseInstances = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingHistoricCaseInstances = query.list();
    }
    List<HistoricCaseInstanceDto> historicCaseInstanceDtoResults = new ArrayList<HistoricCaseInstanceDto>();
    for (HistoricCaseInstance historicCaseInstance : matchingHistoricCaseInstances) {
        HistoricCaseInstanceDto resultHistoricCaseInstanceDto = HistoricCaseInstanceDto.fromHistoricCaseInstance(historicCaseInstance);
        historicCaseInstanceDtoResults.add(resultHistoricCaseInstanceDto);
    }
    return historicCaseInstanceDtoResults;
}
Also used : HistoricCaseInstanceDto(org.camunda.bpm.engine.rest.dto.history.HistoricCaseInstanceDto) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) ArrayList(java.util.ArrayList) HistoricCaseInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseInstanceQuery)

Example 2 with HistoricCaseInstanceQuery

use of org.camunda.bpm.engine.history.HistoricCaseInstanceQuery in project camunda-bpm-platform by camunda.

the class HistoricCaseInstanceRestServiceImpl method queryHistoricCaseInstancesCount.

public CountResultDto queryHistoricCaseInstancesCount(HistoricCaseInstanceQueryDto queryDto) {
    HistoricCaseInstanceQuery query = queryDto.toQuery(processEngine);
    long count = query.count();
    return new CountResultDto(count);
}
Also used : CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) HistoricCaseInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseInstanceQuery)

Example 3 with HistoricCaseInstanceQuery

use of org.camunda.bpm.engine.history.HistoricCaseInstanceQuery in project camunda-bpm-platform by camunda.

the class HistoricCaseInstanceRestServiceQueryTest method testCaseQueryNotClosed.

@Test
public void testCaseQueryNotClosed() {
    List<HistoricCaseInstance> mockedHistoricCaseInstances = MockProvider.createMockRunningHistoricCaseInstances();
    HistoricCaseInstanceQuery mockedHistoricCaseInstanceQuery = mock(HistoricCaseInstanceQuery.class);
    when(mockedHistoricCaseInstanceQuery.list()).thenReturn(mockedHistoricCaseInstances);
    when(processEngine.getHistoryService().createHistoricCaseInstanceQuery()).thenReturn(mockedHistoricCaseInstanceQuery);
    Response response = given().queryParam("notClosed", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL);
    InOrder inOrder = inOrder(mockedHistoricCaseInstanceQuery);
    inOrder.verify(mockedHistoricCaseInstanceQuery).notClosed();
    inOrder.verify(mockedHistoricCaseInstanceQuery).list();
    String content = response.asString();
    List<String> instances = from(content).getList("");
    Assert.assertEquals(1, instances.size());
    Assert.assertNotNull(instances.get(0));
    String returnedCaseInstanceId = from(content).getString("[0].id");
    String returnedCloseTime = from(content).getString("[0].closeTime");
    Assert.assertEquals(MockProvider.EXAMPLE_CASE_INSTANCE_ID, returnedCaseInstanceId);
    Assert.assertEquals(null, returnedCloseTime);
}
Also used : Response(com.jayway.restassured.response.Response) InOrder(org.mockito.InOrder) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) Matchers.containsString(org.hamcrest.Matchers.containsString) HistoricCaseInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseInstanceQuery) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 4 with HistoricCaseInstanceQuery

use of org.camunda.bpm.engine.history.HistoricCaseInstanceQuery in project camunda-bpm-platform by camunda.

the class HistoricCaseInstanceRestServiceQueryTest method setUpMockHistoricCaseInstanceQuery.

protected HistoricCaseInstanceQuery setUpMockHistoricCaseInstanceQuery(List<HistoricCaseInstance> mockedHistoricCaseInstances) {
    HistoricCaseInstanceQuery mockedHistoricCaseInstanceQuery = mock(HistoricCaseInstanceQuery.class);
    when(mockedHistoricCaseInstanceQuery.list()).thenReturn(mockedHistoricCaseInstances);
    when(mockedHistoricCaseInstanceQuery.count()).thenReturn((long) mockedHistoricCaseInstances.size());
    when(processEngine.getHistoryService().createHistoricCaseInstanceQuery()).thenReturn(mockedHistoricCaseInstanceQuery);
    return mockedHistoricCaseInstanceQuery;
}
Also used : HistoricCaseInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseInstanceQuery)

Example 5 with HistoricCaseInstanceQuery

use of org.camunda.bpm.engine.history.HistoricCaseInstanceQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyHistoricCaseInstanceQueryTest method testQueryByNonExistingTenantId.

public void testQueryByNonExistingTenantId() {
    HistoricCaseInstanceQuery query = historyService.createHistoricCaseInstanceQuery().tenantIdIn("nonExisting");
    assertThat(query.count(), is(0L));
}
Also used : HistoricCaseInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseInstanceQuery)

Aggregations

HistoricCaseInstanceQuery (org.camunda.bpm.engine.history.HistoricCaseInstanceQuery)26 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)7 Deployment (org.camunda.bpm.engine.test.Deployment)7 Response (com.jayway.restassured.response.Response)2 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Test (org.junit.Test)2 InOrder (org.mockito.InOrder)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 HistoricCaseInstanceDto (org.camunda.bpm.engine.rest.dto.history.HistoricCaseInstanceDto)1