use of com.jayway.restassured.path.json.JsonPath in project data-prep by Talend.
the class SuggestionTest method suggestLimitDefault.
@Test
public void suggestLimitDefault() throws Exception {
// given
final String columnMetadata = IOUtils.toString(Application.class.getResourceAsStream("suggestions/date_column.json"), UTF_8);
// when
final String response = //
given().contentType(//
JSON).body(//
columnMetadata).when().post(//
"/suggest/column").asString();
// then
final JsonPath json = JsonPath.from(response);
// Default for "limit" is 5.
assertThat(json.getList("").size(), is(5));
}
use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class AbsoluteSearchResourceTest method searchForNonexistingKeyword.
@Test
@UsingDataSet(locations = "searchForExistingKeyword.json")
public void searchForNonexistingKeyword() {
final ValidatableResponse result = doSearchFor("Nonexistent");
final JsonPath response = result.statusCode(200).extract().jsonPath();
assertThat(response.getInt("total_results")).isEqualTo(0);
assertThat(response.getList("messages")).isEmpty();
assertThat(response.getList("used_indices")).hasSize(1);
}
use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class AbsoluteSearchResourceTest method searchForExistingKeyword.
@Test
@UsingDataSet(locations = "searchForExistingKeyword.json")
public void searchForExistingKeyword() {
final ValidatableResponse result = doSearchFor("Testmessage");
final JsonPath response = result.statusCode(200).extract().jsonPath();
assertThat(response.getInt("total_results")).isEqualTo(1);
assertThat(response.getList("messages")).hasSize(1);
assertThat(response.getList("used_indices")).hasSize(1);
}
use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class AbsoluteSearchResourceTest method searchForExistingKeywordInsideOfVeryNarrowTimeRange.
@Test
@UsingDataSet(locations = "searchForExistingKeyword.json")
public void searchForExistingKeywordInsideOfVeryNarrowTimeRange() {
final ValidatableResponse result = doSearchFor("Testmessage", "2015-06-16T11:32:16.827Z", "2015-06-16T11:32:16.827Z");
final JsonPath response = result.statusCode(200).extract().jsonPath();
assertThat(response.getInt("total_results")).isEqualTo(1);
assertThat(response.getList("messages")).isNotEmpty();
assertThat(response.getList("used_indices")).hasSize(1);
}
use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class StreamsTest method createFullStreamIncludingStreamrules.
@Test
public void createFullStreamIncludingStreamrules() {
final int beforeCount = streamCount();
final String streamTitle = "A full Test Stream";
final String description = "This is a full test stream including stream rules.";
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);
final JsonPath getResponse = given().when().get("/streams/" + streamId).then().statusCode(200).contentType(ContentType.JSON).assertThat().body("title", equalTo(streamTitle)).body("disabled", equalTo(true)).body("matching_type", equalTo("AND")).body("description", equalTo(description)).extract().jsonPath();
assertThat(getResponse.getList("rules")).isNotNull();
assertThat(getResponse.getList("rules").size()).isEqualTo(2);
}
Aggregations