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);
}
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;
}
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;
}
});
}
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());
}
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;
}
});
}
Aggregations