Search in sources :

Example 41 with HistoricJobLog

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());
}
Also used : HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 42 with HistoricJobLog

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());
}
Also used : HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) Job(org.camunda.bpm.engine.runtime.Job) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 43 with HistoricJobLog

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());
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery) HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 44 with HistoricJobLog

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());
}
Also used : HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) Job(org.camunda.bpm.engine.runtime.Job) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 45 with HistoricJobLog

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);
}
Also used : HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricJobLog (org.camunda.bpm.engine.history.HistoricJobLog)47 Deployment (org.camunda.bpm.engine.test.Deployment)26 Job (org.camunda.bpm.engine.runtime.Job)15 Date (java.util.Date)14 HistoricJobLogQuery (org.camunda.bpm.engine.history.HistoricJobLogQuery)13 Batch (org.camunda.bpm.engine.batch.Batch)12 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)12 Test (org.junit.Test)12 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)8 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)6 ArrayList (java.util.ArrayList)5 HistoryService (org.camunda.bpm.engine.HistoryService)2 HistoricJobLogEventEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity)2 HashSet (java.util.HashSet)1 List (java.util.List)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)1 JobManager (org.camunda.bpm.engine.impl.persistence.entity.JobManager)1 HistoricJobLogDto (org.camunda.bpm.engine.rest.dto.history.HistoricJobLogDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1