public static void clearUserOperationLog(ProcessEngineConfigurationImpl processEngineConfiguration) { if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) { HistoryService historyService = processEngineConfiguration.getHistoryService(); List<UserOperationLogEntry> logs = historyService.createUserOperationLogQuery().list(); for (UserOperationLogEntry log : logs) { historyService.deleteUserOperationLogEntry(log.getId()); } } }
public static void clearUserOperationLog(ProcessEngineConfigurationImpl processEngineConfiguration) { if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) { HistoryService historyService = processEngineConfiguration.getHistoryService(); List<UserOperationLogEntry> logs = historyService.createUserOperationLogQuery().list(); for (UserOperationLogEntry log : logs) { historyService.deleteUserOperationLogEntry(log.getId()); } } }
private void assertThatTasksHaveAllImportantInformation(UserOperationLogEntry userOperationLogEntry) { assertThat(userOperationLogEntry, notNullValue()); assertThat(userOperationLogEntry.getId(), notNullValue()); assertThat(userOperationLogEntry.getOperationType(), is(OPERATION_TYPE_CLAIM)); assertThat(userOperationLogEntry.getOrgValue(), nullValue()); assertThat(userOperationLogEntry.getNewValue(), is(userId)); assertThat(userOperationLogEntry.getTimestamp(), notNullValue()); assertThat(userOperationLogEntry.getProcessDefinitionKey(), is("process")); assertThat(userOperationLogEntry.getProcessDefinitionId(), notNullValue()); assertThat(userOperationLogEntry.getUserId(), is(userId)); assertThat(userOperationLogEntry.getTaskId(), is(taskService.createTaskQuery().singleResult().getId())); }
private static UserOperationLogEntry createUserOperationLogEntry() { UserOperationLogEntry entry = mock(UserOperationLogEntry.class); when(entry.getId()).thenReturn(EXAMPLE_USER_OPERATION_LOG_ID); when(entry.getDeploymentId()).thenReturn(EXAMPLE_DEPLOYMENT_ID); when(entry.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID); when(entry.getProcessDefinitionKey()).thenReturn(EXAMPLE_PROCESS_DEFINITION_KEY); when(entry.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID); when(entry.getExecutionId()).thenReturn(EXAMPLE_EXECUTION_ID); when(entry.getCaseDefinitionId()).thenReturn(EXAMPLE_CASE_DEFINITION_ID); when(entry.getCaseInstanceId()).thenReturn(EXAMPLE_CASE_INSTANCE_ID); when(entry.getCaseExecutionId()).thenReturn(EXAMPLE_CASE_EXECUTION_ID); when(entry.getTaskId()).thenReturn(EXAMPLE_TASK_ID); when(entry.getJobId()).thenReturn(EXAMPLE_JOB_ID); when(entry.getJobDefinitionId()).thenReturn(EXAMPLE_JOB_DEFINITION_ID); when(entry.getBatchId()).thenReturn(EXAMPLE_BATCH_ID); when(entry.getUserId()).thenReturn(EXAMPLE_USER_ID); when(entry.getTimestamp()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_USER_OPERATION_TIMESTAMP)); when(entry.getOperationId()).thenReturn(EXAMPLE_USER_OPERATION_ID); when(entry.getOperationType()).thenReturn(EXAMPLE_USER_OPERATION_TYPE); when(entry.getEntityType()).thenReturn(EXAMPLE_USER_OPERATION_ENTITY); when(entry.getProperty()).thenReturn(EXAMPLE_USER_OPERATION_PROPERTY); when(entry.getOrgValue()).thenReturn(EXAMPLE_USER_OPERATION_ORG_VALUE); when(entry.getNewValue()).thenReturn(EXAMPLE_USER_OPERATION_NEW_VALUE); return entry; }
@After public void tearDown() throws Exception { identityService.clearAuthentication(); List<UserOperationLogEntry> logs = query().list(); for (UserOperationLogEntry log : logs) { historyService.deleteUserOperationLogEntry(log.getId()); } }
public void testDeleteStandaloneEntry() { // given String taskId = "myTask"; createTask(taskId); String entryId = historyService.createUserOperationLogQuery().singleResult().getId(); // when historyService.deleteUserOperationLogEntry(entryId); // then assertNull(historyService.createUserOperationLogQuery().singleResult()); deleteTask(taskId, true); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testDeleteOpLogEntry() { // given startTestProcess(); // an op log instance is created taskService.resolveTask(task.getId()); UserOperationLogEntry opLogEntry = historyService.createUserOperationLogQuery().singleResult(); // when the op log instance is deleted historyService.deleteUserOperationLogEntry(opLogEntry.getId()); // then it should be removed from the database assertEquals(0, historyService.createUserOperationLogQuery().count()); }
public void testCaseDeleteEntry() { // given createCaseInstanceByKey(ONE_TASK_CASE_KEY); String taskId = selectSingleTask().getId(); setAssignee(taskId, "demo"); String entryId = historyService.createUserOperationLogQuery().singleResult().getId(); // when historyService.deleteUserOperationLogEntry(entryId); // then assertNull(historyService.createUserOperationLogQuery().singleResult()); }
@Test @Deployment(resources = { ONE_TASK_PROCESS }) public void testUserOperationLogDeletion() { // given process = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.setVariable(process.getId(), "testVariable1", "THIS IS TESTVARIABLE!!!"); // assume verifyVariableOperationAsserts(1, UserOperationLogEntry.OPERATION_TYPE_SET_VARIABLE); // when UserOperationLogEntry log = query().entityType(EntityTypes.VARIABLE).operationType(UserOperationLogEntry.OPERATION_TYPE_SET_VARIABLE).singleResult(); assertNotNull(log); historyService.deleteUserOperationLogEntry(log.getId()); // then List<UserOperationLogEntry> list = query().entityType(EntityTypes.VARIABLE).operationType(UserOperationLogEntry.OPERATION_TYPE_SET_VARIABLE).list(); assertEquals(0, list.size()); }
public void testCaseInstanceId() { // create new task task = taskService.newTask(); taskService.saveTask(task); UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_UPDATE); assertEquals(0, query.count()); // set case instance id and save task task.setCaseInstanceId("aCaseInstanceId"); taskService.saveTask(task); assertEquals(1, query.count()); UserOperationLogEntry entry = query.singleResult(); assertNotNull(entry); assertNull(entry.getOrgValue()); assertEquals("aCaseInstanceId", entry.getNewValue()); assertEquals(CASE_INSTANCE_ID, entry.getProperty()); // change case instance id and save task task.setCaseInstanceId("anotherCaseInstanceId"); taskService.saveTask(task); assertEquals(2, query.count()); List<UserOperationLogEntry> entries = query.list(); assertEquals(2, entries.size()); for (UserOperationLogEntry currentEntry : entries) { if (!currentEntry.getId().equals(entry.getId())) { assertEquals("aCaseInstanceId", currentEntry.getOrgValue()); assertEquals("anotherCaseInstanceId", currentEntry.getNewValue()); assertEquals(CASE_INSTANCE_ID, currentEntry.getProperty()); } } }
public static UserOperationLogEntryDto map(UserOperationLogEntry entry) { UserOperationLogEntryDto dto = new UserOperationLogEntryDto(); dto.id = entry.getId(); dto.deploymentId = entry.getDeploymentId(); dto.processDefinitionId = entry.getProcessDefinitionId(); dto.processDefinitionKey = entry.getProcessDefinitionKey(); dto.processInstanceId = entry.getProcessInstanceId(); dto.executionId = entry.getExecutionId(); dto.caseDefinitionId = entry.getCaseDefinitionId(); dto.caseInstanceId = entry.getCaseInstanceId(); dto.caseExecutionId = entry.getCaseExecutionId(); dto.taskId = entry.getTaskId(); dto.jobId = entry.getJobId(); dto.jobDefinitionId = entry.getJobDefinitionId(); dto.batchId = entry.getBatchId(); dto.userId = entry.getUserId(); dto.timestamp = entry.getTimestamp(); dto.operationId = entry.getOperationId(); dto.operationType = entry.getOperationType(); dto.entityType = entry.getEntityType(); dto.property = entry.getProperty(); dto.orgValue = entry.getOrgValue(); dto.newValue = entry.getNewValue(); dto.removalTime = entry.getRemovalTime(); dto.rootProcessInstanceId = entry.getRootProcessInstanceId(); return dto; }
public static UserOperationLogEntryDto map(UserOperationLogEntry entry) { UserOperationLogEntryDto dto = new UserOperationLogEntryDto(); dto.id = entry.getId(); dto.deploymentId = entry.getDeploymentId(); dto.processDefinitionId = entry.getProcessDefinitionId(); dto.processDefinitionKey = entry.getProcessDefinitionKey(); dto.processInstanceId = entry.getProcessInstanceId(); dto.executionId = entry.getExecutionId(); dto.caseDefinitionId = entry.getCaseDefinitionId(); dto.caseInstanceId = entry.getCaseInstanceId(); dto.caseExecutionId = entry.getCaseExecutionId(); dto.taskId = entry.getTaskId(); dto.jobId = entry.getJobId(); dto.jobDefinitionId = entry.getJobDefinitionId(); dto.batchId = entry.getBatchId(); dto.userId = entry.getUserId(); dto.timestamp = entry.getTimestamp(); dto.operationId = entry.getOperationId(); dto.operationType = entry.getOperationType(); dto.entityType = entry.getEntityType(); dto.property = entry.getProperty(); dto.orgValue = entry.getOrgValue(); dto.newValue = entry.getNewValue(); dto.removalTime = entry.getRemovalTime(); dto.rootProcessInstanceId = entry.getRootProcessInstanceId(); return dto; }
public void testDeleteEntryWithDeleteHistoryPermissionOnAnyProcessDefinition() { // given startProcessInstanceByKey(ONE_TASK_PROCESS_KEY); String taskId = selectSingleTask().getId(); setAssignee(taskId, "demo"); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, DELETE_HISTORY); disableAuthorization(); String entryId = historyService.createUserOperationLogQuery().singleResult().getId(); enableAuthorization(); // when historyService.deleteUserOperationLogEntry(entryId); // then disableAuthorization(); assertNull(historyService.createUserOperationLogQuery().singleResult()); enableAuthorization(); }
public void testDeleteEntryWithDeleteHistoryPermissionOnProcessDefinition() { // given startProcessInstanceByKey(ONE_TASK_PROCESS_KEY); String taskId = selectSingleTask().getId(); setAssignee(taskId, "demo"); createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, DELETE_HISTORY); disableAuthorization(); String entryId = historyService.createUserOperationLogQuery().singleResult().getId(); enableAuthorization(); // when historyService.deleteUserOperationLogEntry(entryId); // then disableAuthorization(); assertNull(historyService.createUserOperationLogQuery().singleResult()); enableAuthorization(); }
public void testDeleteEntryWithoutAuthorization() { // given startProcessInstanceByKey(ONE_TASK_PROCESS_KEY); String taskId = selectSingleTask().getId(); setAssignee(taskId, "demo"); disableAuthorization(); String entryId = historyService.createUserOperationLogQuery().singleResult().getId(); enableAuthorization(); try { // when historyService.deleteUserOperationLogEntry(entryId); fail("Exception expected: It should not be possible to delete the user operation log"); } catch (AuthorizationException e) { // then String message = e.getMessage(); assertTextPresent(userId, message); assertTextPresent(DELETE_HISTORY.getName(), message); assertTextPresent(ONE_TASK_PROCESS_KEY, message); assertTextPresent(PROCESS_DEFINITION.resourceName(), message); } }
public static void clearUserOperationLog(ProcessEngineConfigurationImpl processEngineConfiguration) { if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) { HistoryService historyService = processEngineConfiguration.getHistoryService(); List<UserOperationLogEntry> logs = historyService.createUserOperationLogQuery().list(); for (UserOperationLogEntry log : logs) { historyService.deleteUserOperationLogEntry(log.getId()); } } }
public void testDeleteEntryAfterDeletingDeployment() { // given String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId(); String taskId = selectSingleTask().getId(); createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ_HISTORY, DELETE_HISTORY); disableAuthorization(); taskService.complete(taskId); enableAuthorization(); deleteDeployment(deploymentId, false); String entryId = historyService.createUserOperationLogQuery().singleResult().getId(); // when historyService.deleteUserOperationLogEntry(entryId); // then disableAuthorization(); assertNull(historyService.createUserOperationLogQuery().singleResult()); enableAuthorization(); disableAuthorization(); historyService.deleteHistoricProcessInstance(processInstanceId); enableAuthorization(); }
@After public void tearDown() throws Exception { identityService.clearAuthentication(); List<UserOperationLogEntry> logs = query().list(); for (UserOperationLogEntry log : logs) { historyService.deleteUserOperationLogEntry(log.getId()); } }
public void testCaseDeleteEntry() { // given createCaseInstanceByKey(ONE_TASK_CASE_KEY); String taskId = selectSingleTask().getId(); setAssignee(taskId, "demo"); String entryId = historyService.createUserOperationLogQuery().singleResult().getId(); // when historyService.deleteUserOperationLogEntry(entryId); // then assertNull(historyService.createUserOperationLogQuery().singleResult()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testDeleteOpLogEntry() { // given startTestProcess(); // an op log instance is created taskService.resolveTask(task.getId()); UserOperationLogEntry opLogEntry = historyService.createUserOperationLogQuery().singleResult(); // when the op log instance is deleted historyService.deleteUserOperationLogEntry(opLogEntry.getId()); // then it should be removed from the database assertEquals(0, historyService.createUserOperationLogQuery().count()); }