Search in sources :

Example 1 with RuleAwareProcessEventListener

use of org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener in project kogito-runtimes by kiegroup.

the class ErrorEventTest method testErrorBoundaryEventOnBusinessRuleTask.

@Test
public void testErrorBoundaryEventOnBusinessRuleTask() throws Exception {
    kruntime = createKogitoProcessRuntime("BPMN2-ErrorBoundaryEventOnBusinessRuleTask.bpmn2", "BPMN2-ErrorBoundaryEventOnBusinessRuleTask.drl");
    kruntime.getProcessEventManager().addEventListener(new RuleAwareProcessEventListener());
    KogitoProcessInstance processInstance = kruntime.startProcess("BPMN2-ErrorBoundaryEventOnBusinessRuleTask");
    assertProcessInstanceFinished(processInstance, kruntime);
    assertNodeTriggered(processInstance.getStringId(), "start", "business rule task error attached", "error1");
}
Also used : RuleAwareProcessEventListener(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) Test(org.junit.jupiter.api.Test)

Example 2 with RuleAwareProcessEventListener

use of org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener in project kogito-runtimes by kiegroup.

the class ActivityTest method testBusinessRuleTaskWithPersistence.

@Test
@RequirePersistence(true)
public void testBusinessRuleTaskWithPersistence() throws Exception {
    kruntime = createKogitoProcessRuntime("BPMN2-BusinessRuleTask.bpmn2", "BPMN2-BusinessRuleTask.drl");
    kruntime.getProcessEventManager().addEventListener(new RuleAwareProcessEventListener());
    KogitoProcessInstance processInstance = kruntime.startProcess("BPMN2-BusinessRuleTask");
    kruntime.getProcessEventManager().addEventListener(new RuleAwareProcessEventListener());
    assertProcessInstanceFinished(processInstance, kruntime);
}
Also used : RuleAwareProcessEventListener(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) Test(org.junit.jupiter.api.Test) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence)

Example 3 with RuleAwareProcessEventListener

use of org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener in project kogito-runtimes by kiegroup.

the class ActivityTest method testBusinessRuleTaskDynamic.

@Test
public void testBusinessRuleTaskDynamic() throws Exception {
    kruntime = createKogitoProcessRuntime("BPMN2-BusinessRuleTaskDynamic.bpmn2", "BPMN2-BusinessRuleTask.drl");
    kruntime.getProcessEventManager().addEventListener(new RuleAwareProcessEventListener());
    Map<String, Object> params = new HashMap<>();
    params.put("dynamicrule", "MyRuleFlow");
    KogitoProcessInstance processInstance = kruntime.startProcess("BPMN2-BusinessRuleTask", params);
    assertProcessInstanceFinished(processInstance, kruntime);
}
Also used : HashMap(java.util.HashMap) RuleAwareProcessEventListener(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) Test(org.junit.jupiter.api.Test)

Example 4 with RuleAwareProcessEventListener

use of org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener in project kogito-runtimes by kiegroup.

the class ActivityTest method testBusinessRuleTask.

@Test
@RequirePersistence(false)
public void testBusinessRuleTask() throws Exception {
    kruntime = createKogitoProcessRuntime("BPMN2-BusinessRuleTask.bpmn2", "BPMN2-BusinessRuleTask.drl");
    kruntime.getProcessEventManager().addEventListener(new RuleAwareProcessEventListener());
    KogitoProcessInstance processInstance = kruntime.startProcess("BPMN2-BusinessRuleTask");
    assertProcessInstanceFinished(processInstance, kruntime);
}
Also used : RuleAwareProcessEventListener(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) Test(org.junit.jupiter.api.Test) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence)

Example 5 with RuleAwareProcessEventListener

use of org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener in project kogito-runtimes by kiegroup.

the class IntermediateEventTest method testIntermediateCatchEventConditionSetVariableAfter.

@Test
public void testIntermediateCatchEventConditionSetVariableAfter() throws Exception {
    kruntime = createKogitoProcessRuntime("BPMN2-IntermediateCatchEventConditionSetVariableAfter.bpmn2");
    kruntime.getProcessEventManager().addEventListener(new RuleAwareProcessEventListener());
    KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEvent");
    assertProcessInstanceActive(processInstance);
    kruntime.getProcessEventManager().addEventListener(new RuleAwareProcessEventListener());
    Collection<? extends Object> processInstances = kruntime.getKieSession().getObjects(object -> {
        if (object instanceof KogitoProcessInstance) {
            return true;
        }
        return false;
    });
    assertThat(processInstances).isNotNull();
    assertThat(processInstances.size()).isEqualTo(1);
    // now activate condition
    Person person = new Person();
    person.setName("Jack");
    kruntime.getKieSession().insert(person);
    assertProcessInstanceFinished(processInstance, kruntime);
    processInstances = kruntime.getKieSession().getObjects(object -> {
        if (object instanceof KogitoProcessInstance) {
            return true;
        }
        return false;
    });
    assertThat(processInstances).isNotNull();
    assertThat(processInstances.size()).isEqualTo(0);
}
Also used : KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) HashMap(java.util.HashMap) NamedDataType(org.kie.kogito.process.NamedDataType) KogitoProcessRuntime(org.kie.kogito.internal.process.runtime.KogitoProcessRuntime) Disabled(org.junit.jupiter.api.Disabled) ExecutableCommand(org.kie.api.command.ExecutableCommand) DefaultKogitoProcessEventListener(org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener) TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) KogitoProcessEventListener(org.kie.kogito.internal.process.event.KogitoProcessEventListener) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) ProcessNodeLeftEvent(org.kie.api.event.process.ProcessNodeLeftEvent) Map(java.util.Map) KogitoWorkflowProcessInstance(org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance) KogitoWorkItemHandler(org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler) RuleAwareProcessEventListener(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener) DoNothingWorkItemHandler(org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence) Collection(java.util.Collection) Set(java.util.Set) StringDataType(org.jbpm.process.core.datatype.impl.type.StringDataType) KogitoNodeInstance(org.kie.kogito.internal.process.runtime.KogitoNodeInstance) SendTaskHandler(org.jbpm.bpmn2.handler.SendTaskHandler) FactHandle(org.kie.api.runtime.rule.FactHandle) Test(org.junit.jupiter.api.Test) List(java.util.List) ProcessNodeTriggeredEvent(org.kie.api.event.process.ProcessNodeTriggeredEvent) OffsetDateTime(java.time.OffsetDateTime) Assertions.fail(org.assertj.core.api.Assertions.fail) NodeLeftCountDownProcessEventListener(org.jbpm.test.util.NodeLeftCountDownProcessEventListener) Person(org.jbpm.bpmn2.objects.Person) EventDescription(org.kie.kogito.process.EventDescription) KogitoWorkItemManager(org.kie.kogito.internal.process.runtime.KogitoWorkItemManager) Timeout(org.junit.jupiter.api.Timeout) ProcessStartedEvent(org.kie.api.event.process.ProcessStartedEvent) InternalKogitoWorkItem(org.kie.kogito.process.workitems.InternalKogitoWorkItem) ReceiveTaskHandler(org.jbpm.bpmn2.handler.ReceiveTaskHandler) RuleAwareProcessEventListener(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) Person(org.jbpm.bpmn2.objects.Person) Test(org.junit.jupiter.api.Test)

Aggregations

RuleAwareProcessEventListener (org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener)8 Test (org.junit.jupiter.api.Test)8 KogitoProcessInstance (org.kie.kogito.internal.process.runtime.KogitoProcessInstance)8 HashMap (java.util.HashMap)5 RequirePersistence (org.jbpm.bpmn2.test.RequirePersistence)5 Person (org.jbpm.bpmn2.objects.Person)4 OffsetDateTime (java.time.OffsetDateTime)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.fail (org.assertj.core.api.Assertions.fail)2 ReceiveTaskHandler (org.jbpm.bpmn2.handler.ReceiveTaskHandler)2 SendTaskHandler (org.jbpm.bpmn2.handler.SendTaskHandler)2 TestWorkItemHandler (org.jbpm.bpmn2.objects.TestWorkItemHandler)2 StringDataType (org.jbpm.process.core.datatype.impl.type.StringDataType)2