use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class CompleteProcessWithParallelGatewayAndServiceTaskTest method testQueryHistoricProcessWithParallelGateway.
@Test
@ScenarioUnderTest("init.async.complete.1")
public void testQueryHistoricProcessWithParallelGateway() {
// given an already started process instance
ProcessInstance oldInstance = rule.processInstance();
Assert.assertNotNull(oldInstance);
// with one completed user task
HistoricTaskInstanceQuery historicTaskQuery = rule.getHistoryService().createHistoricTaskInstanceQuery().processInstanceId(oldInstance.getId()).finished();
Assert.assertEquals(1, historicTaskQuery.count());
// and one async service task
Job job = rule.jobQuery().singleResult();
Assert.assertNotNull(job);
// when job is executed
rule.getManagementService().executeJob(job.getId());
// then there exists no more tasks
// and the process instance is also completed
Assert.assertEquals(0, rule.taskQuery().count());
rule.assertScenarioEnded();
}
use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class CompleteProcessWithParallelGatewayTest method testCompleteProcessWithParallelGatewayAndSingleUserTask.
@Test
@ScenarioUnderTest("init.complete.one.1")
public void testCompleteProcessWithParallelGatewayAndSingleUserTask() {
// given an already started process instance
ProcessInstance oldInstance = rule.processInstance();
Assert.assertNotNull(oldInstance);
// with one completed user task
HistoricTaskInstanceQuery historicTaskQuery = rule.getHistoryService().createHistoricTaskInstanceQuery().processInstanceId(oldInstance.getId()).finished();
Assert.assertEquals(1, historicTaskQuery.count());
// and one waiting
Task task = rule.taskQuery().singleResult();
Assert.assertNotNull(task);
// when completing the user task
rule.getTaskService().complete(task.getId());
// then there exists no more tasks
Assert.assertEquals(0, rule.taskQuery().count());
// and two historic tasks
Assert.assertEquals(2, historicTaskQuery.count());
// and the process instance is also completed
rule.assertScenarioEnded();
}
use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testQueryByInvalidCaseDefinitionId.
public void testQueryByInvalidCaseDefinitionId() {
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
query.caseDefinitionId("invalid");
assertEquals(0, query.count());
assertEquals(0, query.list().size());
assertNull(query.singleResult());
query.caseDefinitionId(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 testQueryByCaseInstanceIdHierarchy.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricTaskInstanceTest.testQueryByCaseInstanceIdHierarchy.cmmn", "org/camunda/bpm/engine/test/history/HistoricTaskInstanceTest.testQueryByCaseInstanceIdHierarchy.bpmn20.xml" })
public void testQueryByCaseInstanceIdHierarchy() {
// given
String caseInstanceId = caseService.withCaseDefinitionByKey("case").create().getId();
caseService.createCaseExecutionQuery().activityId("PI_ProcessTask_1").singleResult().getId();
// then
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
query.caseInstanceId(caseInstanceId);
assertEquals(2, query.count());
assertEquals(2, query.list().size());
for (HistoricTaskInstance task : query.list()) {
assertEquals(caseInstanceId, task.getCaseInstanceId());
assertNull(task.getCaseDefinitionId());
assertNull(task.getCaseExecutionId());
taskService.complete(task.getId());
}
assertEquals(3, query.count());
assertEquals(3, query.list().size());
for (HistoricTaskInstance task : query.list()) {
assertEquals(caseInstanceId, task.getCaseInstanceId());
assertNull(task.getCaseDefinitionId());
assertNull(task.getCaseExecutionId());
}
}
use of org.camunda.bpm.engine.history.HistoricTaskInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testQueryByCaseDefinitionKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseDefinitionKey() {
// 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.caseDefinitionKey(key);
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());
}
Aggregations