use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class BatchHistoricDecisionInstanceDeletionUserOperationTest method testCreationByQuery.
@Test
public void testCreationByQuery() {
// given
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
// when
identityService.setAuthenticatedUserId(USER_ID);
historyService.deleteHistoricDecisionInstancesAsync(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 UserOperationIdTest method testWithoutAuthentication.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testWithoutAuthentication() {
// given
runtimeService.startProcessInstanceByKey(PROCESS_KEY);
String taskId = taskService.createTaskQuery().singleResult().getId();
// when
taskService.resolveTask(taskId, getVariables());
// then
List<UserOperationLogEntry> userOperationLogEntries = historyService.createUserOperationLogQuery().taskId(taskId).list();
assertEquals(0, userOperationLogEntries.size());
List<HistoricDetail> historicDetails = historyService.createHistoricDetailQuery().list();
assertTrue(historicDetails.size() > 0);
// history detail records must have null userOperationId as user operation log was not created
for (HistoricDetail historicDetail : historicDetails) {
assertNull(historicDetail.getUserOperationId());
}
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class UserOperationIdTest method verifySameOperationId.
private void verifySameOperationId(List<UserOperationLogEntry> userOperationLogEntries, List<HistoricDetail> historicDetails) {
assertTrue("Operation log entry must exist", userOperationLogEntries.size() > 0);
String operationId = userOperationLogEntries.get(0).getOperationId();
assertNotNull(operationId);
assertTrue("Some historic details are expected to be present", historicDetails.size() > 0);
for (UserOperationLogEntry userOperationLogEntry : userOperationLogEntries) {
assertEquals("OperationIds must be the same", operationId, userOperationLogEntry.getOperationId());
}
for (HistoricDetail historicDetail : historicDetails) {
assertEquals("OperationIds must be the same", operationId, historicDetail.getUserOperationId());
}
}
use of org.camunda.bpm.engine.history.UserOperationLogEntry in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceUserOperationLogTest method testLogCreationSync.
@Test
public void testLogCreationSync() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
rule.getIdentityService().setAuthenticatedUserId("userId");
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("process1");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("process1");
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startAfterActivity("user1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).execute();
rule.getIdentityService().clearAuthentication();
// then
List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().operationType("RestartProcessInstance").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("RestartProcessInstance", asyncEntry.getOperationType());
Assert.assertEquals(processDefinition.getId(), asyncEntry.getProcessDefinitionId());
Assert.assertEquals(processDefinition.getKey(), asyncEntry.getProcessDefinitionKey());
Assert.assertNull(asyncEntry.getProcessInstanceId());
Assert.assertNull(asyncEntry.getOrgValue());
Assert.assertEquals("false", asyncEntry.getNewValue());
UserOperationLogEntry numInstancesEntry = entries.get("nrOfInstances");
Assert.assertNotNull(numInstancesEntry);
Assert.assertEquals("ProcessInstance", numInstancesEntry.getEntityType());
Assert.assertEquals("RestartProcessInstance", numInstancesEntry.getOperationType());
Assert.assertEquals(processDefinition.getId(), numInstancesEntry.getProcessDefinitionId());
Assert.assertEquals(processDefinition.getKey(), numInstancesEntry.getProcessDefinitionKey());
Assert.assertNull(numInstancesEntry.getProcessInstanceId());
Assert.assertNull(numInstancesEntry.getOrgValue());
Assert.assertEquals("2", 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 BatchSuspensionTest method shouldCreateUserOperationLogForBatchSuspension.
@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());
}
Aggregations