use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class BatchModificationHistoryTest method testHistoricSeedJobLog.
@Test
public void testHistoricSeedJobLog() {
// when
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
Batch batch = helper.cancelAllAsync("process1", 1, "user1", processDefinition.getId());
// then a historic job log exists for the seed job
HistoricJobLog jobLog = helper.getHistoricSeedJobLog(batch).get(0);
assertNotNull(jobLog);
assertTrue(jobLog.isCreationLog());
assertEquals(batch.getSeedJobDefinitionId(), jobLog.getJobDefinitionId());
assertEquals(BatchSeedJobHandler.TYPE, jobLog.getJobDefinitionType());
assertEquals(batch.getId(), jobLog.getJobDefinitionConfiguration());
assertEquals(START_DATE, jobLog.getTimestamp());
assertNull(jobLog.getDeploymentId());
assertNull(jobLog.getProcessDefinitionId());
assertNull(jobLog.getExecutionId());
assertNull(jobLog.getJobDueDate());
// when the seed job is executed
Date executionDate = helper.addSecondsToClock(12);
helper.executeSeedJob(batch);
// then a new historic job log exists for the seed job
jobLog = helper.getHistoricSeedJobLog(batch).get(1);
assertNotNull(jobLog);
assertTrue(jobLog.isSuccessLog());
assertEquals(batch.getSeedJobDefinitionId(), jobLog.getJobDefinitionId());
assertEquals(BatchSeedJobHandler.TYPE, jobLog.getJobDefinitionType());
assertEquals(batch.getId(), jobLog.getJobDefinitionConfiguration());
assertEquals(executionDate, jobLog.getTimestamp());
assertNull(jobLog.getDeploymentId());
assertNull(jobLog.getProcessDefinitionId());
assertNull(jobLog.getExecutionId());
assertNull(jobLog.getJobDueDate());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class BatchModificationHistoryTest method testHistoricBatchJobLog.
@Test
public void testHistoricBatchJobLog() {
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
Batch batch = helper.startAfterAsync("process1", 1, "user1", processDefinition.getId());
helper.executeSeedJob(batch);
// when
Date executionDate = helper.addSecondsToClock(12);
helper.executeJobs(batch);
// then a historic job log exists for the batch job
HistoricJobLog jobLog = helper.getHistoricBatchJobLog(batch).get(0);
assertNotNull(jobLog);
assertTrue(jobLog.isCreationLog());
assertEquals(batch.getBatchJobDefinitionId(), jobLog.getJobDefinitionId());
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());
assertNull(jobLog.getExecutionId());
assertNull(jobLog.getJobDueDate());
jobLog = helper.getHistoricBatchJobLog(batch).get(1);
assertNotNull(jobLog);
assertTrue(jobLog.isSuccessLog());
assertEquals(batch.getBatchJobDefinitionId(), jobLog.getJobDefinitionId());
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());
assertNull(jobLog.getExecutionId());
assertNull(jobLog.getJobDueDate());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testCatchingSignalEventJobHandlerType.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testCatchingSignalEvent.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testThrowingSignalEventAsync.bpmn20.xml" })
public void testCatchingSignalEventJobHandlerType() {
runtimeService.startProcessInstanceByKey("catchSignal");
runtimeService.startProcessInstanceByKey("throwSignal");
Job job = managementService.createJobQuery().singleResult();
HistoricJobLog historicJob = historyService.createHistoricJobLogQuery().jobId(job.getId()).singleResult();
assertNotNull(historicJob);
assertNull(historicJob.getJobDueDate());
assertEquals(job.getId(), historicJob.getJobId());
assertEquals(job.getJobDefinitionId(), historicJob.getJobDefinitionId());
assertEquals("signalEvent", historicJob.getActivityId());
assertEquals(ProcessEventJobHandler.TYPE, historicJob.getJobDefinitionType());
assertNull(historicJob.getJobDefinitionConfiguration());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testCatchingSignalEventActivityId.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testCatchingSignalEvent.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testThrowingSignalEventAsync.bpmn20.xml" })
public void testCatchingSignalEventActivityId() {
// given + when (1)
String processInstanceId = runtimeService.startProcessInstanceByKey("catchSignal").getId();
runtimeService.startProcessInstanceByKey("throwSignal");
String jobId = managementService.createJobQuery().singleResult().getId();
// then (1)
HistoricJobLog historicJob = historyService.createHistoricJobLogQuery().jobId(jobId).creationLog().singleResult();
assertNotNull(historicJob);
assertEquals("signalEvent", historicJob.getActivityId());
// when (2)
try {
managementService.executeJob(jobId);
fail();
} catch (Exception e) {
// expected
}
// then (2)
historicJob = historyService.createHistoricJobLogQuery().jobId(jobId).failureLog().singleResult();
assertNotNull(historicJob);
assertEquals("signalEvent", historicJob.getActivityId());
// when (3)
runtimeService.setVariable(processInstanceId, "fail", false);
managementService.executeJob(jobId);
// then (3)
historicJob = historyService.createHistoricJobLogQuery().jobId(jobId).successLog().singleResult();
assertNotNull(historicJob);
assertEquals("signalEvent", historicJob.getActivityId());
}
use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.
the class HistoricJobLogTest method testSuccessfulAndFailedJobEvents.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testSuccessfulAndFailedJobEvents() {
// given
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
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();
HistoricJobLogQuery succeededQuery = historyService.createHistoricJobLogQuery().jobId(jobId).successLog();
// there exists one historic job log entry
assertEquals(1, query.count());
assertEquals(1, createdQuery.count());
assertEquals(0, failedQuery.count());
assertEquals(0, succeededQuery.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());
assertEquals(0, succeededQuery.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());
assertEquals(0, succeededQuery.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)
runtimeService.setVariable(processInstanceId, "fail", false);
managementService.executeJob(jobId);
// then (3)
assertEquals(4, query.count());
assertEquals(1, createdQuery.count());
assertEquals(2, failedQuery.count());
assertEquals(1, succeededQuery.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());
HistoricJobLog succeededJobLogEntry = succeededQuery.singleResult();
assertEquals(1, succeededJobLogEntry.getJobRetries());
}
Aggregations