Search in sources :

Example 1 with HistoricCaseActivityInstanceQuery

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

the class HistoricCaseActivityInstanceRestServiceImpl method queryHistoricCaseActivityInstances.

public List<HistoricCaseActivityInstanceDto> queryHistoricCaseActivityInstances(HistoricCaseActivityInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
    HistoricCaseActivityInstanceQuery query = queryDto.toQuery(processEngine);
    List<HistoricCaseActivityInstance> matchingHistoricCaseActivityInstances;
    if (firstResult != null || maxResults != null) {
        matchingHistoricCaseActivityInstances = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingHistoricCaseActivityInstances = query.list();
    }
    List<HistoricCaseActivityInstanceDto> historicCaseActivityInstanceResults = new ArrayList<HistoricCaseActivityInstanceDto>();
    for (HistoricCaseActivityInstance historicCaseActivityInstance : matchingHistoricCaseActivityInstances) {
        HistoricCaseActivityInstanceDto resultHistoricCaseActivityInstance = HistoricCaseActivityInstanceDto.fromHistoricCaseActivityInstance(historicCaseActivityInstance);
        historicCaseActivityInstanceResults.add(resultHistoricCaseActivityInstance);
    }
    return historicCaseActivityInstanceResults;
}
Also used : HistoricCaseActivityInstanceDto(org.camunda.bpm.engine.rest.dto.history.HistoricCaseActivityInstanceDto) ArrayList(java.util.ArrayList) HistoricCaseActivityInstance(org.camunda.bpm.engine.history.HistoricCaseActivityInstance) HistoricCaseActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery)

Example 2 with HistoricCaseActivityInstanceQuery

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

the class HistoricCaseActivityInstanceRestServiceImpl method queryHistoricCaseActivityInstancesCount.

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

Example 3 with HistoricCaseActivityInstanceQuery

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

the class HistoricCaseActivityInstanceRestServiceQueryTest method setUpMockHistoricCaseActivityInstanceQuery.

protected HistoricCaseActivityInstanceQuery setUpMockHistoricCaseActivityInstanceQuery(List<HistoricCaseActivityInstance> mockedHistoricCaseActivityInstances) {
    HistoricCaseActivityInstanceQuery mockedHistoricCaseActivityInstanceQuery = mock(HistoricCaseActivityInstanceQuery.class);
    when(mockedHistoricCaseActivityInstanceQuery.list()).thenReturn(mockedHistoricCaseActivityInstances);
    when(mockedHistoricCaseActivityInstanceQuery.count()).thenReturn((long) mockedHistoricCaseActivityInstances.size());
    when(processEngine.getHistoryService().createHistoricCaseActivityInstanceQuery()).thenReturn(mockedHistoricCaseActivityInstanceQuery);
    return mockedHistoricCaseActivityInstanceQuery;
}
Also used : HistoricCaseActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery)

Example 4 with HistoricCaseActivityInstanceQuery

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

the class HistoricCaseActivityInstanceRestServiceQueryTest method testUnfinishedHistoricCaseActivityQuery.

@Test
public void testUnfinishedHistoricCaseActivityQuery() {
    List<HistoricCaseActivityInstance> mockedHistoricCaseActivityInstances = MockProvider.createMockRunningHistoricCaseActivityInstances();
    HistoricCaseActivityInstanceQuery mockedHistoricCaseActivityInstanceQuery = mock(HistoricCaseActivityInstanceQuery.class);
    when(mockedHistoricCaseActivityInstanceQuery.list()).thenReturn(mockedHistoricCaseActivityInstances);
    when(processEngine.getHistoryService().createHistoricCaseActivityInstanceQuery()).thenReturn(mockedHistoricCaseActivityInstanceQuery);
    Response response = given().queryParam("unfinished", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(HISTORIC_CASE_ACTIVITY_INSTANCE_RESOURCE_URL);
    InOrder inOrder = inOrder(mockedHistoricCaseActivityInstanceQuery);
    inOrder.verify(mockedHistoricCaseActivityInstanceQuery).notEnded();
    inOrder.verify(mockedHistoricCaseActivityInstanceQuery).list();
    String content = response.asString();
    List<String> instances = from(content).getList("");
    Assert.assertEquals(1, instances.size());
    Assert.assertNotNull(instances.get(0));
    String returnedCaseDefinitionId = from(content).getString("[0].caseDefinitionId");
    String returnedActivityEndTime = from(content).getString("[0].endTime");
    Assert.assertEquals(MockProvider.EXAMPLE_CASE_DEFINITION_ID, returnedCaseDefinitionId);
    Assert.assertNull(returnedActivityEndTime);
}
Also used : Response(com.jayway.restassured.response.Response) InOrder(org.mockito.InOrder) HistoricCaseActivityInstance(org.camunda.bpm.engine.history.HistoricCaseActivityInstance) Matchers.containsString(org.hamcrest.Matchers.containsString) HistoricCaseActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 5 with HistoricCaseActivityInstanceQuery

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

the class MultiTenancyHistoricCaseActivityInstanceQueryTest method testQueryByTenantId.

public void testQueryByTenantId() {
    HistoricCaseActivityInstanceQuery query = historyService.createHistoricCaseActivityInstanceQuery().tenantIdIn(TENANT_ONE);
    assertThat(query.count(), is(1L));
    query = historyService.createHistoricCaseActivityInstanceQuery().tenantIdIn(TENANT_TWO);
    assertThat(query.count(), is(1L));
}
Also used : HistoricCaseActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery)

Aggregations

HistoricCaseActivityInstanceQuery (org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery)25 Deployment (org.camunda.bpm.engine.test.Deployment)11 HistoricCaseActivityInstance (org.camunda.bpm.engine.history.HistoricCaseActivityInstance)5 NotValidException (org.camunda.bpm.engine.exception.NotValidException)2 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)2 Response (com.jayway.restassured.response.Response)1 ArrayList (java.util.ArrayList)1 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 HistoricCaseActivityInstanceDto (org.camunda.bpm.engine.rest.dto.history.HistoricCaseActivityInstanceDto)1 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)1 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)1 Task (org.camunda.bpm.engine.task.Task)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1 InOrder (org.mockito.InOrder)1