Search in sources :

Example 21 with HistoricCaseActivityInstanceQuery

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

the class HistoricCaseActivityInstanceTest method testQueryByInvalidCaseActivityId.

public void testQueryByInvalidCaseActivityId() {
    // when
    HistoricCaseActivityInstanceQuery query = historicQuery().caseActivityIdIn("invalid");
    // then
    assertCount(0, query);
    try {
        historicQuery().caseActivityIdIn((String[]) null);
        fail("A NotValidException was expected.");
    } catch (NotValidException e) {
    }
    try {
        historicQuery().caseActivityIdIn((String) null);
        fail("A NotValidException was expected.");
    } catch (NotValidException e) {
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) HistoricCaseActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery)

Example 22 with HistoricCaseActivityInstanceQuery

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

the class HistoricCaseActivityInstanceTest method testQueryByInvalidCaseInstanceId.

public void testQueryByInvalidCaseInstanceId() {
    // when
    HistoricCaseActivityInstanceQuery query = historicQuery().caseActivityInstanceIdIn("invalid");
    // then
    assertCount(0, query);
    try {
        historicQuery().caseActivityInstanceIdIn((String[]) null);
        fail("A NotValidException was expected.");
    } catch (NotValidException e) {
    }
    try {
        historicQuery().caseActivityInstanceIdIn((String) null);
        fail("A NotValidException was expected.");
    } catch (NotValidException e) {
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) HistoricCaseActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery)

Example 23 with HistoricCaseActivityInstanceQuery

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

the class HistoricCaseActivityInstanceTest method testQueryByCaseInstanceId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseInstanceId() {
    // given
    createCaseInstance();
    String taskInstanceId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
    // when
    HistoricCaseActivityInstanceQuery query = historicQuery().caseActivityInstanceIdIn(taskInstanceId);
    // then
    assertCount(1, query);
}
Also used : HistoricCaseActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 24 with HistoricCaseActivityInstanceQuery

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

the class HistoricCaseActivityInstanceTest method testQuerySorting.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testQuerySorting() {
    String taskId1 = "PI_HumanTask_1";
    String taskId2 = "PI_HumanTask_2";
    String oneTaskCaseId = createCaseInstanceByKey("oneTaskCase").getId();
    String twoTaskCaseId = createCaseInstanceByKey("twoTaskCase").getId();
    CaseExecution task1 = caseService.createCaseExecutionQuery().caseInstanceId(oneTaskCaseId).activityId(taskId1).singleResult();
    CaseExecution task2 = caseService.createCaseExecutionQuery().caseInstanceId(twoTaskCaseId).activityId(taskId1).singleResult();
    CaseExecution task3 = caseService.createCaseExecutionQuery().caseInstanceId(twoTaskCaseId).activityId(taskId2).singleResult();
    // sort by historic case activity instance ids
    assertQuerySorting("id", historicQuery().orderByHistoricCaseActivityInstanceId(), task1.getId(), task2.getId(), task3.getId());
    // sort by case instance ids
    assertQuerySorting("caseInstanceId", historicQuery().orderByCaseInstanceId(), oneTaskCaseId, twoTaskCaseId, twoTaskCaseId);
    // sort by case execution ids
    assertQuerySorting("caseExecutionId", historicQuery().orderByCaseExecutionId(), task1.getId(), task2.getId(), task3.getId());
    // sort by case activity ids
    assertQuerySorting("caseActivityId", historicQuery().orderByCaseActivityId(), taskId1, taskId1, taskId2);
    // sort by case activity names
    assertQuerySorting("caseActivityName", historicQuery().orderByCaseActivityName(), "A HumanTask", "A HumanTask", "Another HumanTask");
    // sort by case definition ids
    assertQuerySorting("caseDefinitionId", historicQuery().orderByCaseDefinitionId(), task1.getCaseDefinitionId(), task2.getCaseDefinitionId(), task3.getCaseDefinitionId());
    // manually start tasks to be able to complete them
    manualStart(task2.getId());
    manualStart(task3.getId());
    // complete tasks to set end time and duration
    for (Task task : taskService.createTaskQuery().list()) {
        taskService.complete(task.getId());
    }
    HistoricCaseActivityInstanceQuery query = historyService.createHistoricCaseActivityInstanceQuery();
    HistoricCaseActivityInstance historicTask1 = query.caseInstanceId(oneTaskCaseId).caseActivityId(taskId1).singleResult();
    HistoricCaseActivityInstance historicTask2 = query.caseInstanceId(twoTaskCaseId).caseActivityId(taskId1).singleResult();
    HistoricCaseActivityInstance historicTask3 = query.caseInstanceId(twoTaskCaseId).caseActivityId(taskId2).singleResult();
    // sort by create times
    assertQuerySorting("createTime", historicQuery().orderByHistoricCaseActivityInstanceCreateTime(), historicTask1.getCreateTime(), historicTask2.getCreateTime(), historicTask3.getCreateTime());
    // sort by end times
    assertQuerySorting("endTime", historicQuery().orderByHistoricCaseActivityInstanceEndTime(), historicTask1.getEndTime(), historicTask2.getEndTime(), historicTask3.getEndTime());
    // sort by durations times
    assertQuerySorting("durationInMillis", historicQuery().orderByHistoricCaseActivityInstanceDuration(), historicTask1.getDurationInMillis(), historicTask2.getDurationInMillis(), historicTask3.getDurationInMillis());
}
Also used : Task(org.camunda.bpm.engine.task.Task) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) HistoricCaseActivityInstance(org.camunda.bpm.engine.history.HistoricCaseActivityInstance) HistoricCaseActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 25 with HistoricCaseActivityInstanceQuery

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

the class HistoricCaseActivityInstanceTest method testQueryByCaseActivityIds.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testQueryByCaseActivityIds() {
    // given
    createCaseInstanceByKey("oneTaskCase");
    createCaseInstanceByKey("twoTaskCase");
    // when
    HistoricCaseActivityInstanceQuery query = historicQuery().caseActivityIdIn("PI_HumanTask_1", "PI_HumanTask_2");
    // then
    assertCount(3, query);
}
Also used : HistoricCaseActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricCaseActivityInstanceQuery (org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery)25 Deployment (org.camunda.bpm.engine.test.Deployment)11 HistoricCaseActivityInstance (org.camunda.bpm.engine.history.HistoricCaseActivityInstance)5 NotValidException (org.camunda.bpm.engine.exception.NotValidException)2 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)2 Response (com.jayway.restassured.response.Response)1 ArrayList (java.util.ArrayList)1 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 HistoricCaseActivityInstanceDto (org.camunda.bpm.engine.rest.dto.history.HistoricCaseActivityInstanceDto)1 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)1 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)1 Task (org.camunda.bpm.engine.task.Task)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1 InOrder (org.mockito.InOrder)1