Search in sources :

Example 1 with ProcessScenario

use of org.jbpm.test.container.archive.ejbtransactions.ProcessScenario in project jbpm by kiegroup.

the class EJBTransactionsTest method startProcess.

private void startProcess(ProcessEJB ejb) {
    TrackingProcessEventListener listener = new TrackingProcessEventListener();
    final TestWorkItemHandler wih = new TestWorkItemHandler();
    Assertions.assertThat(kbase).isNotNull();
    ProcessScenario scenario = new ProcessScenario(kbase, EJBTransactions.PROCESS_DOUBLE_HUMAN_TASKS, null, listener) {

        @Override
        protected void runScenario(String procId, Map<String, Object> params, KieSession ksession) {
            ksession.getWorkItemManager().registerWorkItemHandler("Human Task", wih);
            ksession.startProcess(procId, params);
            // first task
            ksession.getWorkItemManager().completeWorkItem(wih.getWorkItem().getId(), null);
            // second task
            ksession.getWorkItemManager().completeWorkItem(wih.getWorkItem().getId(), null);
        }
    };
    ejb.startProcess(scenario);
    if (scenario.hasErrors()) {
        throw new RuntimeException(scenario.getErrors().get(0));
    }
    TrackingListenerAssert.assertProcessStarted(listener, EJBTransactions.PROCESS_DOUBLE_HUMAN_TASKS);
    TrackingListenerAssert.assertTriggeredAndLeft(listener, "Upload Form");
    TrackingListenerAssert.assertTriggeredAndLeft(listener, "Approve It");
    TrackingListenerAssert.assertProcessCompleted(listener, EJBTransactions.PROCESS_DOUBLE_HUMAN_TASKS);
}
Also used : ProcessScenario(org.jbpm.test.container.archive.ejbtransactions.ProcessScenario) TrackingProcessEventListener(org.jbpm.test.container.listeners.TrackingProcessEventListener) KieSession(org.kie.api.runtime.KieSession) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 ProcessScenario (org.jbpm.test.container.archive.ejbtransactions.ProcessScenario)1 TrackingProcessEventListener (org.jbpm.test.container.listeners.TrackingProcessEventListener)1 KieSession (org.kie.api.runtime.KieSession)1