Search in sources :

Example 46 with HistoricJobLog

use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.

the class HistoricJobLogTest method testSuccessfulHistoricJobLogProperties.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testSuccessfulHistoricJobLogProperties() {
    runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("fail", false));
    Job job = managementService.createJobQuery().singleResult();
    managementService.executeJob(job.getId());
    HistoricJobLog historicJob = historyService.createHistoricJobLogQuery().successLog().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());
    assertFalse(historicJob.isCreationLog());
    assertFalse(historicJob.isFailureLog());
    assertTrue(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 47 with HistoricJobLog

use of org.camunda.bpm.engine.history.HistoricJobLog in project camunda-bpm-platform by camunda.

the class HistoricJobLogQueryTest method testQueryByJobPriority.

@Deployment
public void testQueryByJobPriority() {
    // given 5 process instances with 5 jobs
    List<ProcessInstance> processInstances = new ArrayList<ProcessInstance>();
    for (int i = 0; i < 5; i++) {
        processInstances.add(runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("priority", i)));
    }
    // then the creation logs can be filtered by priority of the jobs
    // (1) lower than or equal a priority
    List<HistoricJobLog> jobLogs = historyService.createHistoricJobLogQuery().jobPriorityLowerThanOrEquals(2L).orderByJobPriority().asc().list();
    assertEquals(3, jobLogs.size());
    for (HistoricJobLog log : jobLogs) {
        assertTrue(log.getJobPriority() <= 2);
    }
    // (2) higher than or equal a given priorty
    jobLogs = historyService.createHistoricJobLogQuery().jobPriorityHigherThanOrEquals(3L).orderByJobPriority().asc().list();
    assertEquals(2, jobLogs.size());
    for (HistoricJobLog log : jobLogs) {
        assertTrue(log.getJobPriority() >= 3);
    }
    // (3) lower and higher than or equal
    jobLogs = historyService.createHistoricJobLogQuery().jobPriorityHigherThanOrEquals(1L).jobPriorityLowerThanOrEquals(3L).orderByJobPriority().asc().list();
    assertEquals(3, jobLogs.size());
    for (HistoricJobLog log : jobLogs) {
        assertTrue(log.getJobPriority() >= 1 && log.getJobPriority() <= 3);
    }
    // (4) lower and higher than or equal are disjunctive
    jobLogs = historyService.createHistoricJobLogQuery().jobPriorityHigherThanOrEquals(3).jobPriorityLowerThanOrEquals(1).orderByJobPriority().asc().list();
    assertEquals(0, jobLogs.size());
}
Also used : HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) ArrayList(java.util.ArrayList) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) 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