コード例 #1
0
  @Test
  public void noMatch() {
    final Event event = Event.create("other").localOrigin(true).build();
    this.listener.onEvent(event);

    assertNull(this.event);
  }
コード例 #2
0
  @Test
  public void notLocalOrigin() {
    final Event event = Event.create("application").localOrigin(false).build();
    this.listener.onEvent(event);

    assertNull(this.event);
  }
コード例 #3
0
  @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);
  }
コード例 #4
0
  @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);
  }