Search in sources :

Example 46 with UserOperationLogEntry

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

the class UserOperationLogJobTest method testSetJobPriority.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/asyncTaskProcess.bpmn20.xml" })
public void testSetJobPriority() {
    // given a job
    runtimeService.startProcessInstanceByKey("asyncTaskProcess");
    Job job = managementService.createJobQuery().singleResult();
    // when I set a job priority
    managementService.setJobPriority(job.getId(), 42);
    // then an op log entry is written
    UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery().singleResult();
    assertNotNull(userOperationLogEntry);
    assertEquals(EntityTypes.JOB, userOperationLogEntry.getEntityType());
    assertEquals(job.getId(), userOperationLogEntry.getJobId());
    assertEquals(UserOperationLogEntry.OPERATION_TYPE_SET_PRIORITY, userOperationLogEntry.getOperationType());
    assertEquals("priority", userOperationLogEntry.getProperty());
    assertEquals("42", userOperationLogEntry.getNewValue());
    assertEquals("0", userOperationLogEntry.getOrgValue());
    assertEquals(USER_ID, userOperationLogEntry.getUserId());
    assertEquals(job.getJobDefinitionId(), userOperationLogEntry.getJobDefinitionId());
    assertEquals(job.getProcessInstanceId(), userOperationLogEntry.getProcessInstanceId());
    assertEquals(job.getProcessDefinitionId(), userOperationLogEntry.getProcessDefinitionId());
    assertEquals(job.getProcessDefinitionKey(), userOperationLogEntry.getProcessDefinitionKey());
    assertEquals(deploymentId, userOperationLogEntry.getDeploymentId());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 47 with UserOperationLogEntry

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

the class UserOperationLogTaskServiceAndBeanTest method testDeleteTask.

public void testDeleteTask() {
    // given: a single task
    task = taskService.newTask();
    taskService.saveTask(task);
    // then: delete the task
    taskService.deleteTask(task.getId(), "duplicated");
    // expect: one entry for the deletion
    UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_DELETE);
    assertEquals(1, query.count());
    // assert: details
    UserOperationLogEntry delete = query.singleResult();
    assertEquals(DELETE, delete.getProperty());
    assertFalse(Boolean.parseBoolean(delete.getOrgValue()));
    assertTrue(Boolean.parseBoolean(delete.getNewValue()));
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery)

Example 48 with UserOperationLogEntry

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

the class UserOperationLogTaskServiceAndBeanTest method testResetChange.

public void testResetChange() {
    // given: a single task
    task = taskService.newTask();
    taskService.saveTask(task);
    // then: change the name
    String name = "a task";
    task.setName(name);
    taskService.saveTask(task);
    UserOperationLogEntry update = queryOperationDetails(OPERATION_TYPE_UPDATE).singleResult();
    assertNull(update.getOrgValue());
    assertEquals(name, update.getNewValue());
    // then: change the name some times and set it back to the original value
    task.setName("to do 1");
    task.setName("to do 2");
    task.setName(name);
    taskService.saveTask(task);
    // expect: there is no additional change tracked
    update = queryOperationDetails(OPERATION_TYPE_UPDATE).singleResult();
    assertNull(update.getOrgValue());
    assertEquals(name, update.getNewValue());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry)

Example 49 with UserOperationLogEntry

use of org.camunda.bpm.engine.history.UserOperationLogEntry 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 50 with UserOperationLogEntry

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

the class UserOperationLogTaskServiceAndBeanTest method testSetDateProperty.

public void testSetDateProperty() {
    // given: a single task
    task = taskService.newTask();
    Date now = ClockUtil.getCurrentTime();
    task.setDueDate(now);
    taskService.saveTask(task);
    UserOperationLogEntry logEntry = historyService.createUserOperationLogQuery().singleResult();
    assertEquals(String.valueOf(now.getTime()), logEntry.getNewValue());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) Date(java.util.Date)

Aggregations

UserOperationLogEntry (org.camunda.bpm.engine.history.UserOperationLogEntry)59 Deployment (org.camunda.bpm.engine.test.Deployment)25 UserOperationLogQuery (org.camunda.bpm.engine.history.UserOperationLogQuery)20 Test (org.junit.Test)15 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)11 Deployment (org.camunda.bpm.engine.repository.Deployment)8 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)7 Date (java.util.Date)4 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)4 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)4 Batch (org.camunda.bpm.engine.batch.Batch)3 Job (org.camunda.bpm.engine.runtime.Job)3 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)2 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)2 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)2 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)2 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 ArrayList (java.util.ArrayList)1 EmbeddedProcessApplication (org.camunda.bpm.application.impl.EmbeddedProcessApplication)1 HistoryService (org.camunda.bpm.engine.HistoryService)1