Search in sources :

Example 21 with HistoricJobLog

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

the class HistoricJobLogTest method testDeletedHistoricJobLogProperties.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testDeletedHistoricJobLogProperties() {
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    Job job = managementService.createJobQuery().singleResult();
    runtimeService.deleteProcessInstance(processInstanceId, null);
    HistoricJobLog historicJob = historyService.createHistoricJobLogQuery().deletionLog().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());
    assertFalse(historicJob.isSuccessLog());
    assertTrue(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 22 with HistoricJobLog

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

the class HistoricJobLogRestServiceInteractionTest method setUpRuntimeData.

@Before
public void setUpRuntimeData() {
    mockQuery = mock(HistoricJobLogQuery.class);
    HistoricJobLog mockedHistoricJobLog = MockProvider.createMockHistoricJobLog();
    when(mockQuery.singleResult()).thenReturn(mockedHistoricJobLog);
    when(mockQuery.logId(MockProvider.EXAMPLE_HISTORIC_JOB_LOG_ID)).thenReturn(mockQuery);
    mockHistoryService = mock(HistoryService.class);
    when(mockHistoryService.createHistoricJobLogQuery()).thenReturn(mockQuery);
    namedProcessEngine = getProcessEngine(MockProvider.EXAMPLE_PROCESS_ENGINE_NAME);
    when(namedProcessEngine.getHistoryService()).thenReturn(mockHistoryService);
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery) HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) HistoryService(org.camunda.bpm.engine.HistoryService) Before(org.junit.Before)

Example 23 with HistoricJobLog

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

the class MockProvider method createMockHistoricJobLog.

public static HistoricJobLog createMockHistoricJobLog(String tenantId) {
    HistoricJobLog mock = mock(HistoricJobLog.class);
    when(mock.getId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_ID);
    when(mock.getTimestamp()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_JOB_LOG_TIMESTAMP));
    when(mock.getJobId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_ID);
    when(mock.getJobDueDate()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_JOB_LOG_JOB_DUE_DATE));
    when(mock.getJobRetries()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_RETRIES);
    when(mock.getJobPriority()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_PRIORITY);
    when(mock.getJobExceptionMessage()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_EXCEPTION_MSG);
    when(mock.getJobDefinitionId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_DEF_ID);
    when(mock.getJobDefinitionType()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_DEF_TYPE);
    when(mock.getJobDefinitionConfiguration()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_JOB_DEF_CONFIG);
    when(mock.getActivityId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_ACTIVITY_ID);
    when(mock.getExecutionId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_EXECUTION_ID);
    when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_PROC_INST_ID);
    when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_PROC_DEF_ID);
    when(mock.getProcessDefinitionKey()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_PROC_DEF_KEY);
    when(mock.getDeploymentId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_DEPLOYMENT_ID);
    when(mock.getTenantId()).thenReturn(tenantId);
    when(mock.isCreationLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_CREATION_LOG);
    when(mock.isFailureLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_FAILURE_LOG);
    when(mock.isSuccessLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_SUCCESS_LOG);
    when(mock.isDeletionLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_DELETION_LOG);
    return mock;
}
Also used : HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog)

Example 24 with HistoricJobLog

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

the class HistoricJobLogRestServiceImpl method queryHistoricJobLogs.

public List<HistoricJobLogDto> queryHistoricJobLogs(HistoricJobLogQueryDto queryDto, Integer firstResult, Integer maxResults) {
    queryDto.setObjectMapper(objectMapper);
    HistoricJobLogQuery query = queryDto.toQuery(processEngine);
    List<HistoricJobLog> matchingHistoricJobLogs;
    if (firstResult != null || maxResults != null) {
        matchingHistoricJobLogs = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingHistoricJobLogs = query.list();
    }
    List<HistoricJobLogDto> results = new ArrayList<HistoricJobLogDto>();
    for (HistoricJobLog historicJobLog : matchingHistoricJobLogs) {
        HistoricJobLogDto result = HistoricJobLogDto.fromHistoricJobLog(historicJobLog);
        results.add(result);
    }
    return results;
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery) HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) ArrayList(java.util.ArrayList) HistoricJobLogDto(org.camunda.bpm.engine.rest.dto.history.HistoricJobLogDto)

Example 25 with HistoricJobLog

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

the class BatchMigrationHistoryTest method testHistoricSeedJobLogForBatchDeletion.

@Test
public void testHistoricSeedJobLogForBatchDeletion() {
    Batch batch = helper.migrateProcessInstancesAsync(1);
    // when
    Date deletionDate = helper.addSecondsToClock(12);
    managementService.deleteBatch(batch.getId(), false);
    // then a deletion historic job log was added
    HistoricJobLog jobLog = helper.getHistoricSeedJobLog(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)

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