@Override public Date getProperty(HistoricJobLog obj) { return obj.getTimestamp(); } });
public static HistoricJobLog createMockHistoricJobLog(String tenantId) { HistoricJobLog mock = mock(HistoricJobLog.class); when(mock.getId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_ID); when(mock.getTimestamp()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_JOB_LOG_TIMESTAMP)); when(mock.getRemovalTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_JOB_LOG_REMOVAL_TIME)); when(mock.getJobId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_ID); when(mock.getJobDueDate()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_JOB_LOG_JOB_DUE_DATE)); when(mock.getJobRetries()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_RETRIES); when(mock.getJobPriority()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_PRIORITY); when(mock.getJobExceptionMessage()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_EXCEPTION_MSG); when(mock.getJobDefinitionId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_DEF_ID); when(mock.getJobDefinitionType()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_DEF_TYPE); when(mock.getJobDefinitionConfiguration()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_DEF_CONFIG); when(mock.getActivityId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_ACTIVITY_ID); when(mock.getExecutionId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_EXECUTION_ID); when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_PROC_INST_ID); when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_PROC_DEF_ID); when(mock.getProcessDefinitionKey()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_PROC_DEF_KEY); when(mock.getDeploymentId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_DEPLOYMENT_ID); when(mock.getTenantId()).thenReturn(tenantId); when(mock.getRootProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_ROOT_PROC_INST_ID); when(mock.isCreationLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_CREATION_LOG); when(mock.isFailureLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_FAILURE_LOG); when(mock.isSuccessLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_SUCCESS_LOG); when(mock.isDeletionLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_DELETION_LOG); return mock; }
/** * See https://app.camunda.com/jira/browse/CAM-9505 */ @Test public void shouldResolveBatchJobLogWithTimestampPreserved() { // given processEngineConfiguration.setBatchOperationHistoryTimeToLive("P5D"); processEngineConfiguration.initHistoryCleanup(); testRule.deploy(CALLED_PROCESS); testRule.deploy(CALLING_PROCESS); ClockUtil.setCurrentTime(START_DATE); String processInstanceId = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY).getId(); Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason"); String jobId = managementService.createJobQuery().singleResult().getId(); managementService.executeJob(jobId); List<Job> jobs = managementService.createJobQuery().list(); managementService.executeJob(jobs.get(0).getId()); // when managementService.executeJob(jobs.get(1).getId()); List<HistoricJobLog> jobLogs = historyService.createHistoricJobLogQuery().list(); // then assertThat(jobLogs.get(0).getTimestamp(), is(START_DATE)); assertThat(jobLogs.get(1).getTimestamp(), is(START_DATE)); assertThat(jobLogs.get(2).getTimestamp(), is(START_DATE)); // cleanup historyService.deleteHistoricBatch(batch.getId()); }
@Test public void testHistoricSeedJobLogForBatchDeletion() { Batch batch = helper.migrateProcessInstancesAsync(1); // when Date deletionDate = helper.addSecondsToClock(12); managementService.deleteBatch(batch.getId(), false); // then a deletion historic job log was added HistoricJobLog jobLog = helper.getHistoricSeedJobLog(batch).get(1); assertNotNull(jobLog); assertTrue(jobLog.isDeletionLog()); assertEquals(deletionDate, jobLog.getTimestamp()); }
/** * See https://app.camunda.com/jira/browse/CAM-9505 */ @Test public void shouldResolveJobLogWithTimestampPreserved() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(Bpmn.createExecutableProcess(CALLED_PROCESS_KEY) .startEvent().camundaAsyncBefore() .userTask("userTask").name("userTask") .endEvent().done()); ClockUtil.setCurrentTime(START_DATE); runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String jobId = managementService.createJobQuery() .singleResult() .getId(); try { managementService.executeJob(jobId); } catch (Exception ignored) { } String taskId = taskService.createTaskQuery().singleResult().getId(); // when taskService.complete(taskId); List<HistoricJobLog> jobLog = historyService.createHistoricJobLogQuery().list(); // then assertThat(jobLog.get(0).getTimestamp(), is(START_DATE)); assertThat(jobLog.get(1).getTimestamp(), is(START_DATE)); }
@Test public void testHistoricBatchJobLogForBatchDeletion() { Batch batch = helper.migrateProcessInstancesAsync(1); helper.executeSeedJob(batch); // when Date deletionDate = helper.addSecondsToClock(12); managementService.deleteBatch(batch.getId(), false); // then a deletion historic job log was added HistoricJobLog jobLog = helper.getHistoricBatchJobLog(batch).get(1); assertNotNull(jobLog); assertTrue(jobLog.isDeletionLog()); assertEquals(deletionDate, jobLog.getTimestamp()); }
@Test public void testHistoricMonitorJobLogForBatchDeletion() { Batch batch = helper.migrateProcessInstancesAsync(1); helper.executeSeedJob(batch); // when Date deletionDate = helper.addSecondsToClock(12); managementService.deleteBatch(batch.getId(), false); // then a deletion historic job log was added HistoricJobLog jobLog = helper.getHistoricMonitorJobLog(batch).get(1); assertNotNull(jobLog); assertTrue(jobLog.isDeletionLog()); assertEquals(deletionDate, jobLog.getTimestamp()); }
@Test public void testHistoricSeedJobLogForBatchDeletion() { ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance); Batch batch = helper.startBeforeAsync("process1", 1, "user1", processDefinition.getId()); // when Date deletionDate = helper.addSecondsToClock(12); rule.getManagementService().deleteBatch(batch.getId(), false); // then a deletion historic job log was added HistoricJobLog jobLog = helper.getHistoricSeedJobLog(batch).get(1); assertNotNull(jobLog); assertTrue(jobLog.isDeletionLog()); assertEquals(deletionDate, jobLog.getTimestamp()); }
@Test public void testHistoricBatchJobLogForBatchDeletion() { ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance); Batch batch = helper.startBeforeAsync("process1", 1, "user2", processDefinition.getId()); helper.executeSeedJob(batch); // when Date deletionDate = helper.addSecondsToClock(12); rule.getManagementService().deleteBatch(batch.getId(), false); // then a deletion historic job log was added HistoricJobLog jobLog = helper.getHistoricBatchJobLog(batch).get(1); assertNotNull(jobLog); assertTrue(jobLog.isDeletionLog()); assertEquals(deletionDate, jobLog.getTimestamp()); }
@Test public void testHistoricMonitorJobLogForBatchDeletion() { ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance); Batch batch = helper.startAfterAsync("process1", 1, "user1", processDefinition.getId()); helper.executeSeedJob(batch); // when Date deletionDate = helper.addSecondsToClock(12); rule.getManagementService().deleteBatch(batch.getId(), false); // then a deletion historic job log was added HistoricJobLog jobLog = helper.getHistoricMonitorJobLog(batch).get(1); assertNotNull(jobLog); assertTrue(jobLog.isDeletionLog()); assertEquals(deletionDate, jobLog.getTimestamp()); }
public static HistoricJobLogDto fromHistoricJobLog(HistoricJobLog historicJobLog) { HistoricJobLogDto result = new HistoricJobLogDto(); result.id = historicJobLog.getId(); result.timestamp = historicJobLog.getTimestamp(); result.removalTime = historicJobLog.getRemovalTime(); result.jobId = historicJobLog.getJobId(); result.jobDueDate = historicJobLog.getJobDueDate(); result.jobRetries = historicJobLog.getJobRetries(); result.jobPriority = historicJobLog.getJobPriority(); result.jobExceptionMessage = historicJobLog.getJobExceptionMessage(); result.jobDefinitionId = historicJobLog.getJobDefinitionId(); result.jobDefinitionType = historicJobLog.getJobDefinitionType(); result.jobDefinitionConfiguration = historicJobLog.getJobDefinitionConfiguration(); result.activityId = historicJobLog.getActivityId(); result.executionId = historicJobLog.getExecutionId(); result.processInstanceId = historicJobLog.getProcessInstanceId(); result.processDefinitionId = historicJobLog.getProcessDefinitionId(); result.processDefinitionKey = historicJobLog.getProcessDefinitionKey(); result.deploymentId = historicJobLog.getDeploymentId(); result.tenantId = historicJobLog.getTenantId(); result.rootProcessInstanceId = historicJobLog.getRootProcessInstanceId(); result.creationLog = historicJobLog.isCreationLog(); result.failureLog = historicJobLog.isFailureLog(); result.successLog = historicJobLog.isSuccessLog(); result.deletionLog = historicJobLog.isDeletionLog(); return result; }
public static HistoricJobLogDto fromHistoricJobLog(HistoricJobLog historicJobLog) { HistoricJobLogDto result = new HistoricJobLogDto(); result.id = historicJobLog.getId(); result.timestamp = historicJobLog.getTimestamp(); result.removalTime = historicJobLog.getRemovalTime(); result.jobId = historicJobLog.getJobId(); result.jobDueDate = historicJobLog.getJobDueDate(); result.jobRetries = historicJobLog.getJobRetries(); result.jobPriority = historicJobLog.getJobPriority(); result.jobExceptionMessage = historicJobLog.getJobExceptionMessage(); result.jobDefinitionId = historicJobLog.getJobDefinitionId(); result.jobDefinitionType = historicJobLog.getJobDefinitionType(); result.jobDefinitionConfiguration = historicJobLog.getJobDefinitionConfiguration(); result.activityId = historicJobLog.getActivityId(); result.executionId = historicJobLog.getExecutionId(); result.processInstanceId = historicJobLog.getProcessInstanceId(); result.processDefinitionId = historicJobLog.getProcessDefinitionId(); result.processDefinitionKey = historicJobLog.getProcessDefinitionKey(); result.deploymentId = historicJobLog.getDeploymentId(); result.tenantId = historicJobLog.getTenantId(); result.rootProcessInstanceId = historicJobLog.getRootProcessInstanceId(); result.creationLog = historicJobLog.isCreationLog(); result.failureLog = historicJobLog.isFailureLog(); result.successLog = historicJobLog.isSuccessLog(); result.deletionLog = historicJobLog.isDeletionLog(); return result; }
assertEquals(BatchSeedJobHandler.TYPE, jobLog.getJobDefinitionType()); assertEquals(batch.getId(), jobLog.getJobDefinitionConfiguration()); assertEquals(START_DATE, jobLog.getTimestamp()); assertNull(jobLog.getDeploymentId()); assertNull(jobLog.getProcessDefinitionId()); assertEquals(BatchSeedJobHandler.TYPE, jobLog.getJobDefinitionType()); assertEquals(batch.getId(), jobLog.getJobDefinitionConfiguration()); assertEquals(executionDate, jobLog.getTimestamp()); assertNull(jobLog.getDeploymentId()); assertNull(jobLog.getProcessDefinitionId());
assertEquals(Batch.TYPE_PROCESS_INSTANCE_MIGRATION, jobLog.getJobDefinitionType()); assertEquals(batch.getId(), jobLog.getJobDefinitionConfiguration()); assertEquals(START_DATE, jobLog.getTimestamp()); assertEquals(sourceDeploymentId, jobLog.getDeploymentId()); assertNull(jobLog.getProcessDefinitionId()); assertEquals(Batch.TYPE_PROCESS_INSTANCE_MIGRATION, jobLog.getJobDefinitionType()); assertEquals(batch.getId(), jobLog.getJobDefinitionConfiguration()); assertEquals(executionDate, jobLog.getTimestamp()); assertEquals(sourceDeploymentId, jobLog.getDeploymentId()); assertNull(jobLog.getProcessDefinitionId());
assertEquals(BatchSeedJobHandler.TYPE, jobLog.getJobDefinitionType()); assertEquals(batch.getId(), jobLog.getJobDefinitionConfiguration()); assertEquals(START_DATE, jobLog.getTimestamp()); assertNull(jobLog.getDeploymentId()); assertNull(jobLog.getProcessDefinitionId()); assertEquals(BatchSeedJobHandler.TYPE, jobLog.getJobDefinitionType()); assertEquals(batch.getId(), jobLog.getJobDefinitionConfiguration()); assertEquals(executionDate, jobLog.getTimestamp()); assertNull(jobLog.getDeploymentId()); assertNull(jobLog.getProcessDefinitionId());
assertEquals(Batch.TYPE_PROCESS_INSTANCE_MODIFICATION, jobLog.getJobDefinitionType()); assertEquals(batch.getId(), jobLog.getJobDefinitionConfiguration()); assertEquals(START_DATE, jobLog.getTimestamp()); assertEquals(processDefinition.getDeploymentId(), jobLog.getDeploymentId()); assertNull(jobLog.getProcessDefinitionId()); assertEquals(Batch.TYPE_PROCESS_INSTANCE_MODIFICATION, jobLog.getJobDefinitionType()); assertEquals(batch.getId(), jobLog.getJobDefinitionConfiguration()); assertEquals(executionDate, jobLog.getTimestamp()); assertEquals(processDefinition.getDeploymentId(), jobLog.getDeploymentId()); assertNull(jobLog.getProcessDefinitionId());
assertNotNull(historicJob); assertNotNull(historicJob.getTimestamp());
assertNotNull(historicJob); assertNotNull(historicJob.getTimestamp());
assertNotNull(historicJob); assertNotNull(historicJob.getTimestamp());
assertNotNull(historicJob); assertNotNull(historicJob.getTimestamp());