use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmdTest method testOpLogSetProcessDefinitionVersionCmd.
public void testOpLogSetProcessDefinitionVersionCmd() {
// given
try {
identityService.setAuthenticatedUserId("demo");
String resource = "org/camunda/bpm/engine/test/api/runtime/migration/SetProcessDefinitionVersionCmdTest.bpmn";
// Deployments
org.camunda.bpm.engine.repository.Deployment firstDeployment = repositoryService.createDeployment().addClasspathResource(resource).deploy();
org.camunda.bpm.engine.repository.Deployment secondDeployment = repositoryService.createDeployment().addClasspathResource(resource).deploy();
// Process definitions
ProcessDefinition processDefinitionV1 = repositoryService.createProcessDefinitionQuery().deploymentId(firstDeployment.getId()).singleResult();
ProcessDefinition processDefinitionV2 = repositoryService.createProcessDefinitionQuery().deploymentId(secondDeployment.getId()).singleResult();
// start process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinitionV1.getId());
// when
setProcessDefinitionVersion(processInstance.getId(), 2);
// then
ProcessInstance processInstanceAfterMigration = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertEquals(processDefinitionV2.getId(), processInstanceAfterMigration.getProcessDefinitionId());
if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
List<UserOperationLogEntry> userOperations = historyService.createUserOperationLogQuery().processInstanceId(processInstance.getId()).list();
assertEquals(1, userOperations.size());
UserOperationLogEntry userOperationLogEntry = userOperations.get(0);
assertEquals(UserOperationLogEntry.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE, userOperationLogEntry.getOperationType());
assertEquals("processDefinitionVersion", userOperationLogEntry.getProperty());
assertEquals("1", userOperationLogEntry.getOrgValue());
assertEquals("2", userOperationLogEntry.getNewValue());
}
// Clean up the test
repositoryService.deleteDeployment(firstDeployment.getId(), true);
repositoryService.deleteDeployment(secondDeployment.getId(), true);
} finally {
identityService.clearAuthentication();
}
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class BatchMigrationUserOperationLogTest method testLogCreation.
@Test
public void testLogCreation() {
// given
ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY));
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
// when
engineRule.getIdentityService().setAuthenticatedUserId(USER_ID);
engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).executeAsync();
engineRule.getIdentityService().clearAuthentication();
// then
List<UserOperationLogEntry> opLogEntries = engineRule.getHistoryService().createUserOperationLogQuery().list();
Assert.assertEquals(3, opLogEntries.size());
Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
UserOperationLogEntry procDefEntry = entries.get("processDefinitionId");
Assert.assertNotNull(procDefEntry);
Assert.assertEquals("ProcessInstance", procDefEntry.getEntityType());
Assert.assertEquals("Migrate", procDefEntry.getOperationType());
Assert.assertEquals(sourceProcessDefinition.getId(), procDefEntry.getProcessDefinitionId());
Assert.assertEquals(sourceProcessDefinition.getKey(), procDefEntry.getProcessDefinitionKey());
Assert.assertNull(procDefEntry.getProcessInstanceId());
Assert.assertEquals(sourceProcessDefinition.getId(), procDefEntry.getOrgValue());
Assert.assertEquals(targetProcessDefinition.getId(), procDefEntry.getNewValue());
UserOperationLogEntry asyncEntry = entries.get("async");
Assert.assertNotNull(asyncEntry);
Assert.assertEquals("ProcessInstance", asyncEntry.getEntityType());
Assert.assertEquals("Migrate", asyncEntry.getOperationType());
Assert.assertEquals(sourceProcessDefinition.getId(), asyncEntry.getProcessDefinitionId());
Assert.assertEquals(sourceProcessDefinition.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("Migrate", numInstancesEntry.getOperationType());
Assert.assertEquals(sourceProcessDefinition.getId(), numInstancesEntry.getProcessDefinitionId());
Assert.assertEquals(sourceProcessDefinition.getKey(), numInstancesEntry.getProcessDefinitionKey());
Assert.assertNull(numInstancesEntry.getProcessInstanceId());
Assert.assertNull(numInstancesEntry.getOrgValue());
Assert.assertEquals("1", numInstancesEntry.getNewValue());
Assert.assertEquals(procDefEntry.getOperationId(), asyncEntry.getOperationId());
Assert.assertEquals(asyncEntry.getOperationId(), numInstancesEntry.getOperationId());
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class BatchHistoricDecisionInstanceDeletionUserOperationTest method testCreationByIds.
@Test
public void testCreationByIds() {
// when
identityService.setAuthenticatedUserId(USER_ID);
historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, "a-delete-reason");
identityService.clearAuthentication();
// then
List<UserOperationLogEntry> opLogEntries = engineRule.getHistoryService().createUserOperationLogQuery().list();
Assert.assertEquals(4, opLogEntries.size());
Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
UserOperationLogEntry typeEntry = entries.get("type");
assertNotNull(typeEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("history", typeEntry.getNewValue());
UserOperationLogEntry asyncEntry = entries.get("async");
assertNotNull(asyncEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("true", asyncEntry.getNewValue());
UserOperationLogEntry numInstancesEntry = entries.get("nrOfInstances");
assertNotNull(numInstancesEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("10", numInstancesEntry.getNewValue());
UserOperationLogEntry deleteReasonEntry = entries.get("deleteReason");
assertNotNull(deleteReasonEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("a-delete-reason", deleteReasonEntry.getNewValue());
assertEquals(typeEntry.getOperationId(), asyncEntry.getOperationId());
assertEquals(asyncEntry.getOperationId(), deleteReasonEntry.getOperationId());
assertEquals(numInstancesEntry.getOperationId(), deleteReasonEntry.getOperationId());
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class BatchHistoricDecisionInstanceDeletionUserOperationTest method testCreationByIdsAndQuery.
@Test
public void testCreationByIdsAndQuery() {
// given
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
// when
identityService.setAuthenticatedUserId(USER_ID);
historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, "a-delete-reason");
identityService.clearAuthentication();
// then
List<UserOperationLogEntry> opLogEntries = engineRule.getHistoryService().createUserOperationLogQuery().list();
Assert.assertEquals(4, opLogEntries.size());
Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
UserOperationLogEntry typeEntry = entries.get("type");
assertNotNull(typeEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("history", typeEntry.getNewValue());
UserOperationLogEntry asyncEntry = entries.get("async");
assertNotNull(asyncEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("true", asyncEntry.getNewValue());
UserOperationLogEntry numInstancesEntry = entries.get("nrOfInstances");
assertNotNull(numInstancesEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("10", numInstancesEntry.getNewValue());
UserOperationLogEntry deleteReasonEntry = entries.get("deleteReason");
assertNotNull(deleteReasonEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("a-delete-reason", deleteReasonEntry.getNewValue());
assertEquals(typeEntry.getOperationId(), asyncEntry.getOperationId());
assertEquals(asyncEntry.getOperationId(), numInstancesEntry.getOperationId());
assertEquals(numInstancesEntry.getOperationId(), deleteReasonEntry.getOperationId());
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class UserOperationLogQueryTest method testQueryJobOperations.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testQueryJobOperations() {
// given
process = runtimeService.startProcessInstanceByKey("process");
// when
managementService.suspendJobDefinitionByProcessDefinitionId(process.getProcessDefinitionId());
managementService.activateJobDefinitionByProcessDefinitionId(process.getProcessDefinitionId());
managementService.suspendJobByProcessInstanceId(process.getId());
managementService.activateJobByProcessInstanceId(process.getId());
// then
assertEquals(2, query().entityType(JOB_DEFINITION).count());
assertEquals(2, query().entityType(JOB).count());
// active job definition
UserOperationLogEntry activeJobDefinitionEntry = query().entityType(JOB_DEFINITION).processDefinitionId(process.getProcessDefinitionId()).operationType(OPERATION_TYPE_ACTIVATE_JOB_DEFINITION).singleResult();
assertNotNull(activeJobDefinitionEntry);
assertEquals(process.getProcessDefinitionId(), activeJobDefinitionEntry.getProcessDefinitionId());
assertEquals(deploymentId, activeJobDefinitionEntry.getDeploymentId());
assertEquals("suspensionState", activeJobDefinitionEntry.getProperty());
assertEquals("active", activeJobDefinitionEntry.getNewValue());
assertNull(activeJobDefinitionEntry.getOrgValue());
// active job
UserOperationLogEntry activateJobIdEntry = query().entityType(JOB).processInstanceId(process.getProcessInstanceId()).operationType(OPERATION_TYPE_ACTIVATE_JOB).singleResult();
assertNotNull(activateJobIdEntry);
assertEquals(process.getProcessInstanceId(), activateJobIdEntry.getProcessInstanceId());
assertEquals(deploymentId, activateJobIdEntry.getDeploymentId());
assertEquals("suspensionState", activateJobIdEntry.getProperty());
assertEquals("active", activateJobIdEntry.getNewValue());
assertNull(activateJobIdEntry.getOrgValue());
// suspended job definition
UserOperationLogEntry suspendJobDefinitionEntry = query().entityType(JOB_DEFINITION).processDefinitionId(process.getProcessDefinitionId()).operationType(OPERATION_TYPE_SUSPEND_JOB_DEFINITION).singleResult();
assertNotNull(suspendJobDefinitionEntry);
assertEquals(process.getProcessDefinitionId(), suspendJobDefinitionEntry.getProcessDefinitionId());
assertEquals(deploymentId, suspendJobDefinitionEntry.getDeploymentId());
assertEquals("suspensionState", suspendJobDefinitionEntry.getProperty());
assertEquals("suspended", suspendJobDefinitionEntry.getNewValue());
assertNull(suspendJobDefinitionEntry.getOrgValue());
// suspended job
UserOperationLogEntry suspendedJobEntry = query().entityType(JOB).processInstanceId(process.getProcessInstanceId()).operationType(OPERATION_TYPE_SUSPEND_JOB).singleResult();
assertNotNull(suspendedJobEntry);
assertEquals(process.getProcessInstanceId(), suspendedJobEntry.getProcessInstanceId());
assertEquals(deploymentId, suspendedJobEntry.getDeploymentId());
assertEquals("suspensionState", suspendedJobEntry.getProperty());
assertEquals("suspended", suspendedJobEntry.getNewValue());
assertNull(suspendedJobEntry.getOrgValue());
}
Aggregations