Search in sources :

Example 11 with TrackingProcessEventListener

use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.

the class SubprocessesTest method testReusable.

@Test(timeout = 30000)
public void testReusable() {
    TrackingProcessEventListener process = runProcess(ksession, "external");
    Assertions.assertThat(process.wasProcessCompleted(PROCESS_ID_1)).isTrue();
    Assertions.assertThat(process.wasProcessCompleted(HELLO_WORLD_PROCESS_ID)).isTrue();
}
Also used : TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) Test(org.junit.Test)

Example 12 with TrackingProcessEventListener

use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.

the class EventListenersTest method testBadSignal.

@Test(timeout = 60000L)
public void testBadSignal() {
    TrackingProcessEventListener listener = new TrackingProcessEventListener();
    ksession.addEventListener(listener);
    List<Command<?>> commands = new ArrayList<Command<?>>();
    commands.add(getCommands().newStartProcess(PROCESS_ID));
    commands.add(getCommands().newSignalEvent("bad-signal", "bad signal!"));
    ksession.execute(getCommands().newBatchExecution(commands, null));
    assertTrue(listener.wasNodeTriggered("introduction"));
    assertFalse(listener.wasNodeTriggered("info"));
    assertTrue(listener.wasNodeLeft("introduction"));
    assertFalse(listener.wasNodeLeft("info"));
    assertFalse(listener.wasVariableChanged("signalData"));
    assertFalse(listener.wasVariableChanged("stringVariable"));
    assertTrue(listener.wasNodeLeft("script-warning"));
    assertTrue(listener.wasProcessStarted(PROCESS_ID));
    assertTrue(listener.wasProcessCompleted(PROCESS_ID));
}
Also used : Command(org.kie.api.command.Command) TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 13 with TrackingProcessEventListener

use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.

the class EventListenersTest method testUnfinishedProcess.

@Test(timeout = 60000L)
public void testUnfinishedProcess() {
    TrackingProcessEventListener listener = new TrackingProcessEventListener();
    ksession.addEventListener(listener);
    List<Command<?>> commands = new ArrayList<Command<?>>();
    commands.add(getCommands().newStartProcess(PROCESS_ID));
    ksession.execute(getCommands().newBatchExecution(commands, null));
    assertTrue(listener.wasNodeTriggered("introduction"));
    assertTrue(listener.wasNodeTriggered("split"));
    assertTrue(listener.wasNodeLeft("introduction"));
    assertFalse(listener.wasNodeLeft("xor-gateway"));
    assertTrue(listener.wasProcessStarted(PROCESS_ID));
    assertFalse(listener.wasProcessCompleted(PROCESS_ID));
}
Also used : Command(org.kie.api.command.Command) TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 14 with TrackingProcessEventListener

use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.

the class FlexibleProcessTest method testFlexibleProcess.

/**
 * Flexible process with four fragments. -default - with start node, without
 * end event -two fragments which will be signaled -one fragment which won't
 * be signaled - it should not be executed
 */
@Ignore
@Test(timeout = 30000)
public void testFlexibleProcess() throws Exception {
    KieSession ksession = createKSession(PROCESS);
    TrackingProcessEventListener tpel = new TrackingProcessEventListener();
    ksession.addEventListener(tpel);
    TestWorkItemHandler handler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    ProcessInstance pi = ksession.startProcess(PROCESS_ID);
    assertProcessStarted(tpel, PROCESS_ID);
    assertTriggeredAndLeft(tpel, "start");
    assertTriggered(tpel, "task1");
    ksession.signalEvent("userTask", null, pi.getId());
    assertTriggered(tpel, "userTask");
    ksession = restoreKSession(PROCESS);
    Assertions.assertThat(ksession.getProcessEventListeners()).isNotEmpty();
    WorkItem item = handler.getWorkItem();
    ksession.getWorkItemManager().completeWorkItem(item.getId(), null);
    assertTriggered(tpel, "userTask2");
    ksession.signalEvent("task21", null, pi.getId());
    assertTriggeredAndLeft(tpel, "task21");
    assertTriggeredAndLeft(tpel, "task22");
    assertTriggeredAndLeft(tpel, "end1");
    assertProcessCompleted(tpel, PROCESS_ID);
    assertFalse(tpel.wasNodeTriggered("task3"));
    assertFalse(tpel.wasNodeTriggered("end2"));
}
Also used : TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkItem(org.kie.api.runtime.process.WorkItem) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with TrackingProcessEventListener

use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.

the class FlexibleProcessTest method testFlexibleProcessAddWorkItem.

/**
 * Tests dynamic insertion of work item node into adhoc top-level process.
 * DynamicUtils does not support adhoc processes yet, but there is improved
 * version on jbpm master branch.
 */
@Test(timeout = 30000)
public void testFlexibleProcessAddWorkItem() {
    KieSession ksession = createKSession(PROCESS);
    TrackingProcessEventListener tpel = new TrackingProcessEventListener();
    ksession.addEventListener(tpel);
    TestWorkItemHandler handler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("addedWorkItem", handler);
    ProcessInstance pi = ksession.startProcess(PROCESS_ID);
    assertProcessStarted(tpel, PROCESS_ID);
    DynamicUtils.addDynamicWorkItem(pi, ksession, "addedWorkItem", Collections.<String, Object>emptyMap());
    WorkItem wi = handler.getWorkItem();
    ksession.getWorkItemManager().completeWorkItem(wi.getId(), new java.util.HashMap<String, Object>());
    assertEquals(wi.getName(), "addedWorkItem");
}
Also used : TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkItem(org.kie.api.runtime.process.WorkItem) Test(org.junit.Test)

Aggregations

TrackingProcessEventListener (org.jbpm.test.listener.TrackingProcessEventListener)51 Test (org.junit.Test)49 KieSession (org.kie.api.runtime.KieSession)25 IterableProcessEventListener (org.jbpm.test.listener.IterableProcessEventListener)17 Command (org.kie.api.command.Command)16 ArrayList (java.util.ArrayList)13 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)13 BZ (qa.tools.ikeeper.annotation.BZ)9 UserTransaction (javax.transaction.UserTransaction)7 RegisterWorkItemHandlerCommand (org.drools.core.command.runtime.process.RegisterWorkItemHandlerCommand)6 CompleteWorkItemCommand (org.drools.core.command.runtime.process.CompleteWorkItemCommand)5 HashMap (java.util.HashMap)3 TrackingAgendaEventListener (org.jbpm.test.listener.TrackingAgendaEventListener)2 WorkItem (org.kie.api.runtime.process.WorkItem)2 AsyncWorkItemHandler (org.jbpm.executor.impl.wih.AsyncWorkItemHandler)1 JbpmJUnitBaseTestCase (org.jbpm.test.JbpmJUnitBaseTestCase)1 TrackingRuleRuntimeEventListener (org.jbpm.test.listener.TrackingRuleRuntimeEventListener)1 ListWorkItemHandler (org.jbpm.test.wih.ListWorkItemHandler)1 DynamicNodeInstance (org.jbpm.workflow.instance.node.DynamicNodeInstance)1 Before (org.junit.Before)1