Search in sources :

Example 46 with HistoricTaskInstanceQuery

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

the class HistoricTaskInstanceTest method testQueryByCaseDefinitionId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseDefinitionId() {
    // given
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
    String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    // then
    HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
    query.caseDefinitionId(caseDefinitionId);
    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 47 with HistoricTaskInstanceQuery

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

the class HistoricTaskInstanceTest method testQueryByCaseExecutionId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseExecutionId() {
    // 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.caseExecutionId(humanTaskId);
    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 48 with HistoricTaskInstanceQuery

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

the class HistoricTaskInstanceTest method testQueryByTaskDefinitionKeys.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByTaskDefinitionKeys() {
    // given
    runtimeService.startProcessInstanceByKey("oneTaskProcess");
    caseService.createCaseInstanceByKey("oneTaskCase");
    // when
    HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery().taskDefinitionKeyIn("theTask", "PI_HumanTask_1");
    // then
    assertEquals(2, query.count());
}
Also used : HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 49 with HistoricTaskInstanceQuery

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

the class HistoricTaskInstanceTest method testQueryByProcessInstanceBusinessKeyLike.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryByProcessInstanceBusinessKeyLike() {
    // given
    runtimeService.startProcessInstanceByKey("oneTaskProcess", "BUSINESS-KEY-1");
    HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
    // then
    assertEquals(1, query.processInstanceBusinessKeyLike("BUSINESS-KEY-1").list().size());
    assertEquals(1, query.processInstanceBusinessKeyLike("BUSINESS-KEY%").count());
    assertEquals(1, query.processInstanceBusinessKeyLike("%KEY-1").count());
    assertEquals(1, query.processInstanceBusinessKeyLike("%KEY%").count());
    assertEquals(0, query.processInstanceBusinessKeyLike("BUZINESS-KEY%").count());
}
Also used : HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 50 with HistoricTaskInstanceQuery

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

the class HistoricTaskInstanceTest method testQueryByInvalidCaseDefinitionName.

public void testQueryByInvalidCaseDefinitionName() {
    HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
    query.caseDefinitionName("invalid");
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());
    assertNull(query.singleResult());
    query.caseDefinitionName(null);
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());
    assertNull(query.singleResult());
}
Also used : HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery)

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