Search in sources :

Example 16 with HistoricJobLogQuery

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

the class HistoricJobLogTest method testSuccessfulJobEvent.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testSuccessfulJobEvent() {
    // 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
    managementService.executeJob(jobId);
    // 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 17 with HistoricJobLogQuery

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

the class HistoricJobLogTest method testTerminateEndEvent.

@Deployment
public void testTerminateEndEvent() {
    // given
    runtimeService.startProcessInstanceByKey("process").getId();
    String serviceTask1JobId = managementService.createJobQuery().activityId("serviceTask1").singleResult().getId();
    HistoricJobLogQuery query = historyService.createHistoricJobLogQuery();
    assertEquals(2, query.count());
    // serviceTask1
    HistoricJobLogQuery serviceTask1Query = historyService.createHistoricJobLogQuery().jobId(serviceTask1JobId);
    HistoricJobLogQuery serviceTask1CreatedQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask1JobId).creationLog();
    HistoricJobLogQuery serviceTask1DeletedQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask1JobId).deletionLog();
    HistoricJobLogQuery serviceTask1SuccessfulQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask1JobId).successLog();
    assertEquals(1, serviceTask1Query.count());
    assertEquals(1, serviceTask1CreatedQuery.count());
    assertEquals(0, serviceTask1DeletedQuery.count());
    assertEquals(0, serviceTask1SuccessfulQuery.count());
    // serviceTask2
    String serviceTask2JobId = managementService.createJobQuery().activityId("serviceTask2").singleResult().getId();
    HistoricJobLogQuery serviceTask2Query = historyService.createHistoricJobLogQuery().jobId(serviceTask2JobId);
    HistoricJobLogQuery serviceTask2CreatedQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask2JobId).creationLog();
    HistoricJobLogQuery serviceTask2DeletedQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask2JobId).deletionLog();
    HistoricJobLogQuery serviceTask2SuccessfulQuery = historyService.createHistoricJobLogQuery().jobId(serviceTask2JobId).successLog();
    assertEquals(1, serviceTask2Query.count());
    assertEquals(1, serviceTask2CreatedQuery.count());
    assertEquals(0, serviceTask2DeletedQuery.count());
    assertEquals(0, serviceTask2SuccessfulQuery.count());
    // when
    managementService.executeJob(serviceTask1JobId);
    // then
    assertEquals(4, query.count());
    // serviceTas1
    assertEquals(2, serviceTask1Query.count());
    assertEquals(1, serviceTask1CreatedQuery.count());
    assertEquals(0, serviceTask1DeletedQuery.count());
    assertEquals(1, serviceTask1SuccessfulQuery.count());
    HistoricJobLog serviceTask1CreatedJobLogEntry = serviceTask1CreatedQuery.singleResult();
    assertEquals(3, serviceTask1CreatedJobLogEntry.getJobRetries());
    HistoricJobLog serviceTask1SuccessfulJobLogEntry = serviceTask1SuccessfulQuery.singleResult();
    assertEquals(3, serviceTask1SuccessfulJobLogEntry.getJobRetries());
    // serviceTask2
    assertEquals(2, serviceTask2Query.count());
    assertEquals(1, serviceTask2CreatedQuery.count());
    assertEquals(1, serviceTask2DeletedQuery.count());
    assertEquals(0, serviceTask2SuccessfulQuery.count());
    HistoricJobLog serviceTask2CreatedJobLogEntry = serviceTask2CreatedQuery.singleResult();
    assertEquals(3, serviceTask2CreatedJobLogEntry.getJobRetries());
    HistoricJobLog serviceTask2DeletedJobLogEntry = serviceTask2DeletedQuery.singleResult();
    assertEquals(3, serviceTask2DeletedJobLogEntry.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 18 with HistoricJobLogQuery

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

the class HistoricJobLogTest method testDeletedProcessInstance.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testDeletedProcessInstance() {
    // 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 deletedQuery = historyService.createHistoricJobLogQuery().jobId(jobId).deletionLog();
    // there exists one historic job log entry
    assertEquals(1, query.count());
    assertEquals(1, createdQuery.count());
    assertEquals(0, deletedQuery.count());
    // when
    runtimeService.deleteProcessInstance(processInstanceId, null);
    // then
    assertEquals(2, query.count());
    assertEquals(1, createdQuery.count());
    assertEquals(1, deletedQuery.count());
    HistoricJobLog createdJobLogEntry = createdQuery.singleResult();
    assertEquals(3, createdJobLogEntry.getJobRetries());
    HistoricJobLog deletedJobLogEntry = deletedQuery.singleResult();
    assertEquals(3, deletedJobLogEntry.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 19 with HistoricJobLogQuery

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

the class HistoricJobLogQueryTest method testQuerySorting.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testQuerySorting() {
    for (int i = 0; i < 10; i++) {
        runtimeService.startProcessInstanceByKey("process");
    }
    HistoricJobLogQuery query = historyService.createHistoricJobLogQuery();
    // asc
    query.orderByTimestamp().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByTimestamp());
    query = historyService.createHistoricJobLogQuery();
    query.orderByJobId().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByJobId());
    query = historyService.createHistoricJobLogQuery();
    query.orderByJobDefinitionId().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByJobDefinitionId());
    query = historyService.createHistoricJobLogQuery();
    query.orderByJobDueDate().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByJobDueDate());
    query = historyService.createHistoricJobLogQuery();
    query.orderByJobRetries().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByJobRetries());
    query = historyService.createHistoricJobLogQuery();
    query.orderByActivityId().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByActivityId());
    query = historyService.createHistoricJobLogQuery();
    query.orderByExecutionId().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByExecutionId());
    query = historyService.createHistoricJobLogQuery();
    query.orderByProcessInstanceId().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByProcessInstanceId());
    query = historyService.createHistoricJobLogQuery();
    query.orderByProcessDefinitionId().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByProcessDefinitionId());
    query = historyService.createHistoricJobLogQuery();
    query.orderByProcessDefinitionKey().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByProcessDefinitionKey(processEngine));
    query = historyService.createHistoricJobLogQuery();
    query.orderByDeploymentId().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByDeploymentId());
    query = historyService.createHistoricJobLogQuery();
    query.orderByJobPriority().asc();
    verifyQueryWithOrdering(query, 10, historicJobLogByJobPriority());
    // desc
    query.orderByTimestamp().desc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByTimestamp()));
    query = historyService.createHistoricJobLogQuery();
    query.orderByJobId().desc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByJobId()));
    query = historyService.createHistoricJobLogQuery();
    query.orderByJobDefinitionId().asc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByJobDefinitionId()));
    query = historyService.createHistoricJobLogQuery();
    query.orderByJobDueDate().desc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByJobDueDate()));
    query = historyService.createHistoricJobLogQuery();
    query.orderByJobRetries().desc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByJobRetries()));
    query = historyService.createHistoricJobLogQuery();
    query.orderByActivityId().desc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByActivityId()));
    query = historyService.createHistoricJobLogQuery();
    query.orderByExecutionId().desc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByExecutionId()));
    query = historyService.createHistoricJobLogQuery();
    query.orderByProcessInstanceId().desc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByProcessInstanceId()));
    query = historyService.createHistoricJobLogQuery();
    query.orderByProcessDefinitionId().desc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByProcessDefinitionId()));
    query = historyService.createHistoricJobLogQuery();
    query.orderByProcessDefinitionKey().desc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByProcessDefinitionKey(processEngine)));
    query = historyService.createHistoricJobLogQuery();
    query.orderByDeploymentId().desc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByDeploymentId()));
    query = historyService.createHistoricJobLogQuery();
    query.orderByJobPriority().desc();
    verifyQueryWithOrdering(query, 10, inverted(historicJobLogByJobPriority()));
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 20 with HistoricJobLogQuery

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

the class HistoricJobLogQueryTest method testQueryByExecutionId.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testQueryByExecutionId() {
    runtimeService.startProcessInstanceByKey("process");
    String executionId = managementService.createJobQuery().singleResult().getExecutionId();
    HistoricJobLogQuery query = historyService.createHistoricJobLogQuery().executionIdIn(executionId);
    verifyQueryResults(query, 1);
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricJobLogQuery (org.camunda.bpm.engine.history.HistoricJobLogQuery)65 Deployment (org.camunda.bpm.engine.test.Deployment)28 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)17 HistoricJobLog (org.camunda.bpm.engine.history.HistoricJobLog)12 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)1 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 HistoricJobLogDto (org.camunda.bpm.engine.rest.dto.history.HistoricJobLogDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 Task (org.camunda.bpm.engine.task.Task)1 Test (org.junit.Test)1