Search in sources :

Example 51 with UserOperationLogEntry

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

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

the class RestartProcessInstanceUserOperationLogTest method testLogCreationAsync.

@Test
public void testLogCreationAsync() {
    // given
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
    rule.getIdentityService().setAuthenticatedUserId("userId");
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("process1");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("process1");
    runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
    // when
    runtimeService.restartProcessInstances(processDefinition.getId()).startAfterActivity("user1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
    rule.getIdentityService().clearAuthentication();
    // then
    List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().operationType("RestartProcessInstance").list();
    Assert.assertEquals(2, opLogEntries.size());
    Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
    UserOperationLogEntry asyncEntry = entries.get("async");
    Assert.assertNotNull(asyncEntry);
    Assert.assertEquals("ProcessInstance", asyncEntry.getEntityType());
    Assert.assertEquals("RestartProcessInstance", asyncEntry.getOperationType());
    Assert.assertEquals(processDefinition.getId(), asyncEntry.getProcessDefinitionId());
    Assert.assertEquals(processDefinition.getKey(), asyncEntry.getProcessDefinitionKey());
    Assert.assertNull(asyncEntry.getProcessInstanceId());
    Assert.assertNull(asyncEntry.getOrgValue());
    Assert.assertEquals("true", asyncEntry.getNewValue());
    UserOperationLogEntry numInstancesEntry = entries.get("nrOfInstances");
    Assert.assertNotNull(numInstancesEntry);
    Assert.assertEquals("ProcessInstance", numInstancesEntry.getEntityType());
    Assert.assertEquals("RestartProcessInstance", numInstancesEntry.getOperationType());
    Assert.assertEquals(processDefinition.getId(), numInstancesEntry.getProcessDefinitionId());
    Assert.assertEquals(processDefinition.getKey(), numInstancesEntry.getProcessDefinitionKey());
    Assert.assertNull(numInstancesEntry.getProcessInstanceId());
    Assert.assertNull(numInstancesEntry.getOrgValue());
    Assert.assertEquals("2", numInstancesEntry.getNewValue());
    Assert.assertEquals(asyncEntry.getOperationId(), numInstancesEntry.getOperationId());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 53 with UserOperationLogEntry

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

the class SetExternalTaskRetriesUserOperationLogTest method testLogCreationAsync.

@Test
public void testLogCreationAsync() {
    // given
    rule.getIdentityService().setAuthenticatedUserId("userId");
    // when
    externalTaskService.setRetriesAsync(null, externalTaskService.createExternalTaskQuery(), 5);
    rule.getIdentityService().clearAuthentication();
    // then
    List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().list();
    Assert.assertEquals(3, opLogEntries.size());
    Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
    UserOperationLogEntry asyncEntry = entries.get("async");
    Assert.assertNotNull(asyncEntry);
    Assert.assertEquals("ProcessInstance", asyncEntry.getEntityType());
    Assert.assertEquals("SetExternalTaskRetries", asyncEntry.getOperationType());
    Assert.assertNull(asyncEntry.getProcessDefinitionId());
    Assert.assertNull(asyncEntry.getProcessDefinitionKey());
    Assert.assertNull(asyncEntry.getProcessInstanceId());
    Assert.assertNull(asyncEntry.getOrgValue());
    Assert.assertEquals("true", asyncEntry.getNewValue());
    UserOperationLogEntry numInstancesEntry = entries.get("nrOfInstances");
    Assert.assertNotNull(numInstancesEntry);
    Assert.assertEquals("ProcessInstance", numInstancesEntry.getEntityType());
    Assert.assertEquals("SetExternalTaskRetries", numInstancesEntry.getOperationType());
    Assert.assertNull(numInstancesEntry.getProcessDefinitionId());
    Assert.assertNull(numInstancesEntry.getProcessDefinitionKey());
    Assert.assertNull(numInstancesEntry.getProcessInstanceId());
    Assert.assertNull(numInstancesEntry.getOrgValue());
    Assert.assertEquals("6", numInstancesEntry.getNewValue());
    UserOperationLogEntry retriesEntry = entries.get("retries");
    Assert.assertNotNull(retriesEntry);
    Assert.assertEquals("ProcessInstance", retriesEntry.getEntityType());
    Assert.assertEquals("SetExternalTaskRetries", retriesEntry.getOperationType());
    Assert.assertNull(retriesEntry.getProcessDefinitionId());
    Assert.assertNull(retriesEntry.getProcessDefinitionKey());
    Assert.assertNull(retriesEntry.getProcessInstanceId());
    Assert.assertNull(retriesEntry.getOrgValue());
    Assert.assertEquals("5", retriesEntry.getNewValue());
    Assert.assertEquals(asyncEntry.getOperationId(), retriesEntry.getOperationId());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) Test(org.junit.Test)

Example 54 with UserOperationLogEntry

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

the class SetExternalTaskRetriesUserOperationLogTest method testLogCreationForOneExternalTaskId.

@Test
public void testLogCreationForOneExternalTaskId() {
    // given
    rule.getIdentityService().setAuthenticatedUserId("userId");
    // when
    ExternalTask externalTask = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(0)).singleResult();
    externalTaskService.setRetries(externalTask.getId(), 5);
    rule.getIdentityService().clearAuthentication();
    // then
    List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().list();
    Assert.assertEquals(1, opLogEntries.size());
    Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
    UserOperationLogEntry retriesEntry = entries.get("retries");
    Assert.assertNotNull(retriesEntry);
    Assert.assertEquals("ProcessInstance", retriesEntry.getEntityType());
    Assert.assertEquals("SetExternalTaskRetries", retriesEntry.getOperationType());
    Assert.assertEquals(externalTask.getProcessInstanceId(), retriesEntry.getProcessInstanceId());
    Assert.assertEquals(externalTask.getProcessDefinitionId(), retriesEntry.getProcessDefinitionId());
    Assert.assertEquals(externalTask.getProcessDefinitionKey(), retriesEntry.getProcessDefinitionKey());
    Assert.assertNull(retriesEntry.getOrgValue());
    Assert.assertEquals("5", retriesEntry.getNewValue());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 55 with UserOperationLogEntry

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

the class SetExternalTaskRetriesUserOperationLogTest method testLogCreationSync.

@Test
public void testLogCreationSync() {
    // given
    rule.getIdentityService().setAuthenticatedUserId("userId");
    List<ExternalTask> list = externalTaskService.createExternalTaskQuery().list();
    List<String> externalTaskIds = new ArrayList<String>();
    for (ExternalTask task : list) {
        externalTaskIds.add(task.getId());
    }
    // when
    externalTaskService.setRetries(externalTaskIds, 5);
    rule.getIdentityService().clearAuthentication();
    // then
    List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().list();
    Assert.assertEquals(3, opLogEntries.size());
    Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
    UserOperationLogEntry asyncEntry = entries.get("async");
    Assert.assertNotNull(asyncEntry);
    Assert.assertEquals("ProcessInstance", asyncEntry.getEntityType());
    Assert.assertEquals("SetExternalTaskRetries", asyncEntry.getOperationType());
    Assert.assertNull(asyncEntry.getProcessDefinitionId());
    Assert.assertNull(asyncEntry.getProcessDefinitionKey());
    Assert.assertNull(asyncEntry.getProcessInstanceId());
    Assert.assertNull(asyncEntry.getOrgValue());
    Assert.assertEquals("false", asyncEntry.getNewValue());
    UserOperationLogEntry numInstancesEntry = entries.get("nrOfInstances");
    Assert.assertNotNull(numInstancesEntry);
    Assert.assertEquals("ProcessInstance", numInstancesEntry.getEntityType());
    Assert.assertEquals("SetExternalTaskRetries", numInstancesEntry.getOperationType());
    Assert.assertNull(numInstancesEntry.getProcessDefinitionId());
    Assert.assertNull(numInstancesEntry.getProcessDefinitionKey());
    Assert.assertNull(numInstancesEntry.getProcessInstanceId());
    Assert.assertNull(numInstancesEntry.getOrgValue());
    Assert.assertEquals("6", numInstancesEntry.getNewValue());
    UserOperationLogEntry retriesEntry = entries.get("retries");
    Assert.assertNotNull(retriesEntry);
    Assert.assertEquals("ProcessInstance", retriesEntry.getEntityType());
    Assert.assertEquals("SetExternalTaskRetries", retriesEntry.getOperationType());
    Assert.assertNull(retriesEntry.getProcessDefinitionId());
    Assert.assertNull(retriesEntry.getProcessDefinitionKey());
    Assert.assertNull(retriesEntry.getProcessInstanceId());
    Assert.assertNull(retriesEntry.getOrgValue());
    Assert.assertEquals("5", retriesEntry.getNewValue());
    Assert.assertEquals(asyncEntry.getOperationId(), retriesEntry.getOperationId());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) ArrayList(java.util.ArrayList) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

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