Search in sources :

Example 86 with Incident

use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.

the class IncidentQueryTest method testQueryByIncidentId.

@Test
public void testQueryByIncidentId() {
    Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstanceIds.get(0)).singleResult();
    assertNotNull(incident);
    IncidentQuery query = runtimeService.createIncidentQuery().incidentId(incident.getId());
    assertEquals(1, query.count());
    List<Incident> incidents = query.list();
    assertFalse(incidents.isEmpty());
    assertEquals(1, incidents.size());
}
Also used : IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test)

Example 87 with Incident

use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.

the class IncidentQueryTest method testQueryByExecutionId.

public void testQueryByExecutionId() {
    Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstanceIds.get(0)).singleResult();
    assertNotNull(execution);
    IncidentQuery query = runtimeService.createIncidentQuery().executionId(execution.getId());
    assertEquals(1, query.count());
    List<Incident> incidents = query.list();
    assertFalse(incidents.isEmpty());
    assertEquals(1, incidents.size());
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery) Incident(org.camunda.bpm.engine.runtime.Incident)

Example 88 with Incident

use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.

the class CreateAndResolveIncidentAuthorizationTest method resolveIncident.

@Test
public void resolveIncident() {
    testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
    ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("Process");
    ExecutionEntity execution = (ExecutionEntity) engineRule.getRuntimeService().createExecutionQuery().active().singleResult();
    authRule.disableAuthorization();
    Incident incident = engineRule.getRuntimeService().createIncident("foo", execution.getId(), execution.getActivityId(), "bar");
    authRule.init(scenario).withUser("userId").bindResource("processInstance", processInstance.getId()).bindResource("processDefinition", "Process").start();
    // when
    engineRule.getRuntimeService().resolveIncident(incident.getId());
    // then
    authRule.assertScenario(scenario);
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test)

Example 89 with Incident

use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.

the class ExecutionQueryTest method testQueryByIncidentMessageInSubProcess.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/failingSubProcessCreateOneIncident.bpmn20.xml" })
public void testQueryByIncidentMessageInSubProcess() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingSubProcess");
    executeAvailableJobs();
    List<Incident> incidentList = runtimeService.createIncidentQuery().list();
    assertEquals(1, incidentList.size());
    Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
    List<Execution> executionList = runtimeService.createExecutionQuery().incidentMessage(incident.getIncidentMessage()).list();
    assertEquals(1, executionList.size());
    // execution id of subprocess != process instance id
    assertNotSame(processInstance.getId(), executionList.get(0).getId());
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Incident(org.camunda.bpm.engine.runtime.Incident) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 90 with Incident

use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.

the class ExecutionQueryTest method testQueryByIncidentId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/failingProcessCreateOneIncident.bpmn20.xml" })
public void testQueryByIncidentId() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess");
    executeAvailableJobs();
    List<Incident> incidentList = runtimeService.createIncidentQuery().list();
    assertEquals(1, incidentList.size());
    Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
    List<Execution> executionList = runtimeService.createExecutionQuery().incidentId(incident.getId()).list();
    assertEquals(1, executionList.size());
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Incident(org.camunda.bpm.engine.runtime.Incident) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

Incident (org.camunda.bpm.engine.runtime.Incident)100 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)50 Test (org.junit.Test)50 Deployment (org.camunda.bpm.engine.test.Deployment)40 IncidentQuery (org.camunda.bpm.engine.runtime.IncidentQuery)34 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)19 Job (org.camunda.bpm.engine.runtime.Job)17 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)14 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)13 Execution (org.camunda.bpm.engine.runtime.Execution)10 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)9 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)8 ProcessDefinitionQuery (org.camunda.bpm.engine.repository.ProcessDefinitionQuery)4 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 HistoricIncidentQuery (org.camunda.bpm.engine.history.HistoricIncidentQuery)3 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)3 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)2 RuntimeService (org.camunda.bpm.engine.RuntimeService)2 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)2