Search in sources :

Example 36 with UserOperationLogQuery

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();
}
Also used : UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery)

Example 37 with UserOperationLogQuery

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);
}
Also used : UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery)

Example 38 with UserOperationLogQuery

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);
}
Also used : UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery)

Example 39 with UserOperationLogQuery

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);
}
Also used : UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery)

Example 40 with UserOperationLogQuery

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());
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

UserOperationLogQuery (org.camunda.bpm.engine.history.UserOperationLogQuery)67 Deployment (org.camunda.bpm.engine.test.Deployment)25 UserOperationLogEntry (org.camunda.bpm.engine.history.UserOperationLogEntry)20 Deployment (org.camunda.bpm.engine.repository.Deployment)10 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)6 Task (org.camunda.bpm.engine.task.Task)4 Date (java.util.Date)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 Batch (org.camunda.bpm.engine.batch.Batch)2 UserOperationLogQueryDto (org.camunda.bpm.engine.rest.dto.history.UserOperationLogQueryDto)2 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)2 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 Test (org.junit.Test)2 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1