use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class UserOperationLogQueryTest method testQuery.
@Deployment(resources = { ONE_TASK_PROCESS })
public void testQuery() {
createLogEntries();
// expect: all entries can be fetched
assertEquals(17, query().count());
// entity type
assertEquals(11, query().entityType(EntityTypes.TASK).count());
assertEquals(4, query().entityType(EntityTypes.IDENTITY_LINK).count());
assertEquals(2, query().entityType(EntityTypes.ATTACHMENT).count());
assertEquals(0, query().entityType("unknown entity type").count());
// operation type
assertEquals(1, query().operationType(OPERATION_TYPE_CREATE).count());
assertEquals(1, query().operationType(OPERATION_TYPE_SET_PRIORITY).count());
assertEquals(4, query().operationType(OPERATION_TYPE_UPDATE).count());
assertEquals(1, query().operationType(OPERATION_TYPE_ADD_USER_LINK).count());
assertEquals(1, query().operationType(OPERATION_TYPE_DELETE_USER_LINK).count());
assertEquals(1, query().operationType(OPERATION_TYPE_ADD_GROUP_LINK).count());
assertEquals(1, query().operationType(OPERATION_TYPE_DELETE_GROUP_LINK).count());
assertEquals(1, query().operationType(OPERATION_TYPE_ADD_ATTACHMENT).count());
assertEquals(1, query().operationType(OPERATION_TYPE_DELETE_ATTACHMENT).count());
// process and execution reference
assertEquals(11, query().processDefinitionId(process.getProcessDefinitionId()).count());
assertEquals(11, query().processInstanceId(process.getId()).count());
assertEquals(11, query().executionId(execution.getId()).count());
// task reference
assertEquals(11, query().taskId(processTaskId).count());
assertEquals(6, query().taskId(userTask.getId()).count());
// user reference
// not includes the create operation called by the process
assertEquals(11, query().userId("icke").count());
assertEquals(6, query().userId("er").count());
// operation ID
UserOperationLogQuery updates = query().operationType(OPERATION_TYPE_UPDATE);
String updateOperationId = updates.list().get(0).getOperationId();
assertEquals(updates.count(), query().operationId(updateOperationId).count());
// changed properties
assertEquals(3, query().property(ASSIGNEE).count());
assertEquals(2, query().property(OWNER).count());
// ascending order results by time
List<UserOperationLogEntry> ascLog = query().orderByTimestamp().asc().list();
for (int i = 0; i < 4; i++) {
assertTrue(yesterday.getTime() <= ascLog.get(i).getTimestamp().getTime());
}
for (int i = 4; i < 12; i++) {
assertTrue(today.getTime() <= ascLog.get(i).getTimestamp().getTime());
}
for (int i = 12; i < 16; i++) {
assertTrue(tomorrow.getTime() <= ascLog.get(i).getTimestamp().getTime());
}
// descending order results by time
List<UserOperationLogEntry> descLog = query().orderByTimestamp().desc().list();
for (int i = 0; i < 4; i++) {
assertTrue(tomorrow.getTime() <= descLog.get(i).getTimestamp().getTime());
}
for (int i = 4; i < 11; i++) {
assertTrue(today.getTime() <= descLog.get(i).getTimestamp().getTime());
}
for (int i = 11; i < 15; i++) {
assertTrue(yesterday.getTime() <= descLog.get(i).getTimestamp().getTime());
}
// filter by time, created yesterday
assertEquals(4, query().beforeTimestamp(today).count());
// filter by time, created today and before
assertEquals(12, query().beforeTimestamp(tomorrow).count());
// filter by time, created today and later
assertEquals(13, query().afterTimestamp(yesterday).count());
// filter by time, created tomorrow
assertEquals(5, query().afterTimestamp(today).count());
assertEquals(0, query().afterTimestamp(today).beforeTimestamp(yesterday).count());
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class UserOperationLogQueryTest method testQueryProcessInstanceModificationOperation.
// ----- PROCESS INSTANCE MODIFICATION -----
@Deployment(resources = { ONE_TASK_PROCESS })
public void testQueryProcessInstanceModificationOperation() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
String processInstanceId = processInstance.getId();
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("theTask").execute();
UserOperationLogQuery logQuery = query().entityType(EntityTypes.PROCESS_INSTANCE).operationType(UserOperationLogEntry.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE);
assertEquals(1, logQuery.count());
UserOperationLogEntry logEntry = logQuery.singleResult();
assertEquals(processInstanceId, logEntry.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), logEntry.getProcessDefinitionId());
assertEquals(definition.getKey(), logEntry.getProcessDefinitionKey());
assertEquals(deploymentId, logEntry.getDeploymentId());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE, logEntry.getOperationType());
assertEquals(EntityTypes.PROCESS_INSTANCE, logEntry.getEntityType());
assertNull(logEntry.getProperty());
assertNull(logEntry.getOrgValue());
assertNull(logEntry.getNewValue());
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class UserOperationLogQueryTest method testQueryProcessDefinitionOperationsById.
/**
* CAM-1930: add assertions for additional op log entries here
*/
@Deployment(resources = { ONE_TASK_PROCESS })
public void testQueryProcessDefinitionOperationsById() {
// given
process = runtimeService.startProcessInstanceByKey("oneTaskProcess");
// when
repositoryService.suspendProcessDefinitionById(process.getProcessDefinitionId(), true, null);
repositoryService.activateProcessDefinitionById(process.getProcessDefinitionId(), true, null);
// then
assertEquals(2, query().entityType(PROCESS_DEFINITION).count());
// Process Definition Suspension
UserOperationLogEntry suspendDefinitionEntry = query().entityType(PROCESS_DEFINITION).processDefinitionId(process.getProcessDefinitionId()).operationType(OPERATION_TYPE_SUSPEND_PROCESS_DEFINITION).singleResult();
assertNotNull(suspendDefinitionEntry);
assertEquals(process.getProcessDefinitionId(), suspendDefinitionEntry.getProcessDefinitionId());
assertEquals("oneTaskProcess", suspendDefinitionEntry.getProcessDefinitionKey());
assertEquals(deploymentId, suspendDefinitionEntry.getDeploymentId());
assertEquals("suspensionState", suspendDefinitionEntry.getProperty());
assertEquals("suspended", suspendDefinitionEntry.getNewValue());
assertNull(suspendDefinitionEntry.getOrgValue());
UserOperationLogEntry activateDefinitionEntry = query().entityType(PROCESS_DEFINITION).processDefinitionId(process.getProcessDefinitionId()).operationType(OPERATION_TYPE_ACTIVATE_PROCESS_DEFINITION).singleResult();
assertNotNull(activateDefinitionEntry);
assertEquals(process.getProcessDefinitionId(), activateDefinitionEntry.getProcessDefinitionId());
assertEquals("oneTaskProcess", activateDefinitionEntry.getProcessDefinitionKey());
assertEquals(deploymentId, activateDefinitionEntry.getDeploymentId());
assertEquals("suspensionState", activateDefinitionEntry.getProperty());
assertEquals("active", activateDefinitionEntry.getNewValue());
assertNull(activateDefinitionEntry.getOrgValue());
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class UserOperationLogQueryTest method testQueryProcessInstanceOperationsByProcessDefinitionId.
@Deployment(resources = { ONE_TASK_PROCESS })
public void testQueryProcessInstanceOperationsByProcessDefinitionId() {
// given
process = runtimeService.startProcessInstanceByKey("oneTaskProcess");
// when
runtimeService.suspendProcessInstanceByProcessDefinitionId(process.getProcessDefinitionId());
runtimeService.activateProcessInstanceByProcessDefinitionId(process.getProcessDefinitionId());
// then
assertEquals(2, query().entityType(PROCESS_INSTANCE).count());
UserOperationLogEntry suspendEntry = query().entityType(PROCESS_INSTANCE).processDefinitionId(process.getProcessDefinitionId()).operationType(OPERATION_TYPE_SUSPEND).singleResult();
assertNotNull(suspendEntry);
assertEquals(process.getProcessDefinitionId(), suspendEntry.getProcessDefinitionId());
assertNull(suspendEntry.getProcessInstanceId());
assertEquals("oneTaskProcess", suspendEntry.getProcessDefinitionKey());
assertEquals(deploymentId, suspendEntry.getDeploymentId());
assertEquals("suspensionState", suspendEntry.getProperty());
assertEquals("suspended", suspendEntry.getNewValue());
assertNull(suspendEntry.getOrgValue());
UserOperationLogEntry activateEntry = query().entityType(PROCESS_INSTANCE).processDefinitionId(process.getProcessDefinitionId()).operationType(OPERATION_TYPE_ACTIVATE).singleResult();
assertNotNull(activateEntry);
assertNull(activateEntry.getProcessInstanceId());
assertEquals("oneTaskProcess", activateEntry.getProcessDefinitionKey());
assertEquals(process.getProcessDefinitionId(), activateEntry.getProcessDefinitionId());
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 testQueryProcessDefinitionOperationsByKey.
/**
* CAM-1930: add assertions for additional op log entries here
*/
@Deployment(resources = { ONE_TASK_PROCESS })
public void testQueryProcessDefinitionOperationsByKey() {
// given
process = runtimeService.startProcessInstanceByKey("oneTaskProcess");
// when
repositoryService.suspendProcessDefinitionByKey("oneTaskProcess", true, null);
repositoryService.activateProcessDefinitionByKey("oneTaskProcess", true, null);
// then
assertEquals(2, query().entityType(PROCESS_DEFINITION).count());
UserOperationLogEntry suspendDefinitionEntry = query().entityType(PROCESS_DEFINITION).processDefinitionKey("oneTaskProcess").operationType(OPERATION_TYPE_SUSPEND_PROCESS_DEFINITION).singleResult();
assertNotNull(suspendDefinitionEntry);
assertNull(suspendDefinitionEntry.getProcessDefinitionId());
assertEquals("oneTaskProcess", suspendDefinitionEntry.getProcessDefinitionKey());
assertNull(suspendDefinitionEntry.getDeploymentId());
assertEquals("suspensionState", suspendDefinitionEntry.getProperty());
assertEquals("suspended", suspendDefinitionEntry.getNewValue());
assertNull(suspendDefinitionEntry.getOrgValue());
UserOperationLogEntry activateDefinitionEntry = query().entityType(PROCESS_DEFINITION).processDefinitionKey("oneTaskProcess").operationType(OPERATION_TYPE_ACTIVATE_PROCESS_DEFINITION).singleResult();
assertNotNull(activateDefinitionEntry);
assertNull(activateDefinitionEntry.getProcessDefinitionId());
assertEquals("oneTaskProcess", activateDefinitionEntry.getProcessDefinitionKey());
assertNull(activateDefinitionEntry.getDeploymentId());
assertEquals("suspensionState", activateDefinitionEntry.getProperty());
assertEquals("active", activateDefinitionEntry.getNewValue());
assertNull(activateDefinitionEntry.getOrgValue());
}
Aggregations