use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class HistoricProcessInstanceTest method testDeleteProcessInstanceHistoryCreated.
@Deployment(resources = { "org/activiti/engine/test/history/oneTaskProcess.bpmn20.xml" })
public void testDeleteProcessInstanceHistoryCreated() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
assertNotNull(processInstance);
// delete process instance should not delete the history
runtimeService.deleteProcessInstance(processInstance.getId(), "cancel");
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(historicProcessInstance.getEndTime());
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class HistoryServiceTest method testOrderProcessWithCallActivity.
@Deployment(resources = { "org/activiti/examples/bpmn/callactivity/orderProcess.bpmn20.xml", "org/activiti/examples/bpmn/callactivity/checkCreditProcess.bpmn20.xml" })
public void testOrderProcessWithCallActivity() {
// After the process has started, the 'verify credit history' task should be
// active
ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess");
TaskQuery taskQuery = taskService.createTaskQuery();
Task verifyCreditTask = taskQuery.singleResult();
// Completing the task with approval, will end the subprocess and continue
// the original process
taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true));
Task prepareAndShipTask = taskQuery.singleResult();
assertEquals("Prepare and Ship", prepareAndShipTask.getName());
// verify
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult();
assertNotNull(historicProcessInstance);
assertTrue(historicProcessInstance.getProcessDefinitionId().contains("checkCreditProcess"));
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class HistoryServiceTest method testHistoricProcessInstanceUserIdAndActivityId.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testHistoricProcessInstanceUserIdAndActivityId() {
identityService.setAuthenticatedUserId("johndoe");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertEquals("johndoe", historicProcessInstance.getStartUserId());
assertEquals("theStart", historicProcessInstance.getStartActivityId());
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertEquals(1, tasks.size());
taskService.complete(tasks.get(0).getId());
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertEquals("theEnd", historicProcessInstance.getEndActivityId());
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class HistoryServiceTest method testHistoricProcessInstanceQueryByProcessDefinitionKey.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/examples/bpmn/callactivity/orderProcess.bpmn20.xml", "org/activiti/examples/bpmn/callactivity/checkCreditProcess.bpmn20.xml" })
public void testHistoricProcessInstanceQueryByProcessDefinitionKey() {
String processDefinitionKey = "oneTaskProcess";
runtimeService.startProcessInstanceByKey(processDefinitionKey);
runtimeService.startProcessInstanceByKey("orderProcess");
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey(processDefinitionKey).singleResult();
assertNotNull(historicProcessInstance);
assertTrue(historicProcessInstance.getProcessDefinitionKey().equals(processDefinitionKey));
assertEquals("theStart", historicProcessInstance.getStartActivityId());
// now complete the task to end the process instance
Task task = taskService.createTaskQuery().processDefinitionKey("checkCreditProcess").singleResult();
Map<String, Object> map = new HashMap<String, Object>();
map.put("creditApproved", true);
taskService.complete(task.getId(), map);
// and make sure the super process instance is set correctly on the
// HistoricProcessInstance
HistoricProcessInstance historicProcessInstanceSub = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("checkCreditProcess").singleResult();
HistoricProcessInstance historicProcessInstanceSuper = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("orderProcess").singleResult();
assertEquals(historicProcessInstanceSuper.getId(), historicProcessInstanceSub.getSuperProcessInstanceId());
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class HistoryServiceTest method testHistoricProcessInstanceQueryByProcessInstanceIds.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricProcessInstanceQueryByProcessInstanceIds() {
HashSet<String> processInstanceIds = new HashSet<String>();
for (int i = 0; i < 4; i++) {
processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
}
processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());
// start an instance that will not be part of the query
runtimeService.startProcessInstanceByKey("oneTaskProcess2", "2");
HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().processInstanceIds(processInstanceIds);
assertEquals(5, processInstanceQuery.count());
List<HistoricProcessInstance> processInstances = processInstanceQuery.list();
assertNotNull(processInstances);
assertEquals(5, processInstances.size());
for (HistoricProcessInstance historicProcessInstance : processInstances) {
assertTrue(processInstanceIds.contains(historicProcessInstance.getId()));
}
}
Aggregations