Search in sources :

Example 51 with HistoricJobLogQuery

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

the class HistoricJobLogTest method testErrorEndEventInterruptingCallActivity.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testSuperProcessWithCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testSubProcessWithErrorEndEvent.bpmn20.xml" })
public void testErrorEndEventInterruptingCallActivity() {
    // given
    runtimeService.startProcessInstanceByKey("process").getId();
    HistoricJobLogQuery query = historyService.createHistoricJobLogQuery();
    assertEquals(2, query.count());
    // serviceTask1
    String serviceTask1JobId = managementService.createJobQuery().activityId("serviceTask1").singleResult().getId();
    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());
    // serviceTask1
    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());
    // there should be one task after the boundary event
    assertEquals(1, taskService.createTaskQuery().count());
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery) HistoricJobLog(org.camunda.bpm.engine.history.HistoricJobLog) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 52 with HistoricJobLogQuery

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

the class HistoricJobLogTest method testFailedJobEventsExecutedByJobExecutor.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testFailedJobEventsExecutedByJobExecutor() {
    // given
    runtimeService.startProcessInstanceByKey("process");
    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();
    // there exists one historic job log entry
    assertEquals(1, query.count());
    assertEquals(1, createdQuery.count());
    assertEquals(0, failedQuery.count());
    // when (1)
    executeAvailableJobs();
    // then (1)
    assertEquals(4, query.count());
    assertEquals(1, createdQuery.count());
    assertEquals(3, failedQuery.count());
    HistoricJobLog createdJobLogEntry = createdQuery.singleResult();
    assertEquals(3, createdJobLogEntry.getJobRetries());
    HistoricJobLog failedJobLogEntry = failedQuery.list().get(0);
    assertEquals(3, failedJobLogEntry.getJobRetries());
    failedJobLogEntry = failedQuery.list().get(1);
    assertEquals(2, failedJobLogEntry.getJobRetries());
    failedJobLogEntry = failedQuery.list().get(2);
    assertEquals(1, failedJobLogEntry.getJobRetries());
    // when (2)
    try {
        managementService.executeJob(jobId);
        fail();
    } catch (Exception e) {
    // expected
    }
    // then (2)
    assertEquals(5, query.count());
    assertEquals(1, createdQuery.count());
    assertEquals(4, failedQuery.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());
    failedJobLogEntry = failedQuery.list().get(2);
    assertEquals(1, failedJobLogEntry.getJobRetries());
    failedJobLogEntry = failedQuery.list().get(3);
    assertEquals(0, failedJobLogEntry.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)

Example 53 with HistoricJobLogQuery

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

the class HistoricJobLogTest method testSuccessfulJobEventExecutedByJobExecutor.

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

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

the class HistoricJobLogQueryTest method testQueryByFailureLog.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testQueryByFailureLog() {
    runtimeService.startProcessInstanceByKey("process");
    String jobId = managementService.createJobQuery().singleResult().getId();
    try {
        managementService.executeJob(jobId);
        fail();
    } catch (Exception e) {
    // expected
    }
    HistoricJobLogQuery query = historyService.createHistoricJobLogQuery().failureLog();
    verifyQueryResults(query, 1);
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 55 with HistoricJobLogQuery

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

the class HistoricJobLogQueryTest method testQueryByInvalidJobDefinitionId.

public void testQueryByInvalidJobDefinitionId() {
    HistoricJobLogQuery query = historyService.createHistoricJobLogQuery().jobDefinitionId("invalid");
    verifyQueryResults(query, 0);
    try {
        query.jobDefinitionId(null);
        fail();
    } catch (Exception e) {
    }
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

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