@Test
  public void pubsub() throws Exception {

    PersonRepository repository = new PersonRepository(new GeodeBackend(GeodeSetup.of(x -> region)));

    TestSubscriber<WatchEvent<Person>> events = Flowable.fromPublisher(repository.watcher(PersonCriteria.person).watch())
            .test();

    final PersonGenerator generator = new PersonGenerator();
    final int count = 4;
    for (int i = 0; i < count; i++) {
      repository.insert(generator.next().withId("id" + i));
    }

    check(region.keySet()).notEmpty();
    // ensure (de)serialization is successful
    check(region.query("true")).hasSize(count);

    events.awaitCount(count);
    events.assertNoErrors();
    events.assertValueCount(count);
    check(events.values().stream().map(e -> e.newValue().get().id()).collect(Collectors.toList())).hasContentInAnyOrder("id0", "id1", "id2", "id3");
  }
Unfortunately CQ can't be tested with an embedded server. For Geode, there can be only
one instance of Cache in JVM: server or client. CQ is client / server topology.

<p>This test requires an external Geode instance

<p>Temporary test until we have a proper way to start real geode server

<pre>
  copy artifact jars from common/target/*.jar into $GEMFIRE_HOME/extensions/
  manually start gfsh
  $ start locator --name=locator1 --port=10334
  $ start server --name=server1 --server-port=40411
  $ create region --name=persons --type=REPLICATE
</pre>
criteria/geode/test/org/immutables/criteria/geode/GeodeCqTest.java