Search in sources :

Example 21 with HistoricIncident

use of org.camunda.bpm.engine.history.HistoricIncident in project camunda-bpm-platform by camunda.

the class HistoricIncidentTest method testCreateHistoricIncidentForNestedExecution.

@Deployment
public void testCreateHistoricIncidentForNestedExecution() {
    startProcessInstance("process");
    Execution execution = runtimeService.createExecutionQuery().activityId("serviceTask").singleResult();
    assertNotNull(execution);
    HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();
    assertNotNull(historicIncident);
    assertEquals(execution.getId(), historicIncident.getExecutionId());
    assertEquals("serviceTask", historicIncident.getActivityId());
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Execution(org.camunda.bpm.engine.runtime.Execution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 22 with HistoricIncident

use of org.camunda.bpm.engine.history.HistoricIncident in project camunda-bpm-platform by camunda.

the class HistoricIncidentTest method testSetRetriesByJobDefinitionIdResolveIncident.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneFailingServiceProcess.bpmn20.xml" })
public void testSetRetriesByJobDefinitionIdResolveIncident() {
    startProcessInstance(PROCESS_DEFINITION_KEY);
    ProcessInstance pi = runtimeService.createProcessInstanceQuery().singleResult();
    HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().processInstanceId(pi.getId());
    HistoricIncident incident = query.singleResult();
    assertNotNull(incident);
    runtimeService.setVariable(pi.getId(), "fail", false);
    JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
    // set retries to 1 by job definition id
    managementService.setJobRetriesByJobDefinitionId(jobDefinition.getId(), 1);
    // the incident still exists
    HistoricIncident tmp = query.singleResult();
    assertEquals(incident.getId(), tmp.getId());
    assertNull(tmp.getEndTime());
    assertTrue(tmp.isOpen());
    // 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());
    assertNotNull(tmp.getEndTime());
    assertTrue(tmp.isResolved());
    assertProcessEnded(pi.getId());
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 23 with HistoricIncident

use of org.camunda.bpm.engine.history.HistoricIncident in project camunda-bpm-platform by camunda.

the class HistoricIncidentTest method testSetHistoricIncidentToDeletedRecursive.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricIncidentQueryTest.testQueryByCauseIncidentId.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/oneFailingServiceProcess.bpmn20.xml" })
public void testSetHistoricIncidentToDeletedRecursive() {
    startProcessInstance("process");
    String processInstanceId = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult().getId();
    runtimeService.deleteProcessInstance(processInstanceId, null);
    List<HistoricIncident> historicIncidents = historyService.createHistoricIncidentQuery().list();
    for (HistoricIncident historicIncident : historicIncidents) {
        assertNotNull(historicIncident.getEndTime());
        assertFalse(historicIncident.isOpen());
        assertTrue(historicIncident.isDeleted());
        assertFalse(historicIncident.isResolved());
    }
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 24 with HistoricIncident

use of org.camunda.bpm.engine.history.HistoricIncident in project camunda-bpm-platform by camunda.

the class HistoricIncidentTest method testCreateRecursiveHistoricIncidentsForNestedCallActivities.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricIncidentTest.testCreateRecursiveHistoricIncidentsForNestedCallActivities.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricIncidentQueryTest.testQueryByCauseIncidentId.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/oneFailingServiceProcess.bpmn20.xml" })
public void testCreateRecursiveHistoricIncidentsForNestedCallActivities() {
    startProcessInstance("process1");
    ProcessInstance pi1 = runtimeService.createProcessInstanceQuery().processDefinitionKey("process1").singleResult();
    assertNotNull(pi1);
    ProcessInstance pi2 = runtimeService.createProcessInstanceQuery().processDefinitionKey("process").singleResult();
    assertNotNull(pi2);
    ProcessInstance pi3 = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
    assertNotNull(pi3);
    HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();
    HistoricIncident rootCauseHistoricIncident = query.processInstanceId(pi3.getId()).singleResult();
    assertNotNull(rootCauseHistoricIncident);
    // cause and root cause id is equal to the id of the root incident
    assertEquals(rootCauseHistoricIncident.getId(), rootCauseHistoricIncident.getCauseIncidentId());
    assertEquals(rootCauseHistoricIncident.getId(), rootCauseHistoricIncident.getRootCauseIncidentId());
    HistoricIncident causeHistoricIncident = query.processInstanceId(pi2.getId()).singleResult();
    assertNotNull(causeHistoricIncident);
    // cause and root cause id is equal to the id of the root incident
    assertEquals(rootCauseHistoricIncident.getId(), causeHistoricIncident.getCauseIncidentId());
    assertEquals(rootCauseHistoricIncident.getId(), causeHistoricIncident.getRootCauseIncidentId());
    HistoricIncident historicIncident = query.processInstanceId(pi1.getId()).singleResult();
    assertNotNull(historicIncident);
    // cause and root cause id is equal to the id of the root incident
    assertEquals(causeHistoricIncident.getId(), historicIncident.getCauseIncidentId());
    assertEquals(rootCauseHistoricIncident.getId(), historicIncident.getRootCauseIncidentId());
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 25 with HistoricIncident

use of org.camunda.bpm.engine.history.HistoricIncident in project camunda-bpm-platform by camunda.

the class HistoricIncidentTest method testSetHistoricIncidentToResolvedRecursive.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricIncidentQueryTest.testQueryByCauseIncidentId.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/oneFailingServiceProcess.bpmn20.xml" })
public void testSetHistoricIncidentToResolvedRecursive() {
    startProcessInstance("process");
    String jobId = managementService.createJobQuery().singleResult().getId();
    managementService.setJobRetries(jobId, 1);
    List<HistoricIncident> historicIncidents = historyService.createHistoricIncidentQuery().list();
    for (HistoricIncident historicIncident : historicIncidents) {
        assertNotNull(historicIncident.getEndTime());
        assertFalse(historicIncident.isOpen());
        assertFalse(historicIncident.isDeleted());
        assertTrue(historicIncident.isResolved());
    }
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)25 Deployment (org.camunda.bpm.engine.test.Deployment)12 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)8 List (java.util.List)7 HistoricIncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)7 HistoricIncidentQuery (org.camunda.bpm.engine.history.HistoricIncidentQuery)6 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)5 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)4 ArrayList (java.util.ArrayList)3 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)3 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)3 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)3 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)3 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)3 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 Incident (org.camunda.bpm.engine.runtime.Incident)3 Test (org.junit.Test)3 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)2 Job (org.camunda.bpm.engine.runtime.Job)2