protected Map<String, UserOperationLogEntry> asMap(List<UserOperationLogEntry> logEntries) { Map<String, UserOperationLogEntry> map = new HashMap<String, UserOperationLogEntry>(); for (UserOperationLogEntry entry : logEntries) { UserOperationLogEntry previousValue = map.put(entry.getProperty(), entry); if (previousValue != null) { fail("expected only entry for every property"); } } return map; }
protected Map<String, UserOperationLogEntry> asMap(List<UserOperationLogEntry> logEntries) { Map<String, UserOperationLogEntry> map = new HashMap<String, UserOperationLogEntry>(); for (UserOperationLogEntry entry : logEntries) { UserOperationLogEntry previousValue = map.put(entry.getProperty(), entry); if (previousValue != null) { Assert.fail("expected only entry for every property"); } } return map; } }
protected Map<String, UserOperationLogEntry> asMap(List<UserOperationLogEntry> logEntries) { Map<String, UserOperationLogEntry> map = new HashMap<String, UserOperationLogEntry>(); for (UserOperationLogEntry entry : logEntries) { UserOperationLogEntry previousValue = map.put(entry.getProperty(), entry); if (previousValue != null) { Assert.fail("expected only entry for every property"); } } return map; } }
protected Map<String, UserOperationLogEntry> asMap(List<UserOperationLogEntry> logEntries) { Map<String, UserOperationLogEntry> map = new HashMap<String, UserOperationLogEntry>(); for (UserOperationLogEntry entry : logEntries) { UserOperationLogEntry previousValue = map.put(entry.getProperty(), entry); if (previousValue != null) { Assert.fail("expected only entry for every property"); } } return map; } }
protected Map<String, UserOperationLogEntry> asMap(List<UserOperationLogEntry> logEntries) { Map<String, UserOperationLogEntry> map = new HashMap<String, UserOperationLogEntry>(); for (UserOperationLogEntry entry : logEntries) { UserOperationLogEntry previousValue = map.put(entry.getProperty(), entry); if (previousValue != null) { Assert.fail("expected only entry for every property"); } } return map; } }
protected Map<String, UserOperationLogEntry> asMap(List<UserOperationLogEntry> logEntries) { Map<String, UserOperationLogEntry> map = new HashMap<String, UserOperationLogEntry>(); for (UserOperationLogEntry entry : logEntries) { UserOperationLogEntry previousValue = map.put(entry.getProperty(), entry); if (previousValue != null) { fail("expected only entry for every property"); } } return map; }
protected Map<String, UserOperationLogEntry> asMap(List<UserOperationLogEntry> logEntries) { Map<String, UserOperationLogEntry> map = new HashMap<String, UserOperationLogEntry>(); for (UserOperationLogEntry entry : logEntries) { UserOperationLogEntry previousValue = map.put(entry.getProperty(), entry); if (previousValue != null) { Assert.fail("expected only entry for every property"); } } return map; } }
public void testDeleteTask() { // given: a single task task = taskService.newTask(); taskService.saveTask(task); // then: delete the task taskService.deleteTask(task.getId(), "duplicated"); // expect: one entry for the deletion UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_DELETE); assertEquals(1, query.count()); // assert: details UserOperationLogEntry delete = query.singleResult(); assertEquals(DELETE, delete.getProperty()); assertFalse(Boolean.parseBoolean(delete.getOrgValue())); assertTrue(Boolean.parseBoolean(delete.getNewValue())); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testCreateAndCompleteTask() { startTestProcess(); // expect: no entry for the task creation by process engine UserOperationLogQuery query = historyService.createUserOperationLogQuery(); assertEquals(0, query.count()); completeTestProcess(); // expect: one entry for the task completion query = queryOperationDetails(OPERATION_TYPE_COMPLETE); assertEquals(1, query.count()); UserOperationLogEntry complete = query.singleResult(); assertEquals(DELETE, complete.getProperty()); assertTrue(Boolean.parseBoolean(complete.getNewValue())); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/asyncTaskProcess.bpmn20.xml"}) public void testOverwriteOverridingPriority() { // given a job definition JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // with an overriding priority ClockUtil.setCurrentTime(new Date(System.currentTimeMillis())); managementService.setOverridingJobPriorityForJobDefinition(jobDefinition.getId(), 42); // when I overwrite that priority ClockUtil.setCurrentTime(new Date(System.currentTimeMillis() + 10000)); managementService.setOverridingJobPriorityForJobDefinition(jobDefinition.getId(), 43); // then this is accessible via the op log UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery() .orderByTimestamp().desc().listPage(0, 1).get(0); assertNotNull(userOperationLogEntry); assertEquals(EntityTypes.JOB_DEFINITION, userOperationLogEntry.getEntityType()); assertEquals(jobDefinition.getId(), userOperationLogEntry.getJobDefinitionId()); assertEquals(UserOperationLogEntry.OPERATION_TYPE_SET_PRIORITY, userOperationLogEntry.getOperationType()); assertEquals("overridingPriority", userOperationLogEntry.getProperty()); assertEquals("43", userOperationLogEntry.getNewValue()); assertEquals("42", userOperationLogEntry.getOrgValue()); }
public void testCompositeBeanInteraction() { // given: a manually created task task = taskService.newTask(); // then: save the task without any property change taskService.saveTask(task); // expect: no entry UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_CREATE); UserOperationLogEntry create = query.singleResult(); assertNotNull(create); assertEquals(ENTITY_TYPE_TASK, create.getEntityType()); assertNull(create.getOrgValue()); assertNull(create.getNewValue()); assertNull(create.getProperty()); task.setAssignee("icke"); task.setName("to do"); // then: save the task again taskService.saveTask(task); // expect: two update entries with the same operation id List<UserOperationLogEntry> entries = queryOperationDetails(OPERATION_TYPE_UPDATE).list(); assertEquals(2, entries.size()); assertEquals(entries.get(0).getOperationId(), entries.get(1).getOperationId()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testClaimTask() { startTestProcess(); // then: claim a new the task taskService.claim(task.getId(), "icke"); // expect: one entry for the claim UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_CLAIM); assertEquals(1, query.count()); // assert: details UserOperationLogEntry claim = query.singleResult(); assertEquals(ASSIGNEE, claim.getProperty()); assertEquals("icke", claim.getNewValue()); completeTestProcess(); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testAssignTask() { startTestProcess(); // then: assign the task taskService.setAssignee(task.getId(), "icke"); // expect: one entry for the task assignment UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_ASSIGN); assertEquals(1, query.count()); // assert: details UserOperationLogEntry assign = query.singleResult(); assertEquals(ASSIGNEE, assign.getProperty()); assertEquals("icke", assign.getNewValue()); completeTestProcess(); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testChangeTaskOwner() { startTestProcess(); // then: change the task owner taskService.setOwner(task.getId(), "icke"); // expect: one entry for the owner change UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_SET_OWNER); assertEquals(1, query.count()); // assert: details UserOperationLogEntry change = query.singleResult(); assertEquals(OWNER, change.getProperty()); assertEquals("icke", change.getNewValue()); completeTestProcess(); }
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void shouldCreateUserOperationLogForBatchSuspension() { // given Batch batch = helper.migrateProcessInstancesAsync(1); // when identityService.setAuthenticatedUserId(USER_ID); managementService.suspendBatchById(batch.getId()); identityService.clearAuthentication(); // then UserOperationLogEntry entry = historyService.createUserOperationLogQuery() .singleResult(); assertNotNull(entry); assertEquals(batch.getId(), entry.getBatchId()); assertEquals(AbstractSetBatchStateCmd.SUSPENSION_STATE_PROPERTY, entry.getProperty()); assertNull(entry.getOrgValue()); assertEquals(SuspensionState.SUSPENDED.getName(), entry.getNewValue()); }
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void shouldCreateUserOperationLogForBatchActivation() { // given Batch batch = helper.migrateProcessInstancesAsync(1); managementService.suspendBatchById(batch.getId()); // when identityService.setAuthenticatedUserId(USER_ID); managementService.activateBatchById(batch.getId()); identityService.clearAuthentication(); // then UserOperationLogEntry entry = historyService.createUserOperationLogQuery() .singleResult(); assertNotNull(entry); assertEquals(batch.getId(), entry.getBatchId()); assertEquals(AbstractSetBatchStateCmd.SUSPENSION_STATE_PROPERTY, entry.getProperty()); assertNull(entry.getOrgValue()); assertEquals(SuspensionState.ACTIVE.getName(), entry.getNewValue()); }
public void testCreateDeployment() { // when Deployment deployment = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addModelInstance(RESOURCE_NAME, createProcessWithServiceTask(PROCESS_KEY)) .deploy(); // then UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery().singleResult(); assertNotNull(userOperationLogEntry); assertEquals(EntityTypes.DEPLOYMENT, userOperationLogEntry.getEntityType()); assertEquals(deployment.getId(), userOperationLogEntry.getDeploymentId()); assertEquals(UserOperationLogEntry.OPERATION_TYPE_CREATE, userOperationLogEntry.getOperationType()); assertEquals("duplicateFilterEnabled", userOperationLogEntry.getProperty()); assertNull(userOperationLogEntry.getOrgValue()); assertFalse(Boolean.valueOf(userOperationLogEntry.getNewValue())); assertEquals(USER_ID, userOperationLogEntry.getUserId()); assertNull(userOperationLogEntry.getJobDefinitionId()); assertNull(userOperationLogEntry.getProcessInstanceId()); assertNull(userOperationLogEntry.getProcessDefinitionId()); assertNull(userOperationLogEntry.getProcessDefinitionKey()); assertNull(userOperationLogEntry.getCaseInstanceId()); assertNull(userOperationLogEntry.getCaseDefinitionId()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/asyncTaskProcess.bpmn20.xml"}) public void testSetOverridingPriority() { // given a job definition JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when I set a job priority managementService.setOverridingJobPriorityForJobDefinition(jobDefinition.getId(), 42); // then an op log entry is written UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery().singleResult(); assertNotNull(userOperationLogEntry); assertEquals(EntityTypes.JOB_DEFINITION, userOperationLogEntry.getEntityType()); assertEquals(jobDefinition.getId(), userOperationLogEntry.getJobDefinitionId()); assertEquals(UserOperationLogEntry.OPERATION_TYPE_SET_PRIORITY, userOperationLogEntry.getOperationType()); assertEquals("overridingPriority", userOperationLogEntry.getProperty()); assertEquals("42", userOperationLogEntry.getNewValue()); assertEquals(null, userOperationLogEntry.getOrgValue()); assertEquals(USER_ID, userOperationLogEntry.getUserId()); assertEquals(jobDefinition.getProcessDefinitionId(), userOperationLogEntry.getProcessDefinitionId()); assertEquals(jobDefinition.getProcessDefinitionKey(), userOperationLogEntry.getProcessDefinitionKey()); assertEquals(deploymentId, userOperationLogEntry.getDeploymentId()); }
@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()); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/async/FoxJobRetryCmdTest.testFailedServiceTask.bpmn20.xml" }) public void testQueryJobRetryOperationsById() { // given process = runtimeService.startProcessInstanceByKey("failedServiceTask"); Job job = managementService.createJobQuery().processInstanceId(process.getProcessInstanceId()).singleResult(); managementService.setJobRetries(job.getId(), 10); // then assertEquals(1, query().entityType(JOB).operationType(OPERATION_TYPE_SET_JOB_RETRIES).count()); UserOperationLogEntry jobRetryEntry = query() .entityType(JOB) .jobId(job.getId()) .operationType(OPERATION_TYPE_SET_JOB_RETRIES) .singleResult(); assertNotNull(jobRetryEntry); assertEquals(job.getId(), jobRetryEntry.getJobId()); assertEquals("3", jobRetryEntry.getOrgValue()); assertEquals("10", jobRetryEntry.getNewValue()); assertEquals("retries", jobRetryEntry.getProperty()); assertEquals(job.getJobDefinitionId(), jobRetryEntry.getJobDefinitionId()); assertEquals(job.getProcessInstanceId(), jobRetryEntry.getProcessInstanceId()); assertEquals(job.getProcessDefinitionKey(), jobRetryEntry.getProcessDefinitionKey()); assertEquals(job.getProcessDefinitionId(), jobRetryEntry.getProcessDefinitionId()); }