Search in sources :

Example 1 with HistoricIncident

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

the class ProcessEngineRestServiceTest method createHistoricIncidentMock.

private void createHistoricIncidentMock() {
    HistoricIncidentQuery mockHistoricIncidentQuery = mock(HistoricIncidentQuery.class);
    List<HistoricIncident> historicIncidents = MockProvider.createMockHistoricIncidents();
    when(mockHistoricIncidentQuery.list()).thenReturn(historicIncidents);
    when(mockHistoryService.createHistoricIncidentQuery()).thenReturn(mockHistoricIncidentQuery);
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery)

Example 2 with HistoricIncident

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

the class MockProvider method createMockHistoricIncident.

public static HistoricIncident createMockHistoricIncident(String tenantId) {
    HistoricIncident incident = mock(HistoricIncident.class);
    when(incident.getId()).thenReturn(EXAMPLE_HIST_INCIDENT_ID);
    when(incident.getCreateTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HIST_INCIDENT_CREATE_TIME));
    when(incident.getEndTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HIST_INCIDENT_END_TIME));
    when(incident.getIncidentType()).thenReturn(EXAMPLE_HIST_INCIDENT_TYPE);
    when(incident.getExecutionId()).thenReturn(EXAMPLE_HIST_INCIDENT_EXECUTION_ID);
    when(incident.getActivityId()).thenReturn(EXAMPLE_HIST_INCIDENT_ACTIVITY_ID);
    when(incident.getProcessInstanceId()).thenReturn(EXAMPLE_HIST_INCIDENT_PROC_INST_ID);
    when(incident.getProcessDefinitionId()).thenReturn(EXAMPLE_HIST_INCIDENT_PROC_DEF_ID);
    when(incident.getProcessDefinitionKey()).thenReturn(EXAMPLE_HIST_INCIDENT_PROC_DEF_KEY);
    when(incident.getCauseIncidentId()).thenReturn(EXAMPLE_HIST_INCIDENT_CAUSE_INCIDENT_ID);
    when(incident.getRootCauseIncidentId()).thenReturn(EXAMPLE_HIST_INCIDENT_ROOT_CAUSE_INCIDENT_ID);
    when(incident.getConfiguration()).thenReturn(EXAMPLE_HIST_INCIDENT_CONFIGURATION);
    when(incident.getIncidentMessage()).thenReturn(EXAMPLE_HIST_INCIDENT_MESSAGE);
    when(incident.isOpen()).thenReturn(EXAMPLE_HIST_INCIDENT_STATE_OPEN);
    when(incident.isDeleted()).thenReturn(EXAMPLE_HIST_INCIDENT_STATE_DELETED);
    when(incident.isResolved()).thenReturn(EXAMPLE_HIST_INCIDENT_STATE_RESOLVED);
    when(incident.getTenantId()).thenReturn(tenantId);
    when(incident.getJobDefinitionId()).thenReturn(EXAMPLE_JOB_DEFINITION_ID);
    return incident;
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident)

Example 3 with HistoricIncident

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

the class IncidentAuthorizationTest method clearDatabase.

protected void clearDatabase() {
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Object>() {

        public Object execute(CommandContext commandContext) {
            HistoryLevel historyLevel = Context.getProcessEngineConfiguration().getHistoryLevel();
            if (historyLevel.equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
                commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerSuspendProcessDefinitionHandler.TYPE);
                List<HistoricIncident> incidents = Context.getProcessEngineConfiguration().getHistoryService().createHistoricIncidentQuery().list();
                for (HistoricIncident incident : incidents) {
                    commandContext.getHistoricIncidentManager().delete((HistoricIncidentEntity) incident);
                }
            }
            return null;
        }
    });
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) HistoricIncidentEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) List(java.util.List)

Example 4 with HistoricIncident

use of org.camunda.bpm.engine.history.HistoricIncident 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());
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Incident(org.camunda.bpm.engine.runtime.Incident) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with HistoricIncident

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

the class HistoricIncidentAuthorizationTest method clearDatabase.

protected void clearDatabase() {
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Object>() {

        public Object execute(CommandContext commandContext) {
            commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerSuspendProcessDefinitionHandler.TYPE);
            List<HistoricIncident> incidents = Context.getProcessEngineConfiguration().getHistoryService().createHistoricIncidentQuery().list();
            for (HistoricIncident incident : incidents) {
                commandContext.getHistoricIncidentManager().delete((HistoricIncidentEntity) incident);
            }
            return null;
        }
    });
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) HistoricIncidentEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) List(java.util.List)

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