Search in sources :

Example 1 with SignalEvent

use of org.kie.api.event.process.SignalEvent in project kogito-runtimes by kiegroup.

the class KogitoProcessEventSupportImpl method fireOnSignal.

@Override
public void fireOnSignal(final KogitoProcessInstance instance, KogitoNodeInstance nodeInstance, KieRuntime kruntime, String signalName, Object signalObject) {
    if (hasListeners()) {
        final SignalEvent event = new SignalEventImpl(instance, kruntime, nodeInstance, signalName, signalObject);
        notifyAllListeners(event, ProcessEventListener::onSignal);
    }
}
Also used : SignalEventImpl(org.drools.core.event.SignalEventImpl) ProcessEventListener(org.kie.api.event.process.ProcessEventListener) KogitoProcessEventListener(org.kie.kogito.internal.process.event.KogitoProcessEventListener) SignalEvent(org.kie.api.event.process.SignalEvent)

Example 2 with SignalEvent

use of org.kie.api.event.process.SignalEvent in project drools by kiegroup.

the class ProcessEventSupport method fireOnSignal.

public void fireOnSignal(final ProcessInstance instance, NodeInstance nodeInstance, KieRuntime kruntime, String signalName, Object signalObject) {
    if (hasListeners()) {
        final SignalEvent event = new SignalEventImpl(instance, kruntime, nodeInstance, signalName, signalObject);
        notifyAllListeners(event, ProcessEventListener::onSignal);
    }
}
Also used : ProcessEventListener(org.kie.api.event.process.ProcessEventListener) SignalEvent(org.kie.api.event.process.SignalEvent)

Example 3 with SignalEvent

use of org.kie.api.event.process.SignalEvent in project kogito-runtimes by kiegroup.

the class SignalEventIT method testIntermediateEndSignal.

@Test
public void testIntermediateEndSignal() throws Exception {
    Application app = generateCode(Collections.singletonMap(TYPE.PROCESS, Collections.singletonList("signalevent/EndEventSignalWithData.bpmn2")));
    KogitoProcessEventListener listener = mock(KogitoProcessEventListener.class);
    app.config().get(ProcessConfig.class).processEventListeners().listeners().add(listener);
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.get(Processes.class).processById("src.simpleEndSignal");
    ProcessInstance<?> processInstance = p.createInstance(p.createModel());
    processInstance.start();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    ArgumentCaptor<SignalEvent> signalEvent = ArgumentCaptor.forClass(SignalEvent.class);
    verify(listener).onSignal(signalEvent.capture());
    assertThat(signalEvent.getValue().getSignalName()).isEqualTo("Signal1");
    assertThat(signalEvent.getValue().getSignal()).isEqualTo("Some value");
}
Also used : ProcessConfig(org.kie.kogito.process.ProcessConfig) KogitoProcessEventListener(org.kie.kogito.internal.process.event.KogitoProcessEventListener) SignalEvent(org.kie.api.event.process.SignalEvent) Processes(org.kie.kogito.process.Processes) Application(org.kie.kogito.Application) Test(org.junit.jupiter.api.Test)

Example 4 with SignalEvent

use of org.kie.api.event.process.SignalEvent in project kogito-runtimes by kiegroup.

the class SignalEventIT method testIntermediateThrowSignal.

@Test
public void testIntermediateThrowSignal() throws Exception {
    Application app = generateCode(Collections.singletonMap(TYPE.PROCESS, Collections.singletonList("signalevent/IntermediateThrowEventSignal.bpmn2")));
    KogitoProcessEventListener listener = mock(KogitoProcessEventListener.class);
    app.config().get(ProcessConfig.class).processEventListeners().listeners().add(listener);
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.get(Processes.class).processById("IntermediateThrowEventSignal");
    Model m = p.createModel();
    m.update(Collections.singletonMap("x", "Javierito"));
    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    ArgumentCaptor<SignalEvent> signalEvent = ArgumentCaptor.forClass(SignalEvent.class);
    verify(listener).onSignal(signalEvent.capture());
    assertThat(signalEvent.getValue().getSignalName()).isEqualTo("MySignal");
    assertThat(signalEvent.getValue().getSignal()).isEqualTo("Javierito");
}
Also used : ProcessConfig(org.kie.kogito.process.ProcessConfig) KogitoProcessEventListener(org.kie.kogito.internal.process.event.KogitoProcessEventListener) Model(org.kie.kogito.Model) SignalEvent(org.kie.api.event.process.SignalEvent) Processes(org.kie.kogito.process.Processes) Application(org.kie.kogito.Application) Test(org.junit.jupiter.api.Test)

Aggregations

SignalEvent (org.kie.api.event.process.SignalEvent)4 KogitoProcessEventListener (org.kie.kogito.internal.process.event.KogitoProcessEventListener)3 Test (org.junit.jupiter.api.Test)2 ProcessEventListener (org.kie.api.event.process.ProcessEventListener)2 Application (org.kie.kogito.Application)2 ProcessConfig (org.kie.kogito.process.ProcessConfig)2 Processes (org.kie.kogito.process.Processes)2 SignalEventImpl (org.drools.core.event.SignalEventImpl)1 Model (org.kie.kogito.Model)1