/*
 * Copyright (c) 2015-2016, Index Data
 * All rights reserved.
 * See the file LICENSE for details.
 */
package okapi;

import com.jayway.restassured.RestAssured;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Vertx;
import static com.jayway.restassured.RestAssured.*;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import org.junit.runner.RunWith;

@RunWith(VertxUnitRunner.class)
public class HealthCheckTest {

  Vertx vertx;

  private final int port = Integer.parseInt(System.getProperty("port", "9130"));

  @Before
  public void setUp(TestContext context) {
    vertx = Vertx.vertx();

    DeploymentOptions opt = new DeploymentOptions()
            .setConfig(new JsonObject().put("storage", "inmemory"));
    vertx.deployVerticle(MainVerticle.class.getName(), opt, context.asyncAssertSuccess());
  }

  @After
  public void tearDown(TestContext context) {
    Async async = context.async();
    vertx.close(x -> {
      async.complete();
    });
  }

  @Test
  public void testHealthCheck() {
    RestAssured.port = port;

    given().get("/_/proxy/health").then().assertThat().statusCode(200);
    given().get("/_/proxy/health2").then().assertThat().statusCode(404);
  }

}

@@ -351,16 +351,160 @@
 ured.*;%0A
+import guru.nidi.ramltester.RamlDefinition;%0Aimport guru.nidi.ramltester.RamlLoaders;%0Aimport guru.nidi.ramltester.restassured.RestAssuredClient;%0A
 import i
@@ -647,24 +647,49 @@
 UnitRunner;%0A
+import org.junit.Assert;%0A
 import org.j
@@ -1400,75 +1400,373 @@
     
-given().get(%22/_/proxy/health%22).then().assertThat().statusCode(200);
+RamlDefinition api = RamlLoaders.fromFile(%22src/main/raml%22).load(%22okapi.raml%22)%0A            .assumingBaseUri(%22https://okapi.cloud%22);%0A%0A    RestAssuredClient c;%0A%0A    c = api.createRestAssured();%0A    c.given().get(%22/_/proxy/health%22).then().assertThat().statusCode(200);%0A    Assert.assertTrue(%22raml report: %22 + c.getLastReport().toString(), c.getLastReport().isEmpty());%0A
 %0A   

Validate against RAML in health check test