Search in sources :

Example 26 with HistoricJobLog

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

the class BatchMigrationHistoryTest method testHistoricBatchJobLogForBatchDeletion.

@Test
public void testHistoricBatchJobLogForBatchDeletion() {
    Batch batch = helper.migrateProcessInstancesAsync(1);
    helper.executeSeedJob(batch);
    // when
    Date deletionDate = helper.addSecondsToClock(12);
    managementService.deleteBatch(batch.getId(), false);
    // then a deletion historic job log was added
    HistoricJobLog jobLog = helper.getHistoricBatchJobLog(batch).get(1);
    assertNotNull(jobLog);
    assertTrue(jobLog.isDeletionLog());
    assertEquals(deletionDate, jobLog.getTimestamp());
}
Also used : HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) Date(java.util.Date) Test(org.junit.Test)

Example 27 with HistoricJobLog

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

the class BatchMigrationHistoryTest method testHistoricMonitorJobLog.

@Test
public void testHistoricMonitorJobLog() {
    Batch batch = helper.migrateProcessInstancesAsync(1);
    // when the seed job is executed
    helper.executeSeedJob(batch);
    Job monitorJob = helper.getMonitorJob(batch);
    List<HistoricJobLog> jobLogs = helper.getHistoricMonitorJobLog(batch, monitorJob);
    assertEquals(1, jobLogs.size());
    // then a creation historic job log exists for the monitor job without due date
    HistoricJobLog jobLog = jobLogs.get(0);
    assertCommonMonitorJobLogProperties(batch, jobLog);
    assertTrue(jobLog.isCreationLog());
    assertEquals(START_DATE, jobLog.getTimestamp());
    assertNull(jobLog.getJobDueDate());
    // when the monitor job is executed
    Date executionDate = helper.addSecondsToClock(15);
    Date monitorJobDueDate = helper.addSeconds(executionDate, 30);
    helper.executeMonitorJob(batch);
    jobLogs = helper.getHistoricMonitorJobLog(batch, monitorJob);
    assertEquals(2, jobLogs.size());
    // then a success job log was created for the last monitor job
    jobLog = jobLogs.get(1);
    assertCommonMonitorJobLogProperties(batch, jobLog);
    assertTrue(jobLog.isSuccessLog());
    assertEquals(executionDate, jobLog.getTimestamp());
    assertNull(jobLog.getJobDueDate());
    // and a creation job log for the new monitor job was created with due date
    monitorJob = helper.getMonitorJob(batch);
    jobLogs = helper.getHistoricMonitorJobLog(batch, monitorJob);
    assertEquals(1, jobLogs.size());
    jobLog = jobLogs.get(0);
    assertCommonMonitorJobLogProperties(batch, jobLog);
    assertTrue(jobLog.isCreationLog());
    assertEquals(executionDate, jobLog.getTimestamp());
    assertEquals(monitorJobDueDate, jobLog.getJobDueDate());
    // when the migration and monitor jobs are executed
    executionDate = helper.addSecondsToClock(15);
    helper.executeJobs(batch);
    helper.executeMonitorJob(batch);
    jobLogs = helper.getHistoricMonitorJobLog(batch, monitorJob);
    assertEquals(2, jobLogs.size());
    // then a success job log was created for the last monitor job
    jobLog = jobLogs.get(1);
    assertCommonMonitorJobLogProperties(batch, jobLog);
    assertTrue(jobLog.isSuccessLog());
    assertEquals(executionDate, jobLog.getTimestamp());
    assertEquals(monitorJobDueDate, 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) Job(org.camunda.bpm.engine.runtime.Job) Date(java.util.Date) Test(org.junit.Test)

Example 28 with HistoricJobLog

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

the class HistoricJobLogAuthorizationTest method testQueryAfterStandaloneJob.

// historic job log query (standalone job) ///////////////////////
public void testQueryAfterStandaloneJob() {
    // given
    disableAuthorization();
    repositoryService.suspendProcessDefinitionByKey(TIMER_BOUNDARY_PROCESS_KEY, true, new Date());
    enableAuthorization();
    // when
    HistoricJobLogQuery query = historyService.createHistoricJobLogQuery();
    // then
    verifyQueryResults(query, 1);
    HistoricJobLog jobLog = query.singleResult();
    assertNull(jobLog.getProcessDefinitionKey());
    deleteDeployment(deploymentId);
    disableAuthorization();
    String jobId = managementService.createJobQuery().singleResult().getId();
    managementService.deleteJob(jobId);
    enableAuthorization();
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery) HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) Date(java.util.Date)

Example 29 with HistoricJobLog

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

the class BulkHistoryDeleteTest method findExceptionByteArrayIds.

private List<String> findExceptionByteArrayIds() {
    List<String> exceptionByteArrayIds = new ArrayList<String>();
    List<HistoricJobLog> historicJobLogs = historyService.createHistoricJobLogQuery().list();
    for (HistoricJobLog historicJobLog : historicJobLogs) {
        HistoricJobLogEventEntity historicJobLogEventEntity = (HistoricJobLogEventEntity) historicJobLog;
        if (historicJobLogEventEntity.getExceptionByteArrayId() != null) {
            exceptionByteArrayIds.add(historicJobLogEventEntity.getExceptionByteArrayId());
        }
    }
    return exceptionByteArrayIds;
}
Also used : HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) ArrayList(java.util.ArrayList) HistoricJobLogEventEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity)

Example 30 with HistoricJobLog

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

the class JobExecutorTest method testBasicJobExecutorOperation.

public void testBasicJobExecutorOperation() throws Exception {
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            JobManager jobManager = commandContext.getJobManager();
            jobManager.send(createTweetMessage("message-one"));
            jobManager.send(createTweetMessage("message-two"));
            jobManager.send(createTweetMessage("message-three"));
            jobManager.send(createTweetMessage("message-four"));
            jobManager.schedule(createTweetTimer("timer-one", new Date()));
            jobManager.schedule(createTweetTimer("timer-two", new Date()));
            return null;
        }
    });
    executeAvailableJobs();
    Set<String> messages = new HashSet<String>(tweetHandler.getMessages());
    Set<String> expectedMessages = new HashSet<String>();
    expectedMessages.add("message-one");
    expectedMessages.add("message-two");
    expectedMessages.add("message-three");
    expectedMessages.add("message-four");
    expectedMessages.add("timer-one");
    expectedMessages.add("timer-two");
    assertEquals(new TreeSet<String>(expectedMessages), new TreeSet<String>(messages));
    commandExecutor.execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            List<HistoricJobLog> historicJobLogs = processEngineConfiguration.getHistoryService().createHistoricJobLogQuery().list();
            for (HistoricJobLog historicJobLog : historicJobLogs) {
                commandContext.getHistoricJobLogManager().deleteHistoricJobLogById(historicJobLog.getId());
            }
            return null;
        }
    });
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) ArrayList(java.util.ArrayList) List(java.util.List) JobManager(org.camunda.bpm.engine.impl.persistence.entity.JobManager) Date(java.util.Date) HashSet(java.util.HashSet)

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