Search in sources :

Example 6 with UserOperationLogEntry

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

the class RepositoryServiceTest method testProcessDefinitionUpdateTimeToLiveUserOperationLog.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testProcessDefinitionUpdateTimeToLiveUserOperationLog() {
    // given
    ProcessDefinition processDefinition = findOnlyProcessDefinition();
    Integer timeToLiveOrgValue = processDefinition.getHistoryTimeToLive();
    processEngine.getIdentityService().setAuthenticatedUserId("userId");
    // when
    Integer timeToLiveNewValue = 6;
    repositoryService.updateProcessDefinitionHistoryTimeToLive(processDefinition.getId(), timeToLiveNewValue);
    // then
    List<UserOperationLogEntry> opLogEntries = processEngine.getHistoryService().createUserOperationLogQuery().list();
    Assert.assertEquals(1, opLogEntries.size());
    final UserOperationLogEntryEventEntity userOperationLogEntry = (UserOperationLogEntryEventEntity) opLogEntries.get(0);
    assertEquals(UserOperationLogEntry.OPERATION_TYPE_UPDATE_HISTORY_TIME_TO_LIVE, userOperationLogEntry.getOperationType());
    assertEquals(processDefinition.getKey(), userOperationLogEntry.getProcessDefinitionKey());
    assertEquals(processDefinition.getId(), userOperationLogEntry.getProcessDefinitionId());
    assertEquals("historyTimeToLive", userOperationLogEntry.getProperty());
    assertEquals(timeToLiveOrgValue, Integer.valueOf(userOperationLogEntry.getOrgValue()));
    assertEquals(timeToLiveNewValue, Integer.valueOf(userOperationLogEntry.getNewValue()));
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) UserOperationLogEntryEventEntity(org.camunda.bpm.engine.impl.history.event.UserOperationLogEntryEventEntity) ReadOnlyProcessDefinition(org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 7 with UserOperationLogEntry

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

the class MigrationUserOperationLogTest method testLogCreation.

@Test
public void testLogCreation() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY));
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    // when
    rule.getIdentityService().setAuthenticatedUserId(USER_ID);
    rule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).execute();
    rule.getIdentityService().clearAuthentication();
    // then
    List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().list();
    Assert.assertEquals(3, opLogEntries.size());
    Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
    UserOperationLogEntry procDefEntry = entries.get("processDefinitionId");
    Assert.assertNotNull(procDefEntry);
    Assert.assertEquals("ProcessInstance", procDefEntry.getEntityType());
    Assert.assertEquals("Migrate", procDefEntry.getOperationType());
    Assert.assertEquals(sourceProcessDefinition.getId(), procDefEntry.getProcessDefinitionId());
    Assert.assertEquals(sourceProcessDefinition.getKey(), procDefEntry.getProcessDefinitionKey());
    Assert.assertNull(procDefEntry.getProcessInstanceId());
    Assert.assertEquals(sourceProcessDefinition.getId(), procDefEntry.getOrgValue());
    Assert.assertEquals(targetProcessDefinition.getId(), procDefEntry.getNewValue());
    UserOperationLogEntry asyncEntry = entries.get("async");
    Assert.assertNotNull(asyncEntry);
    Assert.assertEquals("ProcessInstance", asyncEntry.getEntityType());
    Assert.assertEquals("Migrate", asyncEntry.getOperationType());
    Assert.assertEquals(sourceProcessDefinition.getId(), asyncEntry.getProcessDefinitionId());
    Assert.assertEquals(sourceProcessDefinition.getKey(), asyncEntry.getProcessDefinitionKey());
    Assert.assertNull(asyncEntry.getProcessInstanceId());
    Assert.assertNull(asyncEntry.getOrgValue());
    Assert.assertEquals("false", asyncEntry.getNewValue());
    UserOperationLogEntry numInstanceEntry = entries.get("nrOfInstances");
    Assert.assertNotNull(numInstanceEntry);
    Assert.assertEquals("ProcessInstance", numInstanceEntry.getEntityType());
    Assert.assertEquals("Migrate", numInstanceEntry.getOperationType());
    Assert.assertEquals(sourceProcessDefinition.getId(), numInstanceEntry.getProcessDefinitionId());
    Assert.assertEquals(sourceProcessDefinition.getKey(), numInstanceEntry.getProcessDefinitionKey());
    Assert.assertNull(numInstanceEntry.getProcessInstanceId());
    Assert.assertNull(numInstanceEntry.getOrgValue());
    Assert.assertEquals("1", numInstanceEntry.getNewValue());
    Assert.assertEquals(procDefEntry.getOperationId(), asyncEntry.getOperationId());
    Assert.assertEquals(asyncEntry.getOperationId(), numInstanceEntry.getOperationId());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 8 with UserOperationLogEntry

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

the class UserOperationLogQueryTest method verifyVariableOperationAsserts.

private void verifyVariableOperationAsserts(int countAssertValue, String operationType) {
    UserOperationLogQuery logQuery = query().entityType(EntityTypes.VARIABLE).operationType(operationType);
    assertEquals(countAssertValue, logQuery.count());
    if (countAssertValue > 1) {
        List<UserOperationLogEntry> logEntryList = logQuery.list();
        for (UserOperationLogEntry logEntry : logEntryList) {
            assertEquals(process.getProcessDefinitionId(), logEntry.getProcessDefinitionId());
            assertEquals(process.getProcessInstanceId(), logEntry.getProcessInstanceId());
            assertEquals(deploymentId, logEntry.getDeploymentId());
        }
    } else {
        UserOperationLogEntry logEntry = logQuery.singleResult();
        assertEquals(process.getProcessDefinitionId(), logEntry.getProcessDefinitionId());
        assertEquals(process.getProcessInstanceId(), logEntry.getProcessInstanceId());
        assertEquals(deploymentId, logEntry.getDeploymentId());
    }
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery)

Example 9 with UserOperationLogEntry

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

the class UserOperationLogQueryTest method testQueryProcessInstanceOperationsById.

@Deployment(resources = { ONE_TASK_PROCESS })
public void testQueryProcessInstanceOperationsById() {
    // given
    process = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    // when
    runtimeService.suspendProcessInstanceById(process.getId());
    runtimeService.activateProcessInstanceById(process.getId());
    runtimeService.deleteProcessInstance(process.getId(), "a delete reason");
    // then
    assertEquals(3, query().entityType(PROCESS_INSTANCE).count());
    UserOperationLogEntry deleteEntry = query().entityType(PROCESS_INSTANCE).processInstanceId(process.getId()).operationType(OPERATION_TYPE_DELETE).singleResult();
    assertNotNull(deleteEntry);
    assertEquals(process.getId(), deleteEntry.getProcessInstanceId());
    assertNotNull(deleteEntry.getProcessDefinitionId());
    assertEquals("oneTaskProcess", deleteEntry.getProcessDefinitionKey());
    assertEquals(deploymentId, deleteEntry.getDeploymentId());
    UserOperationLogEntry suspendEntry = query().entityType(PROCESS_INSTANCE).processInstanceId(process.getId()).operationType(OPERATION_TYPE_SUSPEND).singleResult();
    assertNotNull(suspendEntry);
    assertEquals(process.getId(), suspendEntry.getProcessInstanceId());
    assertNotNull(suspendEntry.getProcessDefinitionId());
    assertEquals("oneTaskProcess", suspendEntry.getProcessDefinitionKey());
    assertEquals("suspensionState", suspendEntry.getProperty());
    assertEquals("suspended", suspendEntry.getNewValue());
    assertNull(suspendEntry.getOrgValue());
    UserOperationLogEntry activateEntry = query().entityType(PROCESS_INSTANCE).processInstanceId(process.getId()).operationType(OPERATION_TYPE_ACTIVATE).singleResult();
    assertNotNull(activateEntry);
    assertEquals(process.getId(), activateEntry.getProcessInstanceId());
    assertNotNull(activateEntry.getProcessDefinitionId());
    assertEquals("oneTaskProcess", activateEntry.getProcessDefinitionKey());
    assertEquals(deploymentId, activateEntry.getDeploymentId());
    assertEquals("suspensionState", activateEntry.getProperty());
    assertEquals("active", activateEntry.getNewValue());
    assertNull(activateEntry.getOrgValue());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 10 with UserOperationLogEntry

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

the class UserOperationLogQueryTest method testQueryProcessInstanceOperationsByProcessDefinitionKey.

@Deployment(resources = { ONE_TASK_PROCESS })
public void testQueryProcessInstanceOperationsByProcessDefinitionKey() {
    // given
    process = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    // when
    runtimeService.suspendProcessInstanceByProcessDefinitionKey("oneTaskProcess");
    runtimeService.activateProcessInstanceByProcessDefinitionKey("oneTaskProcess");
    // then
    assertEquals(2, query().entityType(PROCESS_INSTANCE).count());
    UserOperationLogEntry suspendEntry = query().entityType(PROCESS_INSTANCE).processDefinitionKey("oneTaskProcess").operationType(OPERATION_TYPE_SUSPEND).singleResult();
    assertNotNull(suspendEntry);
    assertNull(suspendEntry.getProcessInstanceId());
    assertNull(suspendEntry.getProcessDefinitionId());
    assertEquals("oneTaskProcess", suspendEntry.getProcessDefinitionKey());
    assertNull(suspendEntry.getDeploymentId());
    assertEquals("suspensionState", suspendEntry.getProperty());
    assertEquals("suspended", suspendEntry.getNewValue());
    assertNull(suspendEntry.getOrgValue());
    UserOperationLogEntry activateEntry = query().entityType(PROCESS_INSTANCE).processDefinitionKey("oneTaskProcess").operationType(OPERATION_TYPE_ACTIVATE).singleResult();
    assertNotNull(activateEntry);
    assertNull(activateEntry.getProcessInstanceId());
    assertNull(activateEntry.getProcessDefinitionId());
    assertEquals("oneTaskProcess", activateEntry.getProcessDefinitionKey());
    assertNull(activateEntry.getDeploymentId());
    assertEquals("suspensionState", activateEntry.getProperty());
    assertEquals("active", activateEntry.getNewValue());
    assertNull(activateEntry.getOrgValue());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) Deployment(org.camunda.bpm.engine.test.Deployment)

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