use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentAuthorizationTest method testSimpleQueryWithMultiple.
public void testSimpleQueryWithMultiple() {
// given
String processInstanceId = startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
// when
IncidentQuery query = runtimeService.createIncidentQuery();
// then
verifyQueryResults(query, 1);
Incident incident = query.singleResult();
assertNotNull(incident);
assertEquals(processInstanceId, incident.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testSetRetriesResolvesFailureIncident.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testSetRetriesResolvesFailureIncident() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
LockedExternalTask lockedTask = externalTasks.get(0);
externalTaskService.handleFailure(lockedTask.getId(), WORKER_ID, "error", 0, LOCK_TIME);
Incident incident = runtimeService.createIncidentQuery().singleResult();
// when
externalTaskService.setRetries(lockedTask.getId(), 5);
// then the incident is resolved
assertEquals(0, runtimeService.createIncidentQuery().count());
if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_FULL.getId()) {
HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();
assertNotNull(historicIncident);
assertEquals(incident.getId(), historicIncident.getId());
assertTrue(historicIncident.isResolved());
}
// and the task can be fetched again
ClockUtil.setCurrentTime(nowPlus(LOCK_TIME + 3000L));
externalTasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
assertEquals(1, externalTasks.size());
assertEquals(lockedTask.getId(), externalTasks.get(0).getId());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testSetRetriesToZero.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testSetRetriesToZero() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
LockedExternalTask lockedTask = externalTasks.get(0);
// when
externalTaskService.setRetries(lockedTask.getId(), 0);
// then
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertNotNull(incident);
assertEquals(lockedTask.getId(), incident.getConfiguration());
// and resetting the retries removes the incident again
externalTaskService.setRetries(lockedTask.getId(), 5);
assertEquals(0, runtimeService.createIncidentQuery().count());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToFailedJobIncident.
public void testPropagateTenantIdToFailedJobIncident() {
deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().serviceTask().camundaExpression("${failing}").camundaAsyncBefore().endEvent().done());
startProcessInstance(PROCESS_DEFINITION_KEY);
executeAvailableJobs();
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertThat(incident, is(notNullValue()));
// inherit the tenant id from execution
assertThat(incident.getTenantId(), is(TENANT_ID));
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByIncidentIdInSubProcess.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/failingSubProcessCreateOneIncident.bpmn20.xml" })
public void testQueryByIncidentIdInSubProcess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingSubProcess");
testHelper.executeAvailableJobs();
List<Incident> incidentList = runtimeService.createIncidentQuery().list();
assertEquals(1, incidentList.size());
Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
List<ProcessInstance> processInstanceList = runtimeService.createProcessInstanceQuery().incidentId(incident.getId()).list();
assertEquals(1, processInstanceList.size());
assertEquals(processInstance.getId(), processInstanceList.get(0).getId());
}
Aggregations