### Question:
MetricsHttpService implements MetricsService { @Override public CompletableFuture<?> start() { LOG.info("Starting metrics http service on {}:{}", config.getHost(), config.getPort()); httpServer = vertx.createHttpServer( new HttpServerOptions().setHost(config.getHost()).setPort(config.getPort())); final Router router = Router.router(vertx); router.route().handler(checkAllowlistHostHeader()); router.route("/").method(HttpMethod.GET).handler(this::handleEmptyRequest); router.route("/metrics").method(HttpMethod.GET).handler(this::metricsRequest); final CompletableFuture<?> resultFuture = new CompletableFuture<>(); httpServer .requestHandler(router) .listen( res -> { if (!res.failed()) { resultFuture.complete(null); final int actualPort = httpServer.actualPort(); config.setActualPort(actualPort); LOG.info( "Metrics service started and listening on {}:{}", actualPort, httpServer.actualPort()); return; } httpServer = null; final Throwable cause = res.cause(); if (cause instanceof SocketException) { resultFuture.completeExceptionally( new RuntimeException( String.format( "Failed to bind metrics listener to %s:%s (actual port %s): %s", config.getHost(), config.getPort(), config.getActualPort(), cause.getMessage()))); return; } resultFuture.completeExceptionally(cause); }); return resultFuture; } MetricsHttpService(
      final Vertx vertx,
      final MetricsConfiguration configuration,
      final MetricsSystem metricsSystem); @Override CompletableFuture<?> start(); @Override CompletableFuture<?> stop(); @Override Optional<Integer> getPort();  }### Answer:
@Test public void invalidCallToStart() { service .start() .whenComplete( (unused, exception) -> assertThat(exception).isInstanceOf(IllegalStateException.class)); }