@Test public void noMatch() { final Event event = Event.create("other").localOrigin(true).build(); this.listener.onEvent(event); assertNull(this.event); }
@Test public void notLocalOrigin() { final Event event = Event.create("application").localOrigin(false).build(); this.listener.onEvent(event); assertNull(this.event); }
@Test public void testEvent() { final Event event = Event.create("application").localOrigin(true).value("a", 1).build(); this.listener.onEvent(event); assertNotNull(this.event); assertTrue(this.event instanceof MapSerializable); final MapSerializable serializable = (MapSerializable) this.event; final JsonMapGenerator generator = new JsonMapGenerator(); serializable.serialize(generator); }
@Test public void testException() { final Consumer<Object> consumer = o -> { throw new RuntimeException(); }; this.listener = new ScriptEventListenerBuilder() .typePattern("app*") .listener(consumer) .application(ApplicationKey.from("foo.bar")) .build(); final Event event = Event.create("application").localOrigin(true).build(); this.listener.onEvent(event); }