use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class ModificationUserOperationLogTest method testLogCreation.
@Test
public void testLogCreation() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
rule.getIdentityService().setAuthenticatedUserId("userId");
// when
helper.startBeforeAsync("process1", 10, "user2", processDefinition.getId());
rule.getIdentityService().clearAuthentication();
// then
List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().list();
Assert.assertEquals(2, opLogEntries.size());
Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
UserOperationLogEntry asyncEntry = entries.get("async");
Assert.assertNotNull(asyncEntry);
Assert.assertEquals("ProcessInstance", asyncEntry.getEntityType());
Assert.assertEquals("ModifyProcessInstance", asyncEntry.getOperationType());
Assert.assertEquals(processDefinition.getId(), asyncEntry.getProcessDefinitionId());
Assert.assertEquals(processDefinition.getKey(), asyncEntry.getProcessDefinitionKey());
Assert.assertNull(asyncEntry.getProcessInstanceId());
Assert.assertNull(asyncEntry.getOrgValue());
Assert.assertEquals("true", asyncEntry.getNewValue());
UserOperationLogEntry numInstancesEntry = entries.get("nrOfInstances");
Assert.assertNotNull(numInstancesEntry);
Assert.assertEquals("ProcessInstance", numInstancesEntry.getEntityType());
Assert.assertEquals("ModifyProcessInstance", numInstancesEntry.getOperationType());
Assert.assertEquals(processDefinition.getId(), numInstancesEntry.getProcessDefinitionId());
Assert.assertEquals(processDefinition.getKey(), numInstancesEntry.getProcessDefinitionKey());
Assert.assertNull(numInstancesEntry.getProcessInstanceId());
Assert.assertNull(numInstancesEntry.getOrgValue());
Assert.assertEquals("10", numInstancesEntry.getNewValue());
Assert.assertEquals(asyncEntry.getOperationId(), numInstancesEntry.getOperationId());
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class UpdateSuspendStateUserOperationLogTest method testLogCreation.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml" })
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testLogCreation() {
// given
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
rule.getIdentityService().setAuthenticatedUserId("userId");
// when
Batch suspendprocess = runtimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(Arrays.asList(processInstance1.getId(), processInstance2.getId())).suspendAsync();
helper.executeSeedJob(suspendprocess);
helper.executeJobs(suspendprocess);
rule.getIdentityService().clearAuthentication();
// then
List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().list();
assertEquals(2, opLogEntries.size());
Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
UserOperationLogEntry asyncEntry = entries.get("async");
assertNotNull(asyncEntry);
assertEquals("ProcessInstance", asyncEntry.getEntityType());
assertEquals("SuspendJob", asyncEntry.getOperationType());
assertNull(asyncEntry.getProcessInstanceId());
assertNull(asyncEntry.getOrgValue());
assertEquals("true", asyncEntry.getNewValue());
UserOperationLogEntry numInstancesEntry = entries.get("nrOfInstances");
assertNotNull(numInstancesEntry);
assertEquals("ProcessInstance", numInstancesEntry.getEntityType());
assertEquals("SuspendJob", numInstancesEntry.getOperationType());
assertNull(numInstancesEntry.getProcessInstanceId());
assertNull(numInstancesEntry.getProcessDefinitionKey());
assertNull(numInstancesEntry.getProcessDefinitionId());
assertNull(numInstancesEntry.getOrgValue());
assertEquals("2", numInstancesEntry.getNewValue());
assertEquals(asyncEntry.getOperationId(), numInstancesEntry.getOperationId());
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class UserOperationLogJobDefinitionTest method testSetOverridingPriority.
@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());
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class UserOperationLogJobDefinitionTest method testSetOverridingPriorityCascadeToJobs.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/asyncTaskProcess.bpmn20.xml" })
public void testSetOverridingPriorityCascadeToJobs() {
// given a job definition and job
runtimeService.startProcessInstanceByKey("asyncTaskProcess");
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
Job job = managementService.createJobQuery().singleResult();
// when I set an overriding priority with cascade=true
managementService.setOverridingJobPriorityForJobDefinition(jobDefinition.getId(), 42, true);
// then there are two op log entries
assertEquals(2, historyService.createUserOperationLogQuery().count());
// (1): One for the job definition priority
UserOperationLogEntry jobDefOpLogEntry = historyService.createUserOperationLogQuery().entityType(EntityTypes.JOB_DEFINITION).singleResult();
assertNotNull(jobDefOpLogEntry);
// (2): and another one for the job priorities
UserOperationLogEntry jobOpLogEntry = historyService.createUserOperationLogQuery().entityType(EntityTypes.JOB).singleResult();
assertNotNull(jobOpLogEntry);
assertEquals("both entries should be part of the same operation", jobDefOpLogEntry.getOperationId(), jobOpLogEntry.getOperationId());
assertEquals(EntityTypes.JOB, jobOpLogEntry.getEntityType());
assertNull("id should null because it is a bulk update operation", jobOpLogEntry.getJobId());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_SET_PRIORITY, jobOpLogEntry.getOperationType());
assertEquals("priority", jobOpLogEntry.getProperty());
assertEquals("42", jobOpLogEntry.getNewValue());
assertNull("Original Value should be null because it is not known for bulk operations", jobOpLogEntry.getOrgValue());
assertEquals(USER_ID, jobOpLogEntry.getUserId());
// these properties should be there to narrow down the bulk update (like a SQL WHERE clasue)
assertEquals(job.getJobDefinitionId(), jobOpLogEntry.getJobDefinitionId());
assertNull("an unspecified set of process instances was affected by the operation", jobOpLogEntry.getProcessInstanceId());
assertEquals(job.getProcessDefinitionId(), jobOpLogEntry.getProcessDefinitionId());
assertEquals(job.getProcessDefinitionKey(), jobOpLogEntry.getProcessDefinitionKey());
assertEquals(deploymentId, jobOpLogEntry.getDeploymentId());
}
Aggregations