components/src/test/java/eu/internetofus/common/components/AbstractComponentMocker.java
/**
   * Start a new mocked server.
   *
   * @param port to bind the mocker server or {@code 0} to find any available
   *             port.
   *
   * @return a future completed with the start result.
   */
Start a new mocked server.
@param port to bind the mocker server or  0 to find any available
port.

@return a future completed with the start result.
Start a new mocked server . @param port to bind the mocker server or 0 to find any available port . @return a future completed with the start result .
public Future<Void> startServer(final int port) {
    if (this.isServerStarted()) {
      return Future.failedFuture("Server is already started");
    } else {
      try {
        final var vertx = Vertx.vertx();
        final var server = vertx.createHttpServer();
        final var router = Router.router(vertx);
        router.route().handler(BodyHandler.create());
        router.route().handler(this::checkWeNetComponentApikey);
        this.fillInRouterHandler(router);
        router.routeWithRegex(".*").handler(ctx -> {
          final var response = ctx.response();
          response.putHeader("content-type", "application/json");
          response.setStatusCode(Status.NOT_IMPLEMENTED.getStatusCode());
          response.end();
        });
        return server.requestHandler(router).listen(port).compose(startedServer -> {
          this.server = startedServer;
          return Future.succeededFuture();
        });
      } catch (final Throwable cause) {
        return Future.failedFuture(cause);
      }
    }
  }
public Future < Void > startServer ( final int port ) { if ( this . isServerStarted ( ) ) { return Future . failedFuture ( "Server is already started" ) ; } else { try { final var vertx = Vertx . vertx ( ) ; final var server = vertx . createHttpServer ( ) ; final var router = Router . router ( vertx ) ; router . route ( ) . handler ( BodyHandler . create ( ) ) ; router . route ( ) . handler ( this :: checkWeNetComponentApikey ) ; this . fillInRouterHandler ( router ) ; router . routeWithRegex ( ".*" ) . handler ( ctx -> { final var response = ctx . response ( ) ; response . putHeader ( "content-type" , "application/json" ) ; response . setStatusCode ( Status . NOT_IMPLEMENTED . getStatusCode ( ) ) ; response . end ( ) ; } ) ; return server . requestHandler ( router ) . listen ( port ) . compose ( startedServer -> { this . server = startedServer ; return Future . succeededFuture ( ) ; } ) ; } catch ( final Throwable cause ) { return Future . failedFuture ( cause ) ; } } }
Start a new mocked server.
Start a new mocked server .