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; }
@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 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; }
@Deployment(resources = {"org/camunda/bpm/engine/test/history/asyncTaskProcess.bpmn20.xml"}) public void testClearOverridingPriority() { // 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 clear that priority ClockUtil.setCurrentTime(new Date(System.currentTimeMillis() + 10000)); managementService.clearOverridingJobPriorityForJobDefinition(jobDefinition.getId()); // 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()); assertNull(userOperationLogEntry.getNewValue()); assertEquals("42", userOperationLogEntry.getOrgValue()); assertEquals(USER_ID, userOperationLogEntry.getUserId()); assertEquals(jobDefinition.getProcessDefinitionId(), userOperationLogEntry.getProcessDefinitionId()); assertEquals(jobDefinition.getProcessDefinitionKey(), userOperationLogEntry.getProcessDefinitionKey()); assertEquals(deploymentId, userOperationLogEntry.getDeploymentId()); }
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 assertUserOperationLogs() { List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list(); UserOperationLogQuery userOperationLogQuery = historyService .createUserOperationLogQuery() .operationType(UserOperationLogEntry.OPERATION_TYPE_DELETE); List<UserOperationLogEntry> userOperationLogs = userOperationLogQuery.list(); assertEquals(3, userOperationLogs.size()); for (ProcessDefinition processDefinition: processDefinitions) { UserOperationLogEntry userOperationLogEntry = userOperationLogQuery .deploymentId(processDefinition.getDeploymentId()).singleResult(); assertEquals(EntityTypes.PROCESS_DEFINITION, userOperationLogEntry.getEntityType()); assertEquals(processDefinition.getId(), userOperationLogEntry.getProcessDefinitionId()); assertEquals(processDefinition.getKey(), userOperationLogEntry.getProcessDefinitionKey()); assertEquals(processDefinition.getDeploymentId(), userOperationLogEntry.getDeploymentId()); assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, userOperationLogEntry.getOperationType()); assertEquals("cascade", userOperationLogEntry.getProperty()); assertFalse(Boolean.valueOf(userOperationLogEntry.getOrgValue())); assertTrue(Boolean.valueOf(userOperationLogEntry.getNewValue())); assertEquals(USER_ID, userOperationLogEntry.getUserId()); assertNull(userOperationLogEntry.getJobDefinitionId()); assertNull(userOperationLogEntry.getProcessInstanceId()); assertNull(userOperationLogEntry.getCaseInstanceId()); assertNull(userOperationLogEntry.getCaseDefinitionId()); } assertEquals(6, historyService.createUserOperationLogQuery().count()); }
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()); }
public void testCreateDeploymentPa() { // given EmbeddedProcessApplication application = new EmbeddedProcessApplication(); // when Deployment deployment = repositoryService .createDeployment(application.getReference()) .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()); }
assertNull(log.getJobDefinitionId()); assertNull(log.getProcessInstanceId()); assertNull(log.getCaseInstanceId());
assertNull(log.getJobDefinitionId()); assertNull(log.getProcessInstanceId()); assertNull(log.getCaseInstanceId());
@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()); }
public void testDeleteDeployment() { // given Deployment deployment = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addModelInstance(RESOURCE_NAME, createProcessWithServiceTask(PROCESS_KEY)) .deploy(); UserOperationLogQuery query = historyService .createUserOperationLogQuery() .operationType(UserOperationLogEntry.OPERATION_TYPE_DELETE); // when repositoryService.deleteDeployment(deployment.getId(), false); // then assertEquals(1, query.count()); UserOperationLogEntry log = query.singleResult(); assertNotNull(log); assertEquals(EntityTypes.DEPLOYMENT, log.getEntityType()); assertEquals(deployment.getId(), log.getDeploymentId()); assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, log.getOperationType()); assertEquals("cascade", log.getProperty()); assertNull(log.getOrgValue()); assertFalse(Boolean.valueOf(log.getNewValue())); assertEquals(USER_ID, log.getUserId()); assertNull(log.getJobDefinitionId()); assertNull(log.getProcessInstanceId()); assertNull(log.getProcessDefinitionId()); assertNull(log.getProcessDefinitionKey()); assertNull(log.getCaseInstanceId()); assertNull(log.getCaseDefinitionId()); }
public void testDeleteDeploymentCascading() { // given Deployment deployment = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addModelInstance(RESOURCE_NAME, createProcessWithServiceTask(PROCESS_KEY)) .deploy(); UserOperationLogQuery query = historyService .createUserOperationLogQuery() .operationType(UserOperationLogEntry.OPERATION_TYPE_DELETE); // when repositoryService.deleteDeployment(deployment.getId(), true); // then assertEquals(1, query.count()); UserOperationLogEntry log = query.singleResult(); assertNotNull(log); assertEquals(EntityTypes.DEPLOYMENT, log.getEntityType()); assertEquals(deployment.getId(), log.getDeploymentId()); assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, log.getOperationType()); assertEquals("cascade", log.getProperty()); assertNull(log.getOrgValue()); assertTrue(Boolean.valueOf(log.getNewValue())); assertEquals(USER_ID, log.getUserId()); assertNull(log.getJobDefinitionId()); assertNull(log.getProcessInstanceId()); assertNull(log.getProcessDefinitionId()); assertNull(log.getProcessDefinitionKey()); assertNull(log.getCaseInstanceId()); assertNull(log.getCaseDefinitionId()); }
assertEquals(job.getJobDefinitionId(), userOperationLogEntry.getJobDefinitionId()); assertEquals(job.getProcessInstanceId(), userOperationLogEntry.getProcessInstanceId()); assertEquals(job.getProcessDefinitionId(), userOperationLogEntry.getProcessDefinitionId());
@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()); }
@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()); assertEquals(deploymentId, jobRetryEntry.getDeploymentId()); }
assertEquals(job.getJobDefinitionId(), jobOpLogEntry.getJobDefinitionId()); assertNull("an unspecified set of process instances was affected by the operation", jobOpLogEntry.getProcessInstanceId());
@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 testCreateDeploymentPa() { // given EmbeddedProcessApplication application = new EmbeddedProcessApplication(); // when Deployment deployment = repositoryService .createDeployment(application.getReference()) .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()); }