Search in sources :

Example 61 with HistoricProcessInstanceQuery

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

the class HistoricProcessInstanceTest method testQueryByCaseInstanceIdHierarchy.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryByCaseInstanceId.cmmn", "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryByCaseInstanceIdHierarchy-super.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryByCaseInstanceIdHierarchy-sub.bpmn20.xml" })
public void testQueryByCaseInstanceIdHierarchy() {
    // given
    String caseInstanceId = caseService.withCaseDefinitionByKey("case").create().getId();
    // then
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    query.caseInstanceId(caseInstanceId);
    assertEquals(2, query.count());
    assertEquals(2, query.list().size());
    for (HistoricProcessInstance hpi : query.list()) {
        assertEquals(caseInstanceId, hpi.getCaseInstanceId());
    }
    // complete existing user task -> completes the process instance(s)
    String taskId = taskService.createTaskQuery().caseInstanceId(caseInstanceId).singleResult().getId();
    taskService.complete(taskId);
    // the completed historic process instance is still associated with the
    // case instance id
    assertEquals(2, query.count());
    assertEquals(2, query.list().size());
    for (HistoricProcessInstance hpi : query.list()) {
        assertEquals(caseInstanceId, hpi.getCaseInstanceId());
    }
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 62 with HistoricProcessInstanceQuery

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

the class HistoricProcessInstanceTest method testQueryByInvalidCaseInstanceId.

public void testQueryByInvalidCaseInstanceId() {
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    query.caseInstanceId("invalid");
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());
    query.caseInstanceId(null);
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)

Example 63 with HistoricProcessInstanceQuery

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

the class HistoricProcessInstanceTest method testQueryBySuperCaseInstanceId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryBySuperCaseInstanceId() {
    String superCaseInstanceId = caseService.createCaseInstanceByKey("oneProcessTaskCase").getId();
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().superCaseInstanceId(superCaseInstanceId);
    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
    HistoricProcessInstance subProcessInstance = query.singleResult();
    assertNotNull(subProcessInstance);
    assertEquals(superCaseInstanceId, subProcessInstance.getSuperCaseInstanceId());
    assertNull(subProcessInstance.getSuperProcessInstanceId());
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 64 with HistoricProcessInstanceQuery

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

the class HistoricProcessInstanceTest method testQueryBySubCaseInstanceId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/superProcessWithCaseCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryBySubCaseInstanceId() {
    String superProcessInstanceId = runtimeService.startProcessInstanceByKey("subProcessQueryTest").getId();
    String subCaseInstanceId = caseService.createCaseInstanceQuery().superProcessInstanceId(superProcessInstanceId).singleResult().getId();
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().subCaseInstanceId(subCaseInstanceId);
    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
    HistoricProcessInstance superProcessInstance = query.singleResult();
    assertNotNull(superProcessInstance);
    assertEquals(superProcessInstanceId, superProcessInstance.getId());
    assertNull(superProcessInstance.getSuperCaseInstanceId());
    assertNull(superProcessInstance.getSuperProcessInstanceId());
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 65 with HistoricProcessInstanceQuery

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

the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessAsyncHistoricQueryBasedWithQuery.

@Test
public void testSetRetriesByProcessAsyncHistoricQueryBasedWithQuery() {
    Batch batchEntity = MockProvider.createMockBatch();
    when(mockManagementService.setJobRetriesAsync(anyListOf(String.class), eq((ProcessInstanceQuery) null), anyInt())).thenReturn(batchEntity);
    HistoricProcessInstanceQuery mockedHistoricProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(mockedHistoricProcessInstanceQuery);
    List<HistoricProcessInstance> historicProcessInstances = MockProvider.createMockRunningHistoricProcessInstances();
    when(mockedHistoricProcessInstanceQuery.list()).thenReturn(historicProcessInstances);
    SetJobRetriesByProcessDto body = new SetJobRetriesByProcessDto();
    body.setRetries(MockProvider.EXAMPLE_JOB_RETRIES);
    body.setHistoricProcessInstanceQuery(new HistoricProcessInstanceQueryDto());
    Response response = given().contentType(ContentType.JSON).body(body).then().expect().statusCode(Status.OK.getStatusCode()).when().post(SET_JOB_RETRIES_ASYNC_HIST_QUERY_URL);
    verifyBatchJson(response.asString());
    verify(mockManagementService, times(1)).setJobRetriesAsync(eq(Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID)), eq((ProcessInstanceQuery) null), eq(MockProvider.EXAMPLE_JOB_RETRIES));
}
Also used : Response(com.jayway.restassured.response.Response) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) Batch(org.camunda.bpm.engine.batch.Batch) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) SetJobRetriesByProcessDto(org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto) Test(org.junit.Test)

Aggregations

HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)71 Test (org.junit.Test)29 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)25 Batch (org.camunda.bpm.engine.batch.Batch)16 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)14 HashMap (java.util.HashMap)12 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)11 Deployment (org.camunda.bpm.engine.test.Deployment)11 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)10 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 Matchers.anyString (org.mockito.Matchers.anyString)8 ArrayList (java.util.ArrayList)7 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)7 Response (com.jayway.restassured.response.Response)6 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)6 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)6 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)4 HistoricProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl)4 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)4