use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testQueryByInvalidCaseDefinitionKey.
public void testQueryByInvalidCaseDefinitionKey() {
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
query.caseDefinitionKey("invalid");
assertEquals(0, query.count());
assertEquals(0, query.list().size());
assertNull(query.singleResult());
query.caseDefinitionKey(null);
assertEquals(0, query.count());
assertEquals(0, query.list().size());
assertNull(query.singleResult());
}
use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testQueryByCaseInstanceId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseInstanceId() {
// given
String key = "oneTaskCase";
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).singleResult().getId();
String caseInstanceId = caseService.withCaseDefinitionByKey(key).create().getId();
String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
// then
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
query.caseInstanceId(caseInstanceId);
assertEquals(1, query.count());
assertEquals(1, query.list().size());
assertNotNull(query.singleResult());
HistoricTaskInstance task = query.singleResult();
assertNotNull(task);
assertEquals(caseDefinitionId, task.getCaseDefinitionId());
assertEquals(caseInstanceId, task.getCaseInstanceId());
assertEquals(humanTaskId, task.getCaseExecutionId());
}
use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testQueryByCaseDefinitionName.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseDefinitionName() {
// given
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
String caseDefinitionName = caseDefinition.getName();
String caseDefinitionId = caseDefinition.getId();
String caseInstanceId = caseService.withCaseDefinitionByKey("oneTaskCase").create().getId();
String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
// then
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
query.caseDefinitionName(caseDefinitionName);
assertEquals(1, query.count());
assertEquals(1, query.list().size());
assertNotNull(query.singleResult());
HistoricTaskInstance task = query.singleResult();
assertNotNull(task);
assertEquals(caseDefinitionId, task.getCaseDefinitionId());
assertEquals(caseInstanceId, task.getCaseInstanceId());
assertEquals(humanTaskId, task.getCaseExecutionId());
}
use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testHistoricTaskInstanceQueryByActivityInstanceIds.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricTaskInstanceTest.testHistoricTaskInstance.bpmn20.xml" })
public void testHistoricTaskInstanceQueryByActivityInstanceIds() throws Exception {
ProcessInstance pi1 = runtimeService.startProcessInstanceByKey("HistoricTaskInstanceTest");
ProcessInstance pi2 = runtimeService.startProcessInstanceByKey("HistoricTaskInstanceTest");
String activityInstanceId1 = historyService.createHistoricActivityInstanceQuery().processInstanceId(pi1.getId()).activityId("task").singleResult().getId();
String activityInstanceId2 = historyService.createHistoricActivityInstanceQuery().processInstanceId(pi2.getId()).activityId("task").singleResult().getId();
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery().activityInstanceIdIn(activityInstanceId1, activityInstanceId2);
assertEquals(2, query.count());
assertEquals(2, query.list().size());
}
use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testQueryByProcessInstanceBusinessKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryByProcessInstanceBusinessKey() {
// given
ProcessInstance piBusinessKey1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", "BUSINESS-KEY-1");
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
// then
assertEquals(1, query.processInstanceBusinessKey(piBusinessKey1.getBusinessKey()).count());
assertEquals(0, query.processInstanceBusinessKey("unexistingBusinessKey").count());
}
Aggregations