use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testHandleFailureZeroRetries.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testHandleFailureZeroRetries() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
LockedExternalTask task = tasks.get(0);
// when reporting a failure and setting retries to 0
ClockUtil.setCurrentTime(nowPlus(3000L));
String errorMessage = "errorMessage";
externalTaskService.handleFailure(task.getId(), WORKER_ID, errorMessage, 0, 3000L);
// then the task cannot be fetched anymore even when the lock expires
ClockUtil.setCurrentTime(nowPlus(4000L));
tasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
assertEquals(0, tasks.size());
// and an incident has been created
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertNotNull(incident);
assertNotNull(incident.getId());
assertEquals(errorMessage, incident.getIncidentMessage());
assertEquals(task.getExecutionId(), incident.getExecutionId());
assertEquals("externalTask", incident.getActivityId());
assertEquals(incident.getId(), incident.getCauseIncidentId());
assertEquals("failedExternalTask", incident.getIncidentType());
assertEquals(task.getProcessDefinitionId(), incident.getProcessDefinitionId());
assertEquals(task.getProcessInstanceId(), incident.getProcessInstanceId());
assertEquals(incident.getId(), incident.getRootCauseIncidentId());
AssertUtil.assertEqualsSecondPrecision(nowMinus(4000L), incident.getIncidentTimestamp());
assertEquals(task.getId(), incident.getConfiguration());
assertNull(incident.getJobDefinitionId());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentAuthorizationTest method testSimpleQueryWithReadPermissionOnProcessInstance.
public void testSimpleQueryWithReadPermissionOnProcessInstance() {
// given
String processInstanceId = startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, 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 IncidentAuthorizationTest method testSimpleQueryWithReadInstancesPermissionOnOneTaskProcess.
public void testSimpleQueryWithReadInstancesPermissionOnOneTaskProcess() {
// given
String processInstanceId = startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ_INSTANCE);
// 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 IncidentAuthorizationTest method testSimpleQueryWithReadInstancesPermissionOnAnyProcessDefinition.
public void testSimpleQueryWithReadInstancesPermissionOnAnyProcessDefinition() {
// given
String processInstanceId = startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_INSTANCE);
// 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 ProcessInstanceQueryTest method testQueryByIncidentId.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/failingProcessCreateOneIncident.bpmn20.xml" })
public void testQueryByIncidentId() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess");
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());
}
Aggregations