Search in sources :

Example 61 with UserOperationLogQuery

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

the class UserOperationLogTaskServiceAndBeanTest method testCaseInstanceId.

public void testCaseInstanceId() {
    // create new task
    task = taskService.newTask();
    taskService.saveTask(task);
    UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_UPDATE);
    assertEquals(0, query.count());
    // set case instance id and save task
    task.setCaseInstanceId("aCaseInstanceId");
    taskService.saveTask(task);
    assertEquals(1, query.count());
    UserOperationLogEntry entry = query.singleResult();
    assertNotNull(entry);
    assertNull(entry.getOrgValue());
    assertEquals("aCaseInstanceId", entry.getNewValue());
    assertEquals(CASE_INSTANCE_ID, entry.getProperty());
    // change case instance id and save task
    task.setCaseInstanceId("anotherCaseInstanceId");
    taskService.saveTask(task);
    assertEquals(2, query.count());
    List<UserOperationLogEntry> entries = query.list();
    assertEquals(2, entries.size());
    for (UserOperationLogEntry currentEntry : entries) {
        if (!currentEntry.getId().equals(entry.getId())) {
            assertEquals("aCaseInstanceId", currentEntry.getOrgValue());
            assertEquals("anotherCaseInstanceId", currentEntry.getNewValue());
            assertEquals(CASE_INSTANCE_ID, currentEntry.getProperty());
        }
    }
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery)

Example 62 with UserOperationLogQuery

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

the class UserOperationLogTaskServiceAndBeanTest method testCompositeBeanInteraction.

public void testCompositeBeanInteraction() {
    // given: a manually created task
    task = taskService.newTask();
    // then: save the task without any property change
    taskService.saveTask(task);
    // expect: no entry
    UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_CREATE);
    UserOperationLogEntry create = query.singleResult();
    assertNotNull(create);
    assertEquals(ENTITY_TYPE_TASK, create.getEntityType());
    assertNull(create.getOrgValue());
    assertNull(create.getNewValue());
    assertNull(create.getProperty());
    task.setAssignee("icke");
    task.setName("to do");
    // then: save the task again
    taskService.saveTask(task);
    // expect: two update entries with the same operation id
    List<UserOperationLogEntry> entries = queryOperationDetails(OPERATION_TYPE_UPDATE).list();
    assertEquals(2, entries.size());
    assertEquals(entries.get(0).getOperationId(), entries.get(1).getOperationId());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery)

Example 63 with UserOperationLogQuery

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

the class UserOperationLogWithoutUserTest method verifyNoUserOperationLogged.

protected void verifyNoUserOperationLogged() {
    UserOperationLogQuery query = historyService.createUserOperationLogQuery();
    assertEquals(0, query.count());
}
Also used : UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery)

Example 64 with UserOperationLogQuery

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

the class UserOperationLogDeletionTest method testDeleteCaseTaskKeepUserOperationLog.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testDeleteCaseTaskKeepUserOperationLog() {
    // given
    caseService.withCaseDefinitionByKey("oneTaskCase").create();
    String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    String taskId = taskService.createTaskQuery().singleResult().getId();
    taskService.setAssignee(taskId, "demo");
    taskService.complete(taskId);
    UserOperationLogQuery query = historyService.createUserOperationLogQuery().taskId(taskId);
    assertEquals(2, query.count());
    // when
    historyService.deleteHistoricTaskInstance(taskId);
    // then
    assertEquals(2, query.count());
}
Also used : UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 65 with UserOperationLogQuery

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

the class UserOperationLogDeletionTest method testDeleteStandaloneTaskKeepUserOperationLog.

public void testDeleteStandaloneTaskKeepUserOperationLog() {
    // given
    String taskId = "my-task";
    Task task = taskService.newTask(taskId);
    taskService.saveTask(task);
    taskService.setAssignee(taskId, "demo");
    taskService.complete(taskId);
    UserOperationLogQuery query = historyService.createUserOperationLogQuery().taskId(taskId);
    assertEquals(3, query.count());
    // when
    historyService.deleteHistoricTaskInstance(taskId);
    // then
    assertEquals(3, query.count());
}
Also used : Task(org.camunda.bpm.engine.task.Task) UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery)

Aggregations

UserOperationLogQuery (org.camunda.bpm.engine.history.UserOperationLogQuery)67 Deployment (org.camunda.bpm.engine.test.Deployment)25 UserOperationLogEntry (org.camunda.bpm.engine.history.UserOperationLogEntry)20 Deployment (org.camunda.bpm.engine.repository.Deployment)10 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)6 Task (org.camunda.bpm.engine.task.Task)4 Date (java.util.Date)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 Batch (org.camunda.bpm.engine.batch.Batch)2 UserOperationLogQueryDto (org.camunda.bpm.engine.rest.dto.history.UserOperationLogQueryDto)2 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)2 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 Test (org.junit.Test)2 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1