public static io.vertx.ext.consul.ConsulService fireEventWithOptions(io.vertx.ext.consul.ConsulService j_receiver, java.lang.String name, java.util.Map<String, Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.fireEventWithOptions(name, options != null ? new io.vertx.ext.consul.EventOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.consul.Event>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.ext.consul.Event> ar) { resultHandler.handle(ar.map(event -> event != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(event.toJson()) : null)); } } : null)); return j_receiver; } public static io.vertx.ext.consul.ConsulService listEvents(io.vertx.ext.consul.ConsulService j_receiver, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
public static io.vertx.ext.consul.ConsulClient fireEventWithOptions(io.vertx.ext.consul.ConsulClient j_receiver, java.lang.String name, java.util.Map<String, Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.fireEventWithOptions(name, options != null ? new io.vertx.ext.consul.EventOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.consul.Event>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.ext.consul.Event> ar) { resultHandler.handle(ar.map(event -> event != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(event.toJson()) : null)); } } : null)); return j_receiver; } public static io.vertx.ext.consul.ConsulClient listEvents(io.vertx.ext.consul.ConsulClient j_receiver, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
@Test public void watchEvents() throws InterruptedException { StateConsumer<String> consumer = new StateConsumer<>(); String evName = randomAlphaString(10); String p1 = randomAlphaString(10); String p2 = randomAlphaString(10); Watch<EventList> watch = Watch.events(evName, vertx, ctx.readClientOptions()) .setHandler(list -> { if (list.succeeded()) { consumer.consume(list.nextResult().getList() .stream().map(Event::getPayload).collect(Collectors.joining(","))); } }) .start(); consumer.await(""); Utils.<Event>getAsync(h -> ctx.writeClient().fireEventWithOptions(evName, new EventOptions().setPayload(p1), h)); Utils.<Event>getAsync(h -> ctx.writeClient().fireEventWithOptions(randomAlphaString(10), new EventOptions().setPayload(randomAlphaString(10)), h)); Utils.<Event>getAsync(h -> ctx.writeClient().fireEventWithOptions(evName, new EventOptions().setPayload(p2), h)); consumer.await(p1); consumer.await(p1 + "," + p2); consumer.check(); watch.stop(); }
private void runTest(TestContext tc, boolean timeout) { String name1 = randomAlphaString(10); String name2 = randomAlphaString(10); EventOptions opts = new EventOptions().setPayload(randomAlphaString(10)); ctx.writeClient().fireEventWithOptions(name1, opts, tc.asyncAssertSuccess(event -> { tc.assertEquals(name1, event.getName());