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));
}
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));
}
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));
}
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());
}
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());
}
Aggregations