public void testDoNotCreateNewIncident() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess");
executeAvailableJobs();
IncidentQuery query = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId());
Incident incident = query.singleResult();
assertNotNull(incident);
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
// set retries to 1 by job definition id
managementService.setJobRetriesByJobDefinitionId(jobDefinition.getId(), 1);
// the incident still exists
Incident tmp = query.singleResult();
assertEquals(incident.getId(), tmp.getId());
// execute the available job (should fail again)
executeAvailableJobs();
// the incident still exists and there
// should be not a new incident
assertEquals(1, query.count());
tmp = query.singleResult();
assertEquals(incident.getId(), tmp.getId());
}