Search in sources :

Example 46 with HistoricJobLogQuery

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

the class MultiTenancyHistoricJobLogQueryTest method testQueryDisabledTenantCheck.

public void testQueryDisabledTenantCheck() {
    processEngineConfiguration.setTenantCheckEnabled(false);
    identityService.setAuthentication("user", null, null);
    HistoricJobLogQuery query = historyService.createHistoricJobLogQuery();
    assertThat(query.count(), is(4L));
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery)

Example 47 with HistoricJobLogQuery

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

the class MultiTenancyHistoricJobLogQueryTest method testQueryAuthenticatedTenant.

public void testQueryAuthenticatedTenant() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    HistoricJobLogQuery query = historyService.createHistoricJobLogQuery();
    assertThat(query.count(), is(2L));
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(2L));
    assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L));
    assertThat(query.tenantIdIn(TENANT_ONE, TENANT_TWO).count(), is(2L));
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery)

Example 48 with HistoricJobLogQuery

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

the class MultiTenancyHistoricJobLogQueryTest method testQueryNoAuthenticatedTenants.

public void testQueryNoAuthenticatedTenants() {
    identityService.setAuthentication("user", null, null);
    HistoricJobLogQuery query = historyService.createHistoricJobLogQuery();
    assertThat(query.count(), is(0L));
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery)

Example 49 with HistoricJobLogQuery

use of org.camunda.bpm.engine.history.HistoricJobLogQuery 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)

Example 50 with HistoricJobLogQuery

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

the class HistoricJobLogTest method testFailedJobEvents.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricJobLogTest.testAsyncContinuation.bpmn20.xml" })
public void testFailedJobEvents() {
    // 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)
    try {
        managementService.executeJob(jobId);
        fail();
    } catch (Exception e) {
    // expected
    }
    // then (1)
    assertEquals(2, query.count());
    assertEquals(1, createdQuery.count());
    assertEquals(1, failedQuery.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());
    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)
    try {
        managementService.executeJob(jobId);
        fail();
    } catch (Exception e) {
    // expected
    }
    // then (3)
    assertEquals(4, query.count());
    assertEquals(1, createdQuery.count());
    assertEquals(3, 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());
    // when (4)
    try {
        managementService.executeJob(jobId);
        fail();
    } catch (Exception e) {
    // expected
    }
    // then (4)
    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)

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