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