use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoryServiceTest method testHistoricProcessInstanceQueryByProcessDefinitionKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/history/orderProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/history/checkCreditProcess.bpmn20.xml" })
public void testHistoricProcessInstanceQueryByProcessDefinitionKey() {
String processDefinitionKey = ONE_TASK_PROCESS;
runtimeService.startProcessInstanceByKey(processDefinitionKey);
runtimeService.startProcessInstanceByKey("orderProcess");
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey(processDefinitionKey).singleResult();
assertNotNull(historicProcessInstance);
assertTrue(historicProcessInstance.getProcessDefinitionId().startsWith(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.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoryServiceTest method testOrderProcessWithCallActivity.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/history/orderProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/history/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.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationHistoryTest method testCancelTaskShouldCancelProcessInstance.
@Deployment(resources = ONE_TASK_PROCESS)
public void testCancelTaskShouldCancelProcessInstance() {
// given
String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId();
// when
runtimeService.createProcessInstanceModification(processInstanceId).cancelAllForActivity("theTask").execute(true, false);
// then
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertNotNull(instance);
assertEquals(processInstanceId, instance.getId());
assertNotNull(instance.getEndTime());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricActivityInstancesForSubprocess.
@Deployment(resources = SUBPROCESS_PROCESS)
public void testHistoricActivityInstancesForSubprocess() {
// when
ProcessInstance instance = runtimeService.createProcessInstanceByKey("subprocess").startBeforeActivity("innerTask").startBeforeActivity("theSubProcessStart").execute();
// then
HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertNotNull(historicInstance);
assertEquals(instance.getId(), historicInstance.getId());
assertNotNull(historicInstance.getStartTime());
assertNull(historicInstance.getEndTime());
// should be the first activity started
assertEquals("innerTask", historicInstance.getStartActivityId());
// subprocess, subprocess start event, two innerTasks
assertEquals(4, historyService.createHistoricActivityInstanceQuery().count());
HistoricActivityInstance subProcessInstance = historyService.createHistoricActivityInstanceQuery().activityId("subProcess").singleResult();
assertNotNull(subProcessInstance);
assertEquals("subProcess", subProcessInstance.getActivityId());
assertNotNull(subProcessInstance.getId());
assertFalse(instance.getId().equals(subProcessInstance.getId()));
assertNotNull(subProcessInstance.getStartTime());
assertNull(subProcessInstance.getEndTime());
HistoricActivityInstance startEventInstance = historyService.createHistoricActivityInstanceQuery().activityId("theSubProcessStart").singleResult();
assertNotNull(startEventInstance);
assertEquals("theSubProcessStart", startEventInstance.getActivityId());
assertNotNull(startEventInstance.getId());
assertFalse(instance.getId().equals(startEventInstance.getId()));
assertNotNull(startEventInstance.getStartTime());
assertNotNull(startEventInstance.getEndTime());
List<HistoricActivityInstance> innerTaskInstances = historyService.createHistoricActivityInstanceQuery().activityId("innerTask").list();
assertEquals(2, innerTaskInstances.size());
for (HistoricActivityInstance innerTaskInstance : innerTaskInstances) {
assertNotNull(innerTaskInstance);
assertEquals("innerTask", innerTaskInstance.getActivityId());
assertNotNull(innerTaskInstance.getId());
assertFalse(instance.getId().equals(innerTaskInstance.getId()));
assertNotNull(innerTaskInstance.getStartTime());
assertNull(innerTaskInstance.getEndTime());
}
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricProcessInstanceForSynchronousCompletion.
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testHistoricProcessInstanceForSynchronousCompletion() {
// when the process instance ends immediately
ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").startAfterActivity("task1").execute();
// then
HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertNotNull(historicInstance);
assertEquals(instance.getId(), historicInstance.getId());
assertNotNull(historicInstance.getStartTime());
assertNotNull(historicInstance.getEndTime());
assertEquals("join", historicInstance.getStartActivityId());
}
Aggregations