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()));
}
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());
}
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());
}
}
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());
}
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());
}
Aggregations