Search in sources :

Example 26 with HistoricProcessInstanceQuery

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

the class HistoricProcessInstanceTest method testEndTimeAndEndActivity.

@Deployment
public void testEndTimeAndEndActivity() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    String taskId = taskService.createTaskQuery().taskDefinitionKey("userTask2").singleResult().getId();
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    // when (1)
    taskService.complete(taskId);
    // then (1)
    HistoricProcessInstance historicProcessInstance = query.singleResult();
    assertNull(historicProcessInstance.getEndActivityId());
    assertNull(historicProcessInstance.getEndTime());
    // when (2)
    runtimeService.deleteProcessInstance(processInstanceId, null);
    // then (2)
    historicProcessInstance = query.singleResult();
    assertNull(historicProcessInstance.getEndActivityId());
    assertNotNull(historicProcessInstance.getEndTime());
}
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 27 with HistoricProcessInstanceQuery

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

the class HistoricProcessInstanceTest method testQueryByCaseInstanceId.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryByCaseInstanceId.cmmn", "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryByCaseInstanceId.bpmn20.xml" })
public void testQueryByCaseInstanceId() {
    // given
    String caseInstanceId = caseService.withCaseDefinitionByKey("case").create().getId();
    // then
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    query.caseInstanceId(caseInstanceId);
    assertEquals(1, query.count());
    assertEquals(1, query.list().size());
    HistoricProcessInstance historicProcessInstance = query.singleResult();
    assertNotNull(historicProcessInstance);
    assertNull(historicProcessInstance.getEndTime());
    assertEquals(caseInstanceId, historicProcessInstance.getCaseInstanceId());
    // complete existing user task -> completes the process instance
    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(1, query.count());
    assertEquals(1, query.list().size());
    historicProcessInstance = query.singleResult();
    assertNotNull(historicProcessInstance);
    assertNotNull(historicProcessInstance.getEndTime());
    assertEquals(caseInstanceId, historicProcessInstance.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 28 with HistoricProcessInstanceQuery

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

the class HistoricProcessInstanceTest method testQueryByInvalidSuperCaseInstanceId.

public void testQueryByInvalidSuperCaseInstanceId() {
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    query.superCaseInstanceId("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 29 with HistoricProcessInstanceQuery

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

the class HistoricProcessInstanceTest method testBusinessKey.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testBusinessKey.cmmn", "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testBusinessKey.bpmn20.xml" })
public void testBusinessKey() {
    // given
    String businessKey = "aBusinessKey";
    caseService.withCaseDefinitionByKey("case").businessKey(businessKey).create().getId();
    // then
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    query.processInstanceBusinessKey(businessKey);
    assertEquals(1, query.count());
    assertEquals(1, query.list().size());
    HistoricProcessInstance historicProcessInstance = query.singleResult();
    assertNotNull(historicProcessInstance);
    assertEquals(businessKey, historicProcessInstance.getBusinessKey());
}
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 30 with HistoricProcessInstanceQuery

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

the class HistoricProcessInstanceTest method testQueryByInvalidSubCaseInstanceId.

public void testQueryByInvalidSubCaseInstanceId() {
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    query.subCaseInstanceId("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)

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