protocols/src/test/java/eu/internetofus/common/protocols/AbstractProtocolITC.java
/**
   * The process that is waiting until the
   *
   * @param vertx       event bus to use.
   * @param testContext context to do the test.
   * @param supplier    to obtain the model.
   * @param check       the function to check if the obtained model is what is
   *                    expected.
   *
   * @param <T>         type of the waiting data.
   *
   * @return the future model that satisfy the check.
   */
The process that is waiting until the
@param vertx       event bus to use.
@param testContext context to do the test.
@param supplier    to obtain the model.
@param check       the function to check if the obtained model is what is
expected.

@param          type of the waiting data.

@return the future model that satisfy the check.
The process that is waiting until the @param vertx event bus to use . @param testContext context to do the test . @param supplier to obtain the model . @param check the function to check if the obtained model is what is expected . @param type of the waiting data . @return the future model that satisfy the check .
protected <T> Future<T> waitUntil(final Vertx vertx, final VertxTestContext testContext,
      final Supplier<Future<T>> supplier, final Predicate<T> check) {
    final Promise<T> promise = Promise.promise();
    final var address = UUID.randomUUID().toString();
    final var consumer = vertx.eventBus().localConsumer(address);
    final var options = new DeliveryOptions();
    options.setLocalOnly(true);
    consumer.handler(ignored -> {
      supplier.get().onComplete(testContext.succeeding(target -> {
        if (check.test(target)) {
          consumer.unregister();
          promise.complete(target);
        } else if (testContext.completed()) {
          consumer.unregister();
          promise.fail("Test finished");
        } else {
          vertx.eventBus().send(address, "STEP", options);
        }
      }));
    });
    vertx.eventBus().send(address, "START", options);
    return promise.future();
  }
protected < T > Future < T > waitUntil ( final Vertx vertx , final VertxTestContext testContext , final Supplier < Future < T > > supplier , final Predicate < T > check ) { final Promise < T > promise = Promise . promise ( ) ; final var address = UUID . randomUUID ( ) . toString ( ) ; final var consumer = vertx . eventBus ( ) . localConsumer ( address ) ; final var options = new DeliveryOptions ( ) ; options . setLocalOnly ( true ) ; consumer . handler ( ignored -> { supplier . get ( ) . onComplete ( testContext . succeeding ( target -> { if ( check . test ( target ) ) { consumer . unregister ( ) ; promise . complete ( target ) ; } else if ( testContext . completed ( ) ) { consumer . unregister ( ) ; promise . fail ( "Test finished" ) ; } else { vertx . eventBus ( ) . send ( address , "STEP" , options ) ; } } ) ) ; } ) ; vertx . eventBus ( ) . send ( address , "START" , options ) ; return promise . future ( ) ; }
The process that is waiting until the
 @param vertx       event bus to use.
The process that is waiting until the @param vertx event bus to use .