use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testParallelCallActivityHistory.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.externalSubProcess.bpmn20.xml" })
public void testParallelCallActivityHistory() {
runtimeService.startProcessInstanceByKey("miParallelCallActivity");
List<Task> tasks = taskService.createTaskQuery().list();
assertEquals(12, tasks.size());
for (int i = 0; i < tasks.size(); i++) {
taskService.complete(tasks.get(i).getId());
}
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
// Validate historic processes
List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
// 6 subprocesses + main process
assertEquals(7, historicProcessInstances.size());
for (HistoricProcessInstance hpi : historicProcessInstances) {
assertNotNull(hpi.getStartTime());
assertNotNull(hpi.getEndTime());
}
// Validate historic activities
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("callActivity").list();
assertEquals(6, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
}
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
// Validate historic tasks
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list();
assertEquals(12, historicTaskInstances.size());
for (HistoricTaskInstance hti : historicTaskInstances) {
assertNotNull(hti.getStartTime());
assertNotNull(hti.getEndTime());
assertNotNull(hti.getAssignee());
assertEquals("completed", hti.getDeleteReason());
}
}
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class CleanableHistoricProcessInstanceReportTest method cleanUp.
@After
public void cleanUp() {
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();
for (ProcessInstance processInstance : processInstances) {
runtimeService.deleteProcessInstance(processInstance.getId(), null, true, true);
}
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
taskService.deleteTask(task.getId(), true);
}
List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
}
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceTest method testHistoricActivityInstanceCalledProcessId.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/calledProcess.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricActivityInstanceTest.testCallSimpleSubProcess.bpmn20.xml" })
public void testHistoricActivityInstanceCalledProcessId() {
runtimeService.startProcessInstanceByKey("callSimpleSubProcess");
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("callSubProcess").singleResult();
HistoricProcessInstance oldInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("calledProcess").singleResult();
assertEquals(oldInstance.getId(), historicActivityInstance.getCalledProcessInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceStateTest method testErrorEndEvent.
@Test
public void testErrorEndEvent() {
BpmnModelInstance process1 = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().endEvent().error("1").done();
ProcessDefinition processDefinition = processEngineTestRule.deployAndGetDefinition(process1);
processEngineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId());
HistoricProcessInstance entity = getHistoricProcessInstanceWithAssertion(processDefinition);
assertThat(entity.getState(), is(HistoricProcessInstance.STATE_COMPLETED));
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testEndTimeAndEndActivity.
@Deployment
public void testEndTimeAndEndActivity() {
// given
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
String taskId = taskService.createTaskQuery().taskDefinitionKey("userTask2").singleResult().getId();
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
// when (1)
taskService.complete(taskId);
// then (1)
HistoricProcessInstance historicProcessInstance = query.singleResult();
assertNull(historicProcessInstance.getEndActivityId());
assertNull(historicProcessInstance.getEndTime());
// when (2)
runtimeService.deleteProcessInstance(processInstanceId, null);
// then (2)
historicProcessInstance = query.singleResult();
assertNull(historicProcessInstance.getEndActivityId());
assertNotNull(historicProcessInstance.getEndTime());
}
Aggregations