Search in sources :

Example 41 with HistoricTaskInstanceQuery

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());
}
Also used : HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery)

Example 42 with HistoricTaskInstanceQuery

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());
}
Also used : HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 43 with HistoricTaskInstanceQuery

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());
}
Also used : HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 44 with HistoricTaskInstanceQuery

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());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 45 with HistoricTaskInstanceQuery

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());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricTaskInstanceQuery (org.camunda.bpm.engine.history.HistoricTaskInstanceQuery)55 Deployment (org.camunda.bpm.engine.test.Deployment)16 HistoricTaskInstance (org.camunda.bpm.engine.history.HistoricTaskInstance)9 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 Test (org.junit.Test)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)3 Task (org.camunda.bpm.engine.task.Task)3 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)2 ArrayList (java.util.ArrayList)1 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)1 CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 HistoricTaskInstanceDto (org.camunda.bpm.engine.rest.dto.history.HistoricTaskInstanceDto)1 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)1 Job (org.camunda.bpm.engine.runtime.Job)1 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)1