KieSession ksession = engine.getKieSession();
TaskService taskService = engine.getTaskService();
Map<String,Object> params = new HashMap<String,Object>();
params.put("userid", "max");
ProcessInstance processInstance = ksession.startProcess("agu.samples.sample1", params);
AuditLogService logService = (AuditLogService) context.getBean("logService");
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
TransactionStatus status = aptm.getTransaction(def);
ProcessInstanceLog log = logService.findProcessInstance(processInstance.getId());
assertNotNull(log);
aptm.commit(status);
List<TaskSummary> tasks = taskService.getTasksOwned("max", "en-UK");
System.out.println("Found " + tasks.size() + " task(s) for user 'max'");
long taskId = tasks.get(0).getId();
taskService.start(taskId, "max");
taskService.complete(taskId, "max", null);
tasks = taskService.getTasksAssignedAsPotentialOwner("max", "en-UK");
System.out.println("Found " + tasks.size() + " task(s) for user 'max'");
taskId = tasks.get(0).getId();
taskService.start(taskId, "max");
taskService.complete(taskId, "max", null);
processInstance = ksession.getProcessInstance(processInstance.getId());
assertNull(processInstance);
System.out.println("Process instance completed");
}