use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class StreamsTest method createOrMatchingStreamWithTitleAndDescription.
@Test
public void createOrMatchingStreamWithTitleAndDescription() throws Exception {
final int beforeCount = streamCount();
final String streamTitle = "Another Test Stream";
final String description = "This is a test stream.";
final String matchingType = "OR";
final JsonPath response = createStreamFromRequest(jsonResourceForMethod()).statusCode(201).body(".", containsAllKeys("stream_id")).extract().jsonPath();
final String streamId = response.getString("stream_id");
assertThat(streamId).isNotNull().isNotEmpty();
final int afterCount = streamCount();
assertThat(afterCount).isEqualTo(beforeCount + 1);
getStream(streamId).statusCode(200).assertThat().body("title", equalTo(streamTitle)).body("disabled", equalTo(true)).body("matching_type", equalTo(matchingType)).body("description", equalTo(description));
}
use of com.jayway.restassured.path.json.JsonPath in project docker-maven-plugin by fabric8io.
the class VersionIT method testVersion.
@Test
public void testVersion() {
String versionExpected = System.getProperty("jolokia.version");
String jolokiaUrl = System.getProperty("jolokia.url");
RestAssured.baseURI = jolokiaUrl;
RestAssured.defaultParser = Parser.JSON;
System.out.println("Checking URL: " + jolokiaUrl);
// Need to do it that way since Jolokia doesnt return application/json as mimetype by default
JsonPath json = with(get("/version").asString());
json.prettyPrint();
assertEquals(versionExpected, json.get("value.agent"));
// Alternatively, set the mime type before, then Rest-assured's fluent API can be used
given().param("mimeType", "application/json").get("/version").then().assertThat().header("content-type", containsString("application/json")).body("value.agent", equalTo(versionExpected)).body("timestamp", lessThanOrEqualTo((int) (System.currentTimeMillis() / 1000))).body("status", equalTo(200)).body("value.protocol", equalTo("7.2")).body("value.config", notNullValue());
}
use of com.jayway.restassured.path.json.JsonPath in project data-prep by Talend.
the class PreparationAPITest method testPreparationsList_withFilterOnFolderPath.
@Test
public void testPreparationsList_withFilterOnFolderPath() throws Exception {
// given
String tagadaId = testClient.createDataset("dataset/dataset.csv", "tagada");
String preparationName = "tagadaPreparation";
String preparationId = testClient.createPreparationFromDataset(tagadaId, preparationName, home.getId());
// when : short format
final Response shouldNotBeEmpty = when().get("/api/preparations/?format=short&folder_path={folder_path}", "/");
// then
List<String> result = mapper.readerFor(String.class).<String>readValues(shouldNotBeEmpty.asInputStream()).readAll();
assertThat(result.get(0), is(preparationId));
// when
final JsonPath shouldBeEmpty = when().get("/api/preparations/?format=short&folder_path={folder_path}", "/toto").jsonPath();
// then
assertThat(shouldBeEmpty.<String>getList(""), is(empty()));
}
use of com.jayway.restassured.path.json.JsonPath in project data-prep by Talend.
the class PreparationAPITest method testPreparationsList.
@Test
public void testPreparationsList() throws Exception {
// given
String tagadaId = testClient.createDataset("dataset/dataset.csv", "tagada");
String preparationId = testClient.createPreparationFromDataset(tagadaId, "testPreparation", home.getId());
// when : short format
final JsonPath shortFormat = when().get("/api/preparations/?format=short").jsonPath();
// then
final List<String> values = shortFormat.getList("");
assertThat(values.get(0), is(preparationId));
// when : long format
Response response1 = when().get("/api/preparations/?format=long");
// then
List<UserPreparation> preparations = mapper.readerFor(UserPreparation.class).<UserPreparation>readValues(response1.asInputStream()).readAll();
assertEquals(1, preparations.size());
UserPreparation userPreparation = preparations.iterator().next();
assertThat(userPreparation.getDataSetId(), is(tagadaId));
assertThat(userPreparation.getAuthor(), is(security.getUserId()));
assertThat(userPreparation.getId(), is(preparationId));
assertThat(userPreparation.getActions(), is(empty()));
// when : summary format
Response response = when().get("/api/preparations/?format=summary");
// then
List<PreparationSummary> preparationSummaries = mapper.readerFor(PreparationSummary.class).<PreparationSummary>readValues(response.asInputStream()).readAll();
assertEquals(1, preparationSummaries.size());
PreparationSummary preparationSummary = preparationSummaries.iterator().next();
assertThat(preparationSummary.getId(), is(preparationId));
assertThat(preparationSummary.getName(), is("testPreparation"));
assertThat(preparationSummary.getLastModificationDate(), is(notNullValue()));
assertThat(preparationSummary.isAllowDistributedRun(), is(notNullValue()));
}
use of com.jayway.restassured.path.json.JsonPath in project data-prep by Talend.
the class PreparationAPITest method testPreparationsList_withFilterOnName.
@Test
public void testPreparationsList_withFilterOnName() throws Exception {
// given
String tagadaId = testClient.createDataset("dataset/dataset.csv", "tagada");
String preparationId = testClient.createPreparationFromDataset(tagadaId, "testPreparation", home.getId());
// when : short format
final JsonPath shortFormat = when().get("/api/preparations/?format=short&name={name}", "testPreparation").jsonPath();
// then
final List<String> values = shortFormat.getList("");
assertThat(values.get(0), is(preparationId));
}
Aggregations