Search in sources :

Example 46 with UserOperationLogQuery

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

the class UserOperationLogQueryTest method testQueryByCaseExecutionId.

@Deployment(resources = { ONE_TASK_CASE })
public void testQueryByCaseExecutionId() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    caseService.withCaseDefinition(caseDefinitionId).create();
    String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    // when
    taskService.setAssignee(task.getId(), "demo");
    // then
    UserOperationLogQuery query = historyService.createUserOperationLogQuery().caseExecutionId(caseExecutionId);
    verifyQueryResults(query, 1);
}
Also used : Task(org.camunda.bpm.engine.task.Task) UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 47 with UserOperationLogQuery

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

the class UserOperationLogTaskTest method testSetPriority.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml" })
public void testSetPriority() {
    startTestProcess();
    // then: set the priority of the task to 10
    taskService.setPriority(task.getId(), 10);
    // expect: one entry for the priority update
    UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_SET_PRIORITY);
    assertEquals(1, query.count());
    // assert: correct priority set
    UserOperationLogEntry userOperationLogEntry = query.singleResult();
    assertEquals(PRIORITY, userOperationLogEntry.getProperty());
    // note: 50 is the default task priority
    assertEquals(50, Integer.parseInt(userOperationLogEntry.getOrgValue()));
    assertEquals(10, Integer.parseInt(userOperationLogEntry.getNewValue()));
    // move clock by 5 minutes
    Date date = DateTimeUtil.now().plusMinutes(5).toDate();
    ClockUtil.setCurrentTime(date);
    // then: set priority again
    taskService.setPriority(task.getId(), 75);
    // expect: one entry for the priority update
    query = queryOperationDetails(OPERATION_TYPE_SET_PRIORITY);
    assertEquals(2, query.count());
    // assert: correct priority set
    userOperationLogEntry = query.orderByTimestamp().asc().list().get(1);
    assertEquals(PRIORITY, userOperationLogEntry.getProperty());
    assertEquals(10, Integer.parseInt(userOperationLogEntry.getOrgValue()));
    assertEquals(75, Integer.parseInt(userOperationLogEntry.getNewValue()));
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery) Date(java.util.Date) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 48 with UserOperationLogQuery

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

the class UserOperationLogTaskTest method testSubmitTaskForm_Complete.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml" })
public void testSubmitTaskForm_Complete() {
    startTestProcess();
    formService.submitTaskForm(task.getId(), new HashMap<String, Object>());
    // expect: two entries for the resolving (delegation and assignee changed)
    UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_COMPLETE);
    assertEquals(1, query.count());
    // assert: delete
    assertFalse(Boolean.parseBoolean(query.property("delete").singleResult().getOrgValue()));
    assertTrue(Boolean.parseBoolean(query.property("delete").singleResult().getNewValue()));
    assertProcessEnded(process.getId());
}
Also used : UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 49 with UserOperationLogQuery

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

the class UserOperationLogTaskTest method testAssignTask.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml" })
public void testAssignTask() {
    startTestProcess();
    // then: assign the task
    taskService.setAssignee(task.getId(), "icke");
    // expect: one entry for the task assignment
    UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_ASSIGN);
    assertEquals(1, query.count());
    // assert: details
    UserOperationLogEntry assign = query.singleResult();
    assertEquals(ASSIGNEE, assign.getProperty());
    assertEquals("icke", assign.getNewValue());
    completeTestProcess();
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 50 with UserOperationLogQuery

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

the class UserOperationLogTaskTest method testKeepOpLogEntriesOnUndeployment.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml" })
public void testKeepOpLogEntriesOnUndeployment() {
    // given
    startTestProcess();
    // an op log entry directly related to the process instance is created
    taskService.resolveTask(task.getId());
    // and an op log entry with indirect reference to the process instance is created
    runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinition.getId());
    // when
    // the deployment is deleted with cascade
    repositoryService.deleteDeployment(deploymentId, true);
    // then
    UserOperationLogQuery query = historyService.createUserOperationLogQuery();
    assertEquals(3, query.count());
    assertEquals(1, query.operationType(UserOperationLogEntry.OPERATION_TYPE_SUSPEND).count());
    assertEquals(1, query.operationType(UserOperationLogEntry.OPERATION_TYPE_RESOLVE).count());
    assertEquals(1, query.operationType(UserOperationLogEntry.OPERATION_TYPE_DELETE).count());
}
Also used : UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

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