use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testStartTimerEventJobHandlerType.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testStartTimerEvent.bpmn20.xml" })
public void testStartTimerEventJobHandlerType() {
Job job = managementService.createJobQuery().singleResult();
HistoricJobLog historicJob = historyService.createHistoricJobLogQuery().jobId(job.getId()).singleResult();
assertNotNull(historicJob);
assertEquals(job.getId(), historicJob.getJobId());
assertEquals(job.getJobDefinitionId(), historicJob.getJobDefinitionId());
assertEquals("theStart", historicJob.getActivityId());
assertEquals(TimerStartEventJobHandler.TYPE, historicJob.getJobDefinitionType());
assertEquals("CYCLE: 0 0/5 * * * ?", historicJob.getJobDefinitionConfiguration());
assertEquals(job.getDuedate(), historicJob.getJobDueDate());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testFailedJobEvents.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testFailedJobEvents() {
// given
runtimeService.startProcessInstanceByKey("process");
String jobId = managementService.createJobQuery().singleResult().getId();
HistoricJobLogQuery query = historyService.createHistoricJobLogQuery().jobId(jobId);
HistoricJobLogQuery createdQuery = historyService.createHistoricJobLogQuery().jobId(jobId).creationLog();
HistoricJobLogQuery failedQuery = historyService.createHistoricJobLogQuery().jobId(jobId).failureLog().orderByJobRetries().desc();
// there exists one historic job log entry
assertEquals(1, query.count());
assertEquals(1, createdQuery.count());
assertEquals(0, failedQuery.count());
// when (1)
try {
managementService.executeJob(jobId);
fail();
} catch (Exception e) {
// expected
}
// then (1)
assertEquals(2, query.count());
assertEquals(1, createdQuery.count());
assertEquals(1, failedQuery.count());
HistoricJobLog createdJobLogEntry = createdQuery.singleResult();
assertEquals(3, createdJobLogEntry.getJobRetries());
HistoricJobLog failedJobLogEntry = failedQuery.singleResult();
assertEquals(3, failedJobLogEntry.getJobRetries());
// when (2)
try {
managementService.executeJob(jobId);
fail();
} catch (Exception e) {
// expected
}
// then (2)
assertEquals(3, query.count());
assertEquals(1, createdQuery.count());
assertEquals(2, failedQuery.count());
createdJobLogEntry = createdQuery.singleResult();
assertEquals(3, createdJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(0);
assertEquals(3, failedJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(1);
assertEquals(2, failedJobLogEntry.getJobRetries());
// when (3)
try {
managementService.executeJob(jobId);
fail();
} catch (Exception e) {
// expected
}
// then (3)
assertEquals(4, query.count());
assertEquals(1, createdQuery.count());
assertEquals(3, failedQuery.count());
createdJobLogEntry = createdQuery.singleResult();
assertEquals(3, createdJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(0);
assertEquals(3, failedJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(1);
assertEquals(2, failedJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(2);
assertEquals(1, failedJobLogEntry.getJobRetries());
// when (4)
try {
managementService.executeJob(jobId);
fail();
} catch (Exception e) {
// expected
}
// then (4)
assertEquals(5, query.count());
assertEquals(1, createdQuery.count());
assertEquals(4, failedQuery.count());
createdJobLogEntry = createdQuery.singleResult();
assertEquals(3, createdJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(0);
assertEquals(3, failedJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(1);
assertEquals(2, failedJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(2);
assertEquals(1, failedJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(3);
assertEquals(0, failedJobLogEntry.getJobRetries());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testErrorEndEventInterruptingCallActivity.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testSuperProcessWithCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testSubProcessWithErrorEndEvent.bpmn20.xml" })
public void testErrorEndEventInterruptingCallActivity() {
// given
runtimeService.startProcessInstanceByKey("process").getId();
HistoricJobLogQuery query = historyService.createHistoricJobLogQuery();
assertEquals(2, query.count());
// serviceTask1
String serviceTask1JobId = managementService.createJobQuery().activityId("serviceTask1").singleResult().getId();
HistoricJobLogQuery serviceTask1Query = historyService.createHistoricJobLogQuery().jobId(serviceTask1JobId);
HistoricJobLogQuery serviceTask1CreatedQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask1JobId).creationLog();
HistoricJobLogQuery serviceTask1DeletedQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask1JobId).deletionLog();
HistoricJobLogQuery serviceTask1SuccessfulQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask1JobId).successLog();
assertEquals(1, serviceTask1Query.count());
assertEquals(1, serviceTask1CreatedQuery.count());
assertEquals(0, serviceTask1DeletedQuery.count());
assertEquals(0, serviceTask1SuccessfulQuery.count());
// serviceTask2
String serviceTask2JobId = managementService.createJobQuery().activityId("serviceTask2").singleResult().getId();
HistoricJobLogQuery serviceTask2Query = historyService.createHistoricJobLogQuery().jobId(serviceTask2JobId);
HistoricJobLogQuery serviceTask2CreatedQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask2JobId).creationLog();
HistoricJobLogQuery serviceTask2DeletedQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask2JobId).deletionLog();
HistoricJobLogQuery serviceTask2SuccessfulQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask2JobId).successLog();
assertEquals(1, serviceTask2Query.count());
assertEquals(1, serviceTask2CreatedQuery.count());
assertEquals(0, serviceTask2DeletedQuery.count());
assertEquals(0, serviceTask2SuccessfulQuery.count());
// when
managementService.executeJob(serviceTask1JobId);
// then
assertEquals(4, query.count());
// serviceTask1
assertEquals(2, serviceTask1Query.count());
assertEquals(1, serviceTask1CreatedQuery.count());
assertEquals(0, serviceTask1DeletedQuery.count());
assertEquals(1, serviceTask1SuccessfulQuery.count());
HistoricJobLog serviceTask1CreatedJobLogEntry = serviceTask1CreatedQuery.singleResult();
assertEquals(3, serviceTask1CreatedJobLogEntry.getJobRetries());
HistoricJobLog serviceTask1SuccessfulJobLogEntry = serviceTask1SuccessfulQuery.singleResult();
assertEquals(3, serviceTask1SuccessfulJobLogEntry.getJobRetries());
// serviceTask2
assertEquals(2, serviceTask2Query.count());
assertEquals(1, serviceTask2CreatedQuery.count());
assertEquals(1, serviceTask2DeletedQuery.count());
assertEquals(0, serviceTask2SuccessfulQuery.count());
HistoricJobLog serviceTask2CreatedJobLogEntry = serviceTask2CreatedQuery.singleResult();
assertEquals(3, serviceTask2CreatedJobLogEntry.getJobRetries());
HistoricJobLog serviceTask2DeletedJobLogEntry = serviceTask2DeletedQuery.singleResult();
assertEquals(3, serviceTask2DeletedJobLogEntry.getJobRetries());
// there should be one task after the boundary event
assertEquals(1, taskService.createTaskQuery().count());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testFailedJobEventsExecutedByJobExecutor.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testFailedJobEventsExecutedByJobExecutor() {
// given
runtimeService.startProcessInstanceByKey("process");
String jobId = managementService.createJobQuery().singleResult().getId();
HistoricJobLogQuery query = historyService.createHistoricJobLogQuery().jobId(jobId);
HistoricJobLogQuery createdQuery = historyService.createHistoricJobLogQuery().jobId(jobId).creationLog();
HistoricJobLogQuery failedQuery = historyService.createHistoricJobLogQuery().jobId(jobId).failureLog().orderByJobRetries().desc();
// there exists one historic job log entry
assertEquals(1, query.count());
assertEquals(1, createdQuery.count());
assertEquals(0, failedQuery.count());
// when (1)
executeAvailableJobs();
// then (1)
assertEquals(4, query.count());
assertEquals(1, createdQuery.count());
assertEquals(3, failedQuery.count());
HistoricJobLog createdJobLogEntry = createdQuery.singleResult();
assertEquals(3, createdJobLogEntry.getJobRetries());
HistoricJobLog failedJobLogEntry = failedQuery.list().get(0);
assertEquals(3, failedJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(1);
assertEquals(2, failedJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(2);
assertEquals(1, failedJobLogEntry.getJobRetries());
// when (2)
try {
managementService.executeJob(jobId);
fail();
} catch (Exception e) {
// expected
}
// then (2)
assertEquals(5, query.count());
assertEquals(1, createdQuery.count());
assertEquals(4, failedQuery.count());
createdJobLogEntry = createdQuery.singleResult();
assertEquals(3, createdJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(0);
assertEquals(3, failedJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(1);
assertEquals(2, failedJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(2);
assertEquals(1, failedJobLogEntry.getJobRetries());
failedJobLogEntry = failedQuery.list().get(3);
assertEquals(0, failedJobLogEntry.getJobRetries());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testDifferentExceptions.
@Deployment
public void testDifferentExceptions() {
// given
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
String jobId = managementService.createJobQuery().singleResult().getId();
// when (1)
try {
managementService.executeJob(jobId);
fail();
} catch (Exception e) {
// expected
}
// then (1)
HistoricJobLog serviceTask1FailedHistoricJobLog = historyService.createHistoricJobLogQuery().failureLog().singleResult();
String serviceTask1FailedHistoricJobLogId = serviceTask1FailedHistoricJobLog.getId();
assertEquals(FirstFailingDelegate.FIRST_EXCEPTION_MESSAGE, serviceTask1FailedHistoricJobLog.getJobExceptionMessage());
String serviceTask1Stacktrace = historyService.getHistoricJobLogExceptionStacktrace(serviceTask1FailedHistoricJobLogId);
assertNotNull(serviceTask1Stacktrace);
assertTextPresent(FirstFailingDelegate.FIRST_EXCEPTION_MESSAGE, serviceTask1Stacktrace);
assertTextPresent(FirstFailingDelegate.class.getName(), serviceTask1Stacktrace);
// when (2)
runtimeService.setVariable(processInstanceId, "firstFail", false);
try {
managementService.executeJob(jobId);
fail();
} catch (Exception e) {
// expected
}
// then (2)
HistoricJobLog serviceTask2FailedHistoricJobLog = historyService.createHistoricJobLogQuery().failureLog().orderByJobRetries().desc().list().get(1);
String serviceTask2FailedHistoricJobLogId = serviceTask2FailedHistoricJobLog.getId();
assertEquals(SecondFailingDelegate.SECOND_EXCEPTION_MESSAGE, serviceTask2FailedHistoricJobLog.getJobExceptionMessage());
String serviceTask2Stacktrace = historyService.getHistoricJobLogExceptionStacktrace(serviceTask2FailedHistoricJobLogId);
assertNotNull(serviceTask2Stacktrace);
assertTextPresent(SecondFailingDelegate.SECOND_EXCEPTION_MESSAGE, serviceTask2Stacktrace);
assertTextPresent(SecondFailingDelegate.class.getName(), serviceTask2Stacktrace);
assertFalse(serviceTask1Stacktrace.equals(serviceTask2Stacktrace));
}
Aggregations