use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class TerminateEndEventTest method testTerminateInSubProcessConcurrentShouldNotEndProcessInstanceInHistory.
/**
* CAM-4067
*/
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/end/TerminateEndEventTest.testTerminateInSubProcessConcurrent.bpmn")
public void testTerminateInSubProcessConcurrentShouldNotEndProcessInstanceInHistory() throws Exception {
// when process instance is started and terminate end event in subprocess executed
ProcessInstance pi = runtimeService.startProcessInstanceByKey("terminateEndEventExample");
// then the historic process instance should not appear ended
assertProcessNotEnded(pi.getId());
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().singleResult();
assertNotNull(hpi);
assertNull(hpi.getEndTime());
assertNull(hpi.getDurationInMillis());
assertNull(hpi.getDeleteReason());
}
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class BoundaryErrorEventTest method FAILING_testCatchErrorOnCallActivityShouldEndCalledProcessProperly.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.testCatchErrorOnCallActivity-parent.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.subprocess.bpmn20.xml" })
public void FAILING_testCatchErrorOnCallActivityShouldEndCalledProcessProperly() {
// given a process instance that has instantiated (called) a sub process instance
runtimeService.startProcessInstanceByKey("catchErrorOnCallActivity").getId();
Task task = taskService.createTaskQuery().singleResult();
assertEquals("Task in subprocess", task.getName());
// when an error end event is triggered in the sub process instance and catched in the super process instance
taskService.complete(task.getId());
task = taskService.createTaskQuery().singleResult();
assertEquals("Escalated Task", task.getName());
// then the called historic process instance should have properly ended
HistoricProcessInstance historicSubProcessInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("simpleSubProcess").singleResult();
assertNotNull(historicSubProcessInstance);
assertNull(historicSubProcessInstance.getDeleteReason());
assertEquals("theEnd", historicSubProcessInstance.getEndActivityId());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class DeleteHistoricProcessInstancesBatchCmd method collectHistoricProcessInstanceIds.
protected List<String> collectHistoricProcessInstanceIds() {
Set<String> collectedProcessInstanceIds = new HashSet<String>();
List<String> processInstanceIds = this.getHistoricProcessInstanceIds();
if (processInstanceIds != null) {
collectedProcessInstanceIds.addAll(processInstanceIds);
}
final HistoricProcessInstanceQueryImpl processInstanceQuery = (HistoricProcessInstanceQueryImpl) this.historicProcessInstanceQuery;
if (processInstanceQuery != null) {
for (HistoricProcessInstance hpi : processInstanceQuery.list()) {
collectedProcessInstanceIds.add(hpi.getId());
}
}
return new ArrayList<String>(collectedProcessInstanceIds);
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricDetailAuthorizationTest method testQueryAfterDeletingDeployment.
// delete deployment (cascade = false)
public void testQueryAfterDeletingDeployment() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String taskId = selectSingleTask().getId();
disableAuthorization();
formService.submitTaskForm(taskId, getVariables());
enableAuthorization();
startProcessInstanceByKey(PROCESS_KEY);
taskId = selectSingleTask().getId();
disableAuthorization();
formService.submitTaskForm(taskId, getVariables());
enableAuthorization();
startProcessInstanceByKey(PROCESS_KEY, getVariables());
startProcessInstanceByKey(PROCESS_KEY, getVariables());
startProcessInstanceByKey(PROCESS_KEY, getVariables());
createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);
disableAuthorization();
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
taskService.complete(task.getId());
}
enableAuthorization();
disableAuthorization();
repositoryService.deleteDeployment(deploymentId);
enableAuthorization();
// when
HistoricDetailQuery query = historyService.createHistoricDetailQuery();
// then
verifyQueryResults(query, 7);
disableAuthorization();
List<HistoricProcessInstance> instances = historyService.createHistoricProcessInstanceQuery().list();
for (HistoricProcessInstance instance : instances) {
historyService.deleteHistoricProcessInstance(instance.getId());
}
enableAuthorization();
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoryCleanupAuthorizationTest method clearDatabase.
protected void clearDatabase() {
// reset configuration changes
String defaultStartTime = processEngineConfiguration.getHistoryCleanupBatchWindowStartTime();
String defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime();
int defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize();
processEngineConfiguration.setHistoryCleanupBatchWindowStartTime(defaultStartTime);
processEngineConfiguration.setHistoryCleanupBatchWindowEndTime(defaultEndTime);
processEngineConfiguration.setHistoryCleanupBatchSize(defaultBatchSize);
processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
List<Job> jobs = managementService.createJobQuery().list();
if (jobs.size() > 0) {
assertEquals(1, jobs.size());
String jobId = jobs.get(0).getId();
commandContext.getJobManager().deleteJob((JobEntity) jobs.get(0));
commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
}
List<HistoricIncident> historicIncidents = historyService.createHistoricIncidentQuery().list();
for (HistoricIncident historicIncident : historicIncidents) {
commandContext.getDbEntityManager().delete((HistoricIncidentEntity) historicIncident);
}
commandContext.getMeterLogManager().deleteAll();
return null;
}
});
List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
}
List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list();
for (HistoricDecisionInstance historicDecisionInstance : historicDecisionInstances) {
historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
}
List<HistoricCaseInstance> historicCaseInstances = historyService.createHistoricCaseInstanceQuery().list();
for (HistoricCaseInstance historicCaseInstance : historicCaseInstances) {
historyService.deleteHistoricCaseInstance(historicCaseInstance.getId());
}
}
Aggregations