Exemplo n.º 1
0
  @Test
  public void simpleOn2Test() throws InterruptedException {
    AVar<Tuple2> val = new AVar<>();
    firehose.on(
        Key.wrap("key1"),
        (key, value) -> {
          val.set(Tuple.of(key, value));
        });
    firehose.notify(Key.wrap("key1"), 1);

    assertThat(val.get(10, TimeUnit.MILLISECONDS), is(Tuple.of(Key.wrap("key1"), 1)));
  }
Exemplo n.º 2
0
  @Test
  public void keyMissTest() throws InterruptedException {
    AVar<Tuple2> val = new AVar<>();

    firehose.miss(
        (k_) -> true,
        (k) -> {
          return Collections.singletonMap(
              k,
              (key, value) -> {
                val.set(Tuple.of(key, value));
              });
        });

    firehose.notify(Key.wrap("key1"), 1);
    assertThat(val.get(10, TimeUnit.MILLISECONDS), is(Tuple.of(Key.wrap("key1"), 1)));
  }