use of org.camunda.bpm.engine.history.UserOperationLogQuery in project camunda-bpm-platform by camunda.
the class UserOperationLogAuthorizationTest method testQuerySuspendProcessInstanceUserOperationLogWithoutAuthorization.
// process instance //////////////////////////////////////////////
public void testQuerySuspendProcessInstanceUserOperationLogWithoutAuthorization() {
// given
String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
suspendProcessInstanceById(processInstanceId);
// when
UserOperationLogQuery query = historyService.createUserOperationLogQuery();
// then
verifyQueryResults(query, 0);
clearDatabase();
}
use of org.camunda.bpm.engine.history.UserOperationLogQuery in project camunda-bpm-platform by camunda.
the class UserOperationLogAuthorizationTest method testQueryCreateStandaloneTaskUserOperationLog.
// standalone task ///////////////////////////////
public void testQueryCreateStandaloneTaskUserOperationLog() {
// given
String taskId = "myTask";
createTask(taskId);
// when
UserOperationLogQuery query = historyService.createUserOperationLogQuery();
// then
verifyQueryResults(query, 1);
deleteTask(taskId, true);
}
use of org.camunda.bpm.engine.history.UserOperationLogQuery in project camunda-bpm-platform by camunda.
the class UserOperationLogAuthorizationTest method testQuerySetJobRetriesUserOperationLogWithoutAuthorization.
// job ///////////////////////////////
public void testQuerySetJobRetriesUserOperationLogWithoutAuthorization() {
// given
startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY);
String jobId = selectSingleJob().getId();
disableAuthorization();
managementService.setJobRetries(jobId, 5);
enableAuthorization();
// when
UserOperationLogQuery query = historyService.createUserOperationLogQuery();
// then
verifyQueryResults(query, 0);
}
use of org.camunda.bpm.engine.history.UserOperationLogQuery in project camunda-bpm-platform by camunda.
the class UserOperationLogAuthorizationTest method testQuerySetJobRetriesUserOperationLogWithReadHistoryPermissionOnAnyProcessDefinition.
public void testQuerySetJobRetriesUserOperationLogWithReadHistoryPermissionOnAnyProcessDefinition() {
// given
startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY);
String jobId = selectSingleJob().getId();
disableAuthorization();
managementService.setJobRetries(jobId, 5);
enableAuthorization();
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
// when
UserOperationLogQuery query = historyService.createUserOperationLogQuery();
// then
verifyQueryResults(query, 1);
}
use of org.camunda.bpm.engine.history.UserOperationLogQuery 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());
}
Aggregations