use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testCreateHistoricJobLogProperties.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testCreateHistoricJobLogProperties() {
runtimeService.startProcessInstanceByKey("process");
Job job = managementService.createJobQuery().singleResult();
HistoricJobLog historicJob = historyService.createHistoricJobLogQuery().creationLog().singleResult();
assertNotNull(historicJob);
assertNotNull(historicJob.getTimestamp());
assertNull(historicJob.getJobExceptionMessage());
assertEquals(job.getId(), historicJob.getJobId());
assertEquals(job.getJobDefinitionId(), historicJob.getJobDefinitionId());
assertEquals("serviceTask", historicJob.getActivityId());
assertEquals(AsyncContinuationJobHandler.TYPE, historicJob.getJobDefinitionType());
assertEquals(MessageJobDeclaration.ASYNC_BEFORE, historicJob.getJobDefinitionConfiguration());
assertEquals(job.getDuedate(), historicJob.getJobDueDate());
assertEquals(job.getRetries(), historicJob.getJobRetries());
assertEquals(job.getExecutionId(), historicJob.getExecutionId());
assertEquals(job.getProcessInstanceId(), historicJob.getProcessInstanceId());
assertEquals(job.getProcessDefinitionId(), historicJob.getProcessDefinitionId());
assertEquals(job.getProcessDefinitionKey(), historicJob.getProcessDefinitionKey());
assertEquals(job.getDeploymentId(), historicJob.getDeploymentId());
assertEquals(job.getPriority(), historicJob.getJobPriority());
assertTrue(historicJob.isCreationLog());
assertFalse(historicJob.isFailureLog());
assertFalse(historicJob.isSuccessLog());
assertFalse(historicJob.isDeletionLog());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testThrowExceptionMessageTruncation.
@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());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testSuccessfulJobEventExecutedByJobExecutor.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testSuccessfulJobEventExecutedByJobExecutor() {
// given
runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("fail", false));
String jobId = managementService.createJobQuery().singleResult().getId();
HistoricJobLogQuery query = historyService.createHistoricJobLogQuery().jobId(jobId);
HistoricJobLogQuery createdQuery = historyService.createHistoricJobLogQuery().jobId(jobId).creationLog();
HistoricJobLogQuery succeededQuery = historyService.createHistoricJobLogQuery().jobId(jobId).successLog();
// there exists one historic job log entry
assertEquals(1, query.count());
assertEquals(1, createdQuery.count());
assertEquals(0, succeededQuery.count());
// when
executeAvailableJobs();
// then
assertEquals(2, query.count());
assertEquals(1, createdQuery.count());
assertEquals(1, succeededQuery.count());
HistoricJobLog createdJobLogEntry = createdQuery.singleResult();
assertEquals(3, createdJobLogEntry.getJobRetries());
HistoricJobLog succeededJobLogEntry = succeededQuery.singleResult();
assertEquals(3, succeededJobLogEntry.getJobRetries());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testFailedHistoricJobLogProperties.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testFailedHistoricJobLogProperties() {
runtimeService.startProcessInstanceByKey("process");
Job job = managementService.createJobQuery().singleResult();
try {
managementService.executeJob(job.getId());
fail();
} catch (Exception e) {
// expected
}
HistoricJobLog historicJob = historyService.createHistoricJobLogQuery().failureLog().singleResult();
assertNotNull(historicJob);
assertNotNull(historicJob.getTimestamp());
assertEquals(job.getId(), historicJob.getJobId());
assertEquals(job.getJobDefinitionId(), historicJob.getJobDefinitionId());
assertEquals("serviceTask", historicJob.getActivityId());
assertEquals(AsyncContinuationJobHandler.TYPE, historicJob.getJobDefinitionType());
assertEquals(MessageJobDeclaration.ASYNC_BEFORE, historicJob.getJobDefinitionConfiguration());
assertEquals(job.getDuedate(), historicJob.getJobDueDate());
assertEquals(3, historicJob.getJobRetries());
assertEquals(job.getExecutionId(), historicJob.getExecutionId());
assertEquals(job.getProcessInstanceId(), historicJob.getProcessInstanceId());
assertEquals(job.getProcessDefinitionId(), historicJob.getProcessDefinitionId());
assertEquals(job.getProcessDefinitionKey(), historicJob.getProcessDefinitionKey());
assertEquals(job.getDeploymentId(), historicJob.getDeploymentId());
assertEquals(FailingDelegate.EXCEPTION_MESSAGE, historicJob.getJobExceptionMessage());
assertEquals(job.getPriority(), historicJob.getJobPriority());
assertFalse(historicJob.isCreationLog());
assertTrue(historicJob.isFailureLog());
assertFalse(historicJob.isSuccessLog());
assertFalse(historicJob.isDeletionLog());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testThrowExceptionWithoutMessage.
@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);
}
Aggregations