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; }
@Test public void shouldResolveBatchJobLog() { // given processEngineConfiguration.setBatchOperationHistoryTimeToLive("P5D"); processEngineConfiguration.initHistoryCleanup(); testRule.deploy(CALLED_PROCESS); testRule.deploy(CALLING_PROCESS); String processInstanceId = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY).getId(); ClockUtil.setCurrentTime(START_DATE); Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason"); HistoricJobLog jobLog = historyService.createHistoricJobLogQuery().singleResult(); // assume assertThat(jobLog.getRemovalTime(), is(addDays(START_DATE, 5))); // when managementService.executeJob(jobLog.getJobId()); List<HistoricJobLog> jobLogs = historyService.createHistoricJobLogQuery().list(); // then assertThat(jobLogs.get(0).getRemovalTime(), is(addDays(START_DATE, 5))); assertThat(jobLogs.get(1).getRemovalTime(), is(addDays(START_DATE, 5))); // cleanup managementService.deleteBatch(batch.getId(), true); }
@Test public void shouldResolveJobLog() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); taskService.complete(taskService.createTaskQuery().singleResult().getId()); String jobId = managementService.createJobQuery() .singleResult() .getId(); try { // when managementService.executeJob(jobId); } catch (Exception ignored) { } List<HistoricJobLog> jobLog = historyService.createHistoricJobLogQuery().list(); // assume assertThat(jobLog.size(), is(2)); Date removalTime = addDays(START_DATE, 5); // then assertThat(jobLog.get(0).getRemovalTime(), is(removalTime)); assertThat(jobLog.get(1).getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveBatchJobLog() { // given processEngineConfiguration.setBatchOperationHistoryTimeToLive("P5D"); processEngineConfiguration.initHistoryCleanup(); testRule.deploy(CALLED_PROCESS); testRule.deploy(CALLING_PROCESS); String processInstanceId = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY).getId(); Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason"); ClockUtil.setCurrentTime(END_DATE); String jobId = managementService.createJobQuery().singleResult().getId(); managementService.executeJob(jobId); List<Job> jobs = managementService.createJobQuery().list(); for (Job job : jobs) { managementService.executeJob(job.getId()); } List<HistoricJobLog> jobLogs = historyService.createHistoricJobLogQuery().list(); // then assertThat(jobLogs.get(0).getRemovalTime(), is(addDays(END_DATE, 5))); assertThat(jobLogs.get(1).getRemovalTime(), is(addDays(END_DATE, 5))); assertThat(jobLogs.get(2).getRemovalTime(), is(addDays(END_DATE, 5))); // cleanup historyService.deleteHistoricBatch(batch.getId()); }
@Test public void shouldResolveJobLog() { // 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) { } List<HistoricJobLog> jobLog = historyService.createHistoricJobLogQuery().list(); // assume assertThat(jobLog.get(0).getRemovalTime(), nullValue()); assertThat(jobLog.get(1).getRemovalTime(), nullValue()); ClockUtil.setCurrentTime(END_DATE); String taskId = taskService.createTaskQuery().singleResult().getId(); // when taskService.complete(taskId); jobLog = historyService.createHistoricJobLogQuery().list(); Date removalTime = addDays(END_DATE, 5); // then assertThat(jobLog.get(0).getRemovalTime(), is(removalTime)); assertThat(jobLog.get(1).getRemovalTime(), is(removalTime)); }
@Test public void shouldNotResolveJobLog() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLED_PROCESS); repositoryService.suspendProcessDefinitionByKey(CALLED_PROCESS_KEY, true, new Date(1363608000000L)); // when HistoricJobLog jobLog = historyService.createHistoricJobLogQuery().singleResult(); // assume assertThat(jobLog, notNullValue()); // then assertThat(jobLog.getRemovalTime(), nullValue()); // cleanup managementService.deleteJob(jobLog.getJobId()); clearJobLog(jobLog.getJobId()); }
@Test public void shouldResolveBatchIncident_SeedJob() { // given processEngineConfiguration.setBatchOperationHistoryTimeToLive("P5D"); processEngineConfiguration.initHistoryCleanup(); testRule.deploy(CALLED_PROCESS); testRule.deploy(CALLING_PROCESS); String processInstanceId = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY).getId(); ClockUtil.setCurrentTime(START_DATE); Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason"); HistoricJobLog jobLog = historyService.createHistoricJobLogQuery().singleResult(); // assume assertThat(jobLog.getRemovalTime(), is(addDays(START_DATE, 5))); // when managementService.setJobRetries(jobLog.getJobId(), 0); HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult(); // then assertThat(historicIncident.getRemovalTime(), is(addDays(START_DATE, 5))); // cleanup managementService.deleteBatch(batch.getId(), true); }
@Test public void shouldResolveBatchIncident_SeedJob() { // given processEngineConfiguration.setBatchOperationHistoryTimeToLive("P5D"); processEngineConfiguration.initHistoryCleanup(); testRule.deploy(CALLED_PROCESS); testRule.deploy(CALLING_PROCESS); String processInstanceId = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY).getId(); ClockUtil.setCurrentTime(START_DATE); Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason"); HistoricJobLog jobLog = historyService.createHistoricJobLogQuery().singleResult(); // assume assertThat(jobLog.getRemovalTime(), nullValue()); managementService.setJobRetries(jobLog.getJobId(), 0); managementService.executeJob(jobLog.getJobId()); List<Job> jobs = managementService.createJobQuery().list(); managementService.executeJob(jobs.get(0).getId()); managementService.executeJob(jobs.get(1).getId()); HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult(); // then assertThat(historicIncident.getRemovalTime(), is(addDays(START_DATE, 5))); // cleanup historyService.deleteHistoricBatch(batch.getId()); }
/** * See https://app.camunda.com/jira/browse/CAM-9505 */ @Test public void shouldNotUpdateCreateTimeForIncidentRelatedToBatch() { // given processEngineConfiguration.setBatchOperationHistoryTimeToLive("P5D"); processEngineConfiguration.initHistoryCleanup(); testRule.deploy(CALLED_PROCESS); testRule.deploy(CALLING_PROCESS); String processInstanceId = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY).getId(); ClockUtil.setCurrentTime(START_DATE); Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason"); HistoricJobLog jobLog = historyService.createHistoricJobLogQuery().singleResult(); // assume assertThat(jobLog.getRemovalTime(), nullValue()); managementService.setJobRetries(jobLog.getJobId(), 0); managementService.executeJob(jobLog.getJobId()); List<Job> jobs = managementService.createJobQuery().list(); managementService.executeJob(jobs.get(0).getId()); managementService.executeJob(jobs.get(1).getId()); HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult(); // then assertThat(historicIncident.getCreateTime(), is(START_DATE)); // cleanup historyService.deleteHistoricBatch(batch.getId()); }
@Test public void shouldResolveBatchIncident_BatchJob() { // given processEngineConfiguration.setBatchOperationHistoryTimeToLive("P5D"); processEngineConfiguration.initHistoryCleanup(); testRule.deploy(CALLED_PROCESS); testRule.deploy(CALLING_PROCESS); String processInstanceId = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY).getId(); ClockUtil.setCurrentTime(START_DATE); Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason"); HistoricJobLog jobLog = historyService.createHistoricJobLogQuery().singleResult(); // assume assertThat(jobLog.getRemovalTime(), is(addDays(START_DATE, 5))); runtimeService.deleteProcessInstance(processInstanceId, "aDeleteReason"); managementService.executeJob(jobLog.getJobId()); String jobId = managementService.createJobQuery() .jobDefinitionId(batch.getBatchJobDefinitionId()) .singleResult() .getId(); // when managementService.setJobRetries(jobId, 0); HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult(); // then assertThat(historicIncident.getRemovalTime(), is(addDays(START_DATE, 5))); // cleanup managementService.deleteBatch(batch.getId(), true); }
assertThat(jobLog.getRemovalTime(), is(addDays(START_DATE, 5)));
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; }
assertThat(jobLog.getRemovalTime(), nullValue());
assertThat(jobLog.getRemovalTime(), nullValue());
@Test public void shouldResolveBatchJobLog() { // given processEngineConfiguration.setBatchOperationHistoryTimeToLive("P5D"); processEngineConfiguration.initHistoryCleanup(); testRule.deploy(CALLED_PROCESS); testRule.deploy(CALLING_PROCESS); String processInstanceId = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY).getId(); ClockUtil.setCurrentTime(START_DATE); // when Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason"); HistoricJobLog jobLog = historyService.createHistoricJobLogQuery().singleResult(); // then assertThat(jobLog.getRemovalTime(), is(addDays(START_DATE, 5))); // when managementService.executeJob(jobLog.getJobId()); List<HistoricJobLog> jobLogs = historyService.createHistoricJobLogQuery().list(); assertThat(jobLogs.get(0).getRemovalTime(), is(addDays(START_DATE, 5))); assertThat(jobLogs.get(1).getRemovalTime(), is(addDays(START_DATE, 5))); // cleanup managementService.deleteBatch(batch.getId(), true); }
@Test public void shouldResolveJobLog() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); taskService.complete(taskService.createTaskQuery().singleResult().getId()); String jobId = managementService.createJobQuery() .singleResult() .getId(); try { // when managementService.executeJob(jobId); } catch (Exception ignored) { } List<HistoricJobLog> jobLog = historyService.createHistoricJobLogQuery().list(); // assume assertThat(jobLog.size(), is(2)); Date removalTime = addDays(START_DATE, 5); // then assertThat(jobLog.get(0).getRemovalTime(), is(removalTime)); assertThat(jobLog.get(1).getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveBatchJobLog() { // given processEngineConfiguration.setBatchOperationHistoryTimeToLive("P5D"); processEngineConfiguration.initHistoryCleanup(); testRule.deploy(CALLED_PROCESS); testRule.deploy(CALLING_PROCESS); String processInstanceId = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY).getId(); Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason"); ClockUtil.setCurrentTime(END_DATE); String jobId = managementService.createJobQuery().singleResult().getId(); managementService.executeJob(jobId); List<Job> jobs = managementService.createJobQuery().list(); for (Job job : jobs) { managementService.executeJob(job.getId()); } List<HistoricJobLog> jobLogs = historyService.createHistoricJobLogQuery().list(); // then assertThat(jobLogs.get(0).getRemovalTime(), is(addDays(END_DATE, 5))); assertThat(jobLogs.get(1).getRemovalTime(), is(addDays(END_DATE, 5))); assertThat(jobLogs.get(2).getRemovalTime(), is(addDays(END_DATE, 5))); // cleanup historyService.deleteHistoricBatch(batch.getId()); }
@Test public void shouldNotResolveJobLog() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLED_PROCESS); repositoryService.suspendProcessDefinitionByKey(CALLED_PROCESS_KEY, true, new Date(1363608000000L)); // when HistoricJobLog jobLog = historyService.createHistoricJobLogQuery().singleResult(); // assume assertThat(jobLog, notNullValue()); // then assertThat(jobLog.getRemovalTime(), nullValue()); // cleanup managementService.deleteJob(jobLog.getJobId()); clearJobLog(jobLog.getJobId()); }
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; }