Search in sources :

Example 31 with HistoricJobLog

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());
}
Also used : HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Date(java.util.Date) Test(org.junit.Test)

Example 32 with HistoricJobLog

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());
}
Also used : HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Date(java.util.Date) Test(org.junit.Test)

Example 33 with HistoricJobLog

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

Example 34 with HistoricJobLog

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

Example 35 with HistoricJobLog

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