Search in sources :

Example 1 with DefaultEvent

use of com.graphaware.nlp.event.DefaultEvent in project neo4j-nlp by graphaware.

the class NLPExtensionTest method testExtensionCanRegisterEventListeners.

@Test
public void testExtensionCanRegisterEventListeners() {
    Map<String, NLPExtension> loadedExtensions = ServiceLoader.loadInstances(NLPModuleExtension.class);
    EventDispatcher dispatcher = new EventDispatcher();
    loadedExtensions.values().forEach(nlpExtension -> {
        nlpExtension.registerEventListeners(dispatcher);
    });
    dispatcher.notify(StubEvents.HELLO, new DefaultEvent("hello you"));
    NLPExtension nlpExtension = loadedExtensions.get(StubExtension.class.getName());
    assertEquals("hello you", ((StubExtension) nlpExtension).getSomeValue());
}
Also used : DefaultEvent(com.graphaware.nlp.event.DefaultEvent) EventDispatcher(com.graphaware.nlp.event.EventDispatcher) StubExtension(com.graphaware.nlp.stub.StubExtension) Test(org.junit.Test)

Aggregations

DefaultEvent (com.graphaware.nlp.event.DefaultEvent)1 EventDispatcher (com.graphaware.nlp.event.EventDispatcher)1 StubExtension (com.graphaware.nlp.stub.StubExtension)1 Test (org.junit.Test)1