public ProcessInstanceLog execute(Context cntxt) { setLogEnvironment(cntxt); return this.auditLogService.findProcessInstance(processInstanceId); }
protected boolean assertProcessInstanceState(int state, ProcessInstance processInstance) { if (sessionPersistence) { ProcessInstanceLog log = logService.findProcessInstance(processInstance.getId()); if (log != null) { return log.getStatus() == state; } } else { return processInstance.getState() == state; } return false; }
private int getSLAComplianceForProcessInstance(ProcessInstance processInstance) { int slaCompliance = -1; if (sessionPersistence) { ProcessInstanceLog log = logService.findProcessInstance(processInstance.getId()); if (log != null) { slaCompliance = log.getSlaCompliance(); } } else { slaCompliance = ((org.jbpm.process.instance.ProcessInstance)processInstance).getSlaCompliance(); } return slaCompliance; }
assertProcessInstanceFinished(processInstance, ksession); ProcessInstanceLog log = logService.findProcessInstance(childPI); assertNotNull(log); assertEquals(ProcessInstance.STATE_ABORTED, log.getStatus().intValue()); log = logService.findProcessInstance(processInstance.getId()); assertNotNull(log); assertEquals("Parent process should be completed and not aborted", ProcessInstance.STATE_COMPLETED, log.getStatus().intValue());
@Test @RequirePersistence public void testScriptTaskWithHistoryLog() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-ScriptTask.bpmn2"); ksession = createKnowledgeSession(kbase); ProcessInstance processInstance = ksession.startProcess("ScriptTask"); assertProcessInstanceCompleted(processInstance); AuditLogService logService = new JPAAuditLogService(ksession.getEnvironment()); List<NodeInstanceLog> logs = logService.findNodeInstances(processInstance.getId()); assertNotNull(logs); assertEquals(6, logs.size()); for (NodeInstanceLog log : logs) { assertNotNull(log.getDate()); } ProcessInstanceLog pilog = logService.findProcessInstance(processInstance.getId()); assertNotNull(pilog); assertNotNull(pilog.getEnd()); List<ProcessInstanceLog> pilogs = logService.findActiveProcessInstances(processInstance.getProcessId()); assertNotNull(pilogs); assertEquals(0, pilogs.size()); logService.dispose(); }
private int getSLAComplianceForProcessInstance(ProcessInstance processInstance) { int slaCompliance = -1; if (sessionPersistence) { ProcessInstanceLog log = logService.findProcessInstance(processInstance.getId()); if (log != null) { slaCompliance = log.getSlaCompliance(); } } else { slaCompliance = ((org.jbpm.process.instance.ProcessInstance)processInstance).getSlaCompliance(); } return slaCompliance; }
protected boolean assertProcessInstanceState(int state, ProcessInstance processInstance) { if (sessionPersistence) { ProcessInstanceLog log = logService.findProcessInstance(processInstance.getId()); if (log != null) { return log.getStatus() == state; } } else { return processInstance.getState() == state; } return false; }
@Test public void testCompleteTaskInSwimlane() throws Exception{ KieSession ksession = getKieSession(); TaskService taskService = getTaskService(); Map<String,Object> params = new HashMap<String,Object>(); params.put("userid", USER_MAX); ProcessInstance processInstance = ksession.startProcess(AGU_SAMPLE_PROCESS_ID, params); ProcessInstanceLog log = getLogService().findProcessInstance(processInstance.getId()); assertNotNull(log); List<TaskSummary> tasks = taskService.getTasksOwned(USER_MAX, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+USER_MAX+"'"); long taskId = tasks.get(0).getId(); taskService.start(taskId, USER_MAX); taskService.complete(taskId, USER_MAX, null); tasks = taskService.getTasksAssignedAsPotentialOwner(USER_MAX, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+USER_MAX+"'"); taskId = tasks.get(0).getId(); taskService.start(taskId, USER_MAX); taskService.complete(taskId, USER_MAX, null); processInstance = ksession.getProcessInstance(processInstance.getId()); assertNull(processInstance); System.out.println("Process instance completed"); }
@Test public void testCompleteTaskInSwimlane() throws Exception{ KieSession ksession = getKieSession(); TaskService taskService = getTaskService(); Map<String,Object> params = new HashMap<String,Object>(); params.put("userid", USER_MAX); ProcessInstance processInstance = ksession.startProcess(AGU_SAMPLE_PROCESS_ID, params); ProcessInstanceLog log = getLogService().findProcessInstance(processInstance.getId()); assertNotNull(log); List<TaskSummary> tasks = taskService.getTasksOwned(USER_MAX, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+USER_MAX+"'"); long taskId = tasks.get(0).getId(); taskService.start(taskId, USER_MAX); taskService.complete(taskId, USER_MAX, null); tasks = taskService.getTasksAssignedAsPotentialOwner(USER_MAX, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+USER_MAX+"'"); taskId = tasks.get(0).getId(); taskService.start(taskId, USER_MAX); taskService.complete(taskId, USER_MAX, null); processInstance = ksession.getProcessInstance(processInstance.getId()); assertNull(processInstance); System.out.println("Process instance completed"); }
@Test public void testSpringWithJTAAndSharedEMFAndUserManagedTx() throws Exception { UserTransaction ut = (UserTransaction) new InitialContext().lookup(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME); ut.begin(); KieSession ksession = getKieSession(); TaskService taskService = getTaskService(); ProcessInstance processInstance = ksession.startProcess(SAMPLE_HELLO_PROCESS_ID); System.out.println("Process started"); AuditLogService logService = getLogService(); ProcessInstanceLog log = logService.findProcessInstance(processInstance.getId()); assertNotNull(log); List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+ USER_JOHN + "'"); assertEquals(1, tasks.size()); long taskId = tasks.get(0).getId(); taskService.start(taskId, USER_JOHN); taskService.complete(taskId, USER_JOHN, null); tasks = taskService.getTasksAssignedAsPotentialOwner(USER_MARY, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+ USER_MARY + "'"); assertEquals(1, tasks.size()); taskId = tasks.get(0).getId(); taskService.start(taskId, USER_MARY); taskService.complete(taskId, USER_MARY, null); processInstance = ksession.getProcessInstance(processInstance.getId()); assertNull(processInstance); System.out.println("Process instance completed"); ut.commit(); }
/** * Simple test to verify that application is operational even without context factory defined. */ @Test public void testSimpleTaskInvocation() throws Exception { RuntimeManager manager = getManager(); AuditLogService logService = getLogService(); RuntimeEngine engine = getEngine(); KieSession ksession = getKieSession(); ProcessInstance processInstance = ksession.startProcess(SAMPLE_HELLO_PROCESS_ID); System.out.println("Process started"); ProcessInstanceLog instanceLog = logService.findProcessInstance(processInstance.getId()); assertNotNull(instanceLog); assertEquals(ProcessInstance.STATE_ACTIVE, instanceLog.getStatus().intValue()); ksession.abortProcessInstance(processInstance.getId()); System.out.println("Process instance aborted"); instanceLog = logService.findProcessInstance(processInstance.getId()); assertNotNull(instanceLog); assertEquals(ProcessInstance.STATE_ABORTED, instanceLog.getStatus().intValue()); manager.disposeRuntimeEngine(engine); } }
/** * Simple test to verify that application is operational even without context factory defined. */ @Test public void testSimpleTaskInvocation() throws Exception { RuntimeManager manager = getManager(); AuditLogService logService = getLogService(); RuntimeEngine engine = getEngine(); KieSession ksession = getKieSession(); ProcessInstance processInstance = ksession.startProcess(SAMPLE_HELLO_PROCESS_ID); System.out.println("Process started"); ProcessInstanceLog instanceLog = logService.findProcessInstance(processInstance.getId()); assertNotNull(instanceLog); assertEquals(ProcessInstance.STATE_ACTIVE, instanceLog.getStatus().intValue()); ksession.abortProcessInstance(processInstance.getId()); System.out.println("Process instance aborted"); instanceLog = logService.findProcessInstance(processInstance.getId()); assertNotNull(instanceLog); assertEquals(ProcessInstance.STATE_ABORTED, instanceLog.getStatus().intValue()); manager.disposeRuntimeEngine(engine); } }
@Test public void testUserTransaction() throws Exception { UserTransaction ut = (UserTransaction) new InitialContext().lookup( JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME ); ut.begin(); RuntimeManager manager = getManager(); RuntimeEngine engine = getEngine(); KieSession ksession = getKieSession(); ProcessInstance processInstance = ksession.startProcess(SCRIPT_TASK_PROCESS_ID); ProcessInstanceLog instanceLog = getLogService().findProcessInstance(processInstance.getId()); assertNotNull(instanceLog); assertEquals(ProcessInstance.STATE_COMPLETED, instanceLog.getStatus().intValue()); ut.commit(); manager.disposeRuntimeEngine(engine); } }
@Test public void testUserTransaction() throws Exception { UserTransaction ut = (UserTransaction) new InitialContext().lookup( JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME ); ut.begin(); RuntimeManager manager = getManager(); RuntimeEngine engine = getEngine(); KieSession ksession = getKieSession(); ProcessInstance processInstance = ksession.startProcess(SCRIPT_TASK_PROCESS_ID); ProcessInstanceLog instanceLog = getLogService().findProcessInstance(processInstance.getId()); assertNotNull(instanceLog); assertEquals(ProcessInstance.STATE_COMPLETED, instanceLog.getStatus().intValue()); ut.commit(); manager.disposeRuntimeEngine(engine); } }
@Test public void testAuditLog() throws Exception { KieSession ksession = getKieSession(); final ProcessInstance processInstance = ksession.startProcess(SAMPLE_HELLO_PROCESS_ID); RuntimeManager manager = getManager(); RuntimeEngine engine = getEngine(); AuditLogService logService = getLogService(); ProcessInstanceLog instanceLog = logService.findProcessInstance(processInstance.getId()); assertNotNull(instanceLog); assertEquals(ProcessInstance.STATE_ACTIVE, instanceLog.getStatus().intValue()); ksession.abortProcessInstance(processInstance.getId()); instanceLog = logService.findProcessInstance(processInstance.getId()); assertNotNull(instanceLog); assertEquals(ProcessInstance.STATE_ABORTED, instanceLog.getStatus().intValue()); manager.disposeRuntimeEngine(engine); }
@Test public void testSimpleTaskInvocation() throws Exception{ RuntimeManager manager = getManager(); RuntimeEngine engine = getEngine(); KieSession ksession = getKieSession(); TaskService taskService = getTaskService(); ProcessInstance processInstance = ksession.startProcess(SAMPLE_HELLO_PROCESS_ID); System.out.println("Process started"); AuditLogService logService = getLogService(); ProcessInstanceLog log = logService.findProcessInstance(processInstance.getId()); assertNotNull(log); List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+USER_JOHN+"'"); assertEquals(1, tasks.size()); long taskId = tasks.get(0).getId(); taskService.start(taskId, USER_JOHN); taskService.complete(taskId, USER_JOHN, null); tasks = taskService.getTasksAssignedAsPotentialOwner(USER_MARY, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+USER_MARY+"'"); assertEquals(1, tasks.size()); taskId = tasks.get(0).getId(); taskService.start(taskId, USER_MARY); taskService.complete(taskId, USER_MARY, null); processInstance = ksession.getProcessInstance(processInstance.getId()); assertNull(processInstance); System.out.println("Process instance completed"); manager.disposeRuntimeEngine(engine); }
@Test public void testAuditLog() throws Exception { KieSession ksession = getKieSession(); final ProcessInstance processInstance = ksession.startProcess(SAMPLE_HELLO_PROCESS_ID); RuntimeManager manager = getManager(); RuntimeEngine engine = getEngine(); AuditLogService logService = getLogService(); ProcessInstanceLog instanceLog = logService.findProcessInstance(processInstance.getId()); assertNotNull(instanceLog); assertEquals(ProcessInstance.STATE_ACTIVE, instanceLog.getStatus().intValue()); ksession.abortProcessInstance(processInstance.getId()); instanceLog = logService.findProcessInstance(processInstance.getId()); assertNotNull(instanceLog); assertEquals(ProcessInstance.STATE_ABORTED, instanceLog.getStatus().intValue()); manager.disposeRuntimeEngine(engine); }
@Test public void testSimpleTaskInvocationWithRollback() throws Exception{ AbstractPlatformTransactionManager transactionManager = getTransactionManager(); RuntimeManager manager = getManager(); RuntimeEngine engine = getEngine(); KieSession ksession = getKieSession(); AuditLogService logService = getLogService(); DefaultTransactionDefinition def = new DefaultTransactionDefinition(); TransactionStatus status = transactionManager.getTransaction(def); ProcessInstance processInstance = ksession.startProcess(SAMPLE_HELLO_PROCESS_ID); long processInstanceId = processInstance.getId(); transactionManager.rollback(status); processInstance = ksession.getProcessInstance(processInstanceId); assertNull("Process instance not rolled back", processInstance); System.out.println("Process instance rolled back"); List<TaskSummary> tasks = getTaskService().getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+USER_JOHN+"'"); assertEquals(0, tasks.size()); ProcessInstanceLog log = logService.findProcessInstance(processInstanceId); assertNull(log); manager.disposeRuntimeEngine(engine); } }
@Test public void testSimpleTaskInvocationWithRollback() throws Exception{ AbstractPlatformTransactionManager transactionManager = getTransactionManager(); RuntimeManager manager = getManager(); RuntimeEngine engine = getEngine(); KieSession ksession = getKieSession(); AuditLogService logService = getLogService(); DefaultTransactionDefinition def = new DefaultTransactionDefinition(); TransactionStatus status = transactionManager.getTransaction(def); ProcessInstance processInstance = ksession.startProcess(SAMPLE_HELLO_PROCESS_ID); long processInstanceId = processInstance.getId(); transactionManager.rollback(status); processInstance = ksession.getProcessInstance(processInstanceId); assertNull("Process instance not rolled back", processInstance); System.out.println("Process instance rolled back"); List<TaskSummary> tasks = getTaskService().getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); System.out.println("Found " + tasks.size() + " task(s) for user '"+USER_JOHN+"'"); assertEquals(0, tasks.size()); ProcessInstanceLog log = logService.findProcessInstance(processInstanceId); assertNull(log); manager.disposeRuntimeEngine(engine); } }
@Test @RequirePersistence public void testScriptTaskWithHistoryLog() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-ScriptTask.bpmn2"); ksession = createKnowledgeSession(kbase); ProcessInstance processInstance = ksession.startProcess("ScriptTask"); assertProcessInstanceCompleted(processInstance); AuditLogService logService = new JPAAuditLogService(ksession.getEnvironment()); List<NodeInstanceLog> logs = logService.findNodeInstances(processInstance.getId()); assertNotNull(logs); assertEquals(6, logs.size()); for (NodeInstanceLog log : logs) { assertNotNull(log.getDate()); } ProcessInstanceLog pilog = logService.findProcessInstance(processInstance.getId()); assertNotNull(pilog); assertNotNull(pilog.getEnd()); List<ProcessInstanceLog> pilogs = logService.findActiveProcessInstances(processInstance.getProcessId()); assertNotNull(pilogs); assertEquals(0, pilogs.size()); logService.dispose(); }