use of guru.nidi.ramltester.RamlDefinition in project okapi by folio-org.
the class RamlTest method testOkapiRaml.
@Test
public void testOkapiRaml() {
RamlDefinition api = RamlLoaders.fromFile("src/main/raml").load("okapi.raml");
// Don't check Validation.DESCRIPTION
RamlValidator v = api.validator().withChecks(Validation.URI_PARAMETER, Validation.PARAMETER, Validation.EMPTY);
Assert.assertThat(v.validate(), validates());
}
use of guru.nidi.ramltester.RamlDefinition in project okapi by folio-org.
the class DockerTest method dockerTest1.
@Test
public void dockerTest1(TestContext context) {
Async async = context.async();
logger.info("dockerTest1");
RestAssuredClient c;
Response r;
RamlDefinition api = RamlLoaders.fromFile("src/main/raml").load("okapi.raml").assumingBaseUri("https://okapi.cloud");
final String docSampleDockerModule = "{" + LS + " \"id\" : \"sample-module-1\"," + LS + " \"name\" : \"sample module\"," + LS + " \"provides\" : [ {" + LS + " \"id\" : \"sample\"," + LS + " \"version\" : \"1.0.0\"," + LS + " \"handlers\" : [ {" + LS + " \"methods\" : [ \"GET\", \"POST\" ]," + LS + " \"pathPattern\" : \"/testb\"" + LS + " } ]" + LS + " } ]," + LS + " \"launchDescriptor\" : {" + LS + " \"dockerImage\" : \"okapi-test-module\"," + LS + " \"dockerPull\" : false," + LS + " \"dockerCMD\" : [\"-Dfoo=bar\"]," + LS + " \"dockerArgs\" : {" + LS + " \"StopTimeout\" : 12," + LS + " \"HostConfig\": { \"PortBindings\": { \"8080/tcp\": [{ \"HostPort\": \"%p\" }] } }" + LS + " }" + LS + " }" + LS + "}";
c = api.createRestAssured3();
r = c.given().header("Content-Type", "application/json").body(docSampleDockerModule).post("/_/proxy/modules").then().statusCode(201).log().ifValidationFails().extract().response();
context.assertTrue(c.getLastReport().isEmpty(), "raml: " + c.getLastReport().toString());
locations.add(r.getHeader("Location"));
final String doc1 = "{" + LS + " \"srvcId\" : \"sample-module-1\"," + LS + " \"nodeId\" : \"localhost\"" + LS + "}";
c = api.createRestAssured3();
if (haveDocker) {
r = c.given().header("Content-Type", "application/json").body(doc1).post("/_/discovery/modules").then().statusCode(201).extract().response();
locations.add(r.getHeader("Location"));
} else {
c.given().header("Content-Type", "application/json").body(doc1).post("/_/discovery/modules").then().statusCode(400);
}
context.assertTrue(c.getLastReport().isEmpty(), "raml: " + c.getLastReport().toString());
if (!haveDocker) {
async.complete();
return;
}
final String docUserDockerModule = "{" + LS + " \"id\" : \"mod-users-1\"," + LS + " \"name\" : \"users\"," + LS + " \"provides\" : [ {" + LS + " \"id\" : \"users\"," + LS + " \"version\" : \"1.0.0\"," + LS + " \"handlers\" : [ {" + LS + " \"methods\" : [ \"GET\", \"POST\" ]," + LS + " \"pathPattern\" : \"/test\"" + LS + " } ]" + LS + " } ]," + LS + " \"launchDescriptor\" : {" + LS + " \"dockerImage\" : \"folioci/mod-users:5.0.0-SNAPSHOT\"" + LS + " }" + LS + "}";
c = api.createRestAssured3();
r = c.given().header("Content-Type", "application/json").body(docUserDockerModule).post("/_/proxy/modules").then().statusCode(201).extract().response();
context.assertTrue(c.getLastReport().isEmpty(), "raml: " + c.getLastReport().toString());
locations.add(r.getHeader("Location"));
final String doc2 = "{" + LS + " \"srvcId\" : \"mod-users-1\"," + LS + " \"nodeId\" : \"localhost\"" + LS + "}";
c = api.createRestAssured3();
r = c.given().header("Content-Type", "application/json").body(doc2).post("/_/discovery/modules").then().statusCode(201).extract().response();
context.assertTrue(c.getLastReport().isEmpty(), "raml: " + c.getLastReport().toString());
locations.add(r.getHeader("Location"));
async.complete();
}
use of guru.nidi.ramltester.RamlDefinition in project openlmis-stockmanagement by OpenLMIS.
the class BaseWebIntegrationTest method init.
/**
* Method called to initialize basic resources after the object is created.
*/
@PostConstruct
public void init() {
mockExternalAuthorization();
RestAssured.baseURI = BASE_URL;
RestAssured.port = serverPort;
RestAssured.config = RestAssuredConfig.config().objectMapperConfig(new ObjectMapperConfig().jackson2ObjectMapperFactory((clazz, charset) -> objectMapper));
RamlDefinition ramlDefinition = RamlLoaders.fromClasspath().load("api-definition-raml.yaml").ignoringXheaders();
restAssured = ramlDefinition.createRestAssured();
}
Aggregations