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; }
assertEquals(FirstFailingDelegate.FIRST_EXCEPTION_MESSAGE, serviceTask1FailedHistoricJobLog.getJobExceptionMessage()); assertEquals(SecondFailingDelegate.SECOND_EXCEPTION_MESSAGE, serviceTask2FailedHistoricJobLog.getJobExceptionMessage());
@Deployment public void testThrowExceptionWithoutMessage() { // given runtimeService.startProcessInstanceByKey("process").getId(); String jobId = managementService.createJobQuery().singleResult().getId(); // when try { managementService.executeJob(jobId); fail(); } catch (Exception e) { // expected } // then HistoricJobLog failedHistoricJobLog = historyService .createHistoricJobLogQuery() .failureLog() .singleResult(); String failedHistoricJobLogId = failedHistoricJobLog.getId(); assertNull(failedHistoricJobLog.getJobExceptionMessage()); String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(failedHistoricJobLogId); assertNotNull(stacktrace); assertTextPresent(ThrowExceptionWithoutMessageDelegate.class.getName(), stacktrace); }
@Deployment public void testThrowExceptionMessageTruncation() { // given String exceptionMessage = randomString(10000); ThrowExceptionWithOverlongMessageDelegate delegate = new ThrowExceptionWithOverlongMessageDelegate(exceptionMessage); runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("delegate", delegate)); Job job = managementService.createJobQuery().singleResult(); // when try { managementService.executeJob(job.getId()); fail(); } catch (Exception e) { // expected } // then HistoricJobLog failedHistoricJobLog = historyService .createHistoricJobLogQuery() .failureLog() .singleResult(); assertNotNull(failedHistoricJobLog); assertEquals(exceptionMessage.substring(0, JobEntity.MAX_EXCEPTION_MESSAGE_LENGTH), failedHistoricJobLog.getJobExceptionMessage()); }
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; }
assertNull(historicJob.getJobExceptionMessage());
assertNull(historicJob.getJobExceptionMessage());
assertNull(historicJob.getJobExceptionMessage());
assertEquals(job.getProcessDefinitionKey(), historicJob.getProcessDefinitionKey()); assertEquals(job.getDeploymentId(), historicJob.getDeploymentId()); assertEquals(FailingDelegate.EXCEPTION_MESSAGE, historicJob.getJobExceptionMessage()); assertEquals(job.getPriority(), historicJob.getJobPriority());
assertEquals(FirstFailingDelegate.FIRST_EXCEPTION_MESSAGE, serviceTask1FailedHistoricJobLog.getJobExceptionMessage()); assertEquals(SecondFailingDelegate.SECOND_EXCEPTION_MESSAGE, serviceTask2FailedHistoricJobLog.getJobExceptionMessage());
@Deployment public void testThrowExceptionWithoutMessage() { // given runtimeService.startProcessInstanceByKey("process").getId(); String jobId = managementService.createJobQuery().singleResult().getId(); // when try { managementService.executeJob(jobId); fail(); } catch (Exception e) { // expected } // then HistoricJobLog failedHistoricJobLog = historyService .createHistoricJobLogQuery() .failureLog() .singleResult(); String failedHistoricJobLogId = failedHistoricJobLog.getId(); assertNull(failedHistoricJobLog.getJobExceptionMessage()); String stacktrace = historyService.getHistoricJobLogExceptionStacktrace(failedHistoricJobLogId); assertNotNull(stacktrace); assertTextPresent(ThrowExceptionWithoutMessageDelegate.class.getName(), stacktrace); }
@Deployment public void testThrowExceptionMessageTruncation() { // given String exceptionMessage = randomString(10000); ThrowExceptionWithOverlongMessageDelegate delegate = new ThrowExceptionWithOverlongMessageDelegate(exceptionMessage); runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("delegate", delegate)); Job job = managementService.createJobQuery().singleResult(); // when try { managementService.executeJob(job.getId()); fail(); } catch (Exception e) { // expected } // then HistoricJobLog failedHistoricJobLog = historyService .createHistoricJobLogQuery() .failureLog() .singleResult(); assertNotNull(failedHistoricJobLog); assertEquals(exceptionMessage.substring(0, JobEntity.MAX_EXCEPTION_MESSAGE_LENGTH), failedHistoricJobLog.getJobExceptionMessage()); }
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; }
assertNull(historicJob.getJobExceptionMessage());
assertNull(historicJob.getJobExceptionMessage());
assertNull(historicJob.getJobExceptionMessage());
assertEquals(job.getProcessDefinitionKey(), historicJob.getProcessDefinitionKey()); assertEquals(job.getDeploymentId(), historicJob.getDeploymentId()); assertEquals(FailingDelegate.EXCEPTION_MESSAGE, historicJob.getJobExceptionMessage()); assertEquals(job.getPriority(), historicJob.getJobPriority());