Search in sources :

Example 1 with ValidatableResponse

use of com.jayway.restassured.response.ValidatableResponse in project graylog2-server by Graylog2.

the class AbsoluteSearchResourceTest method searchForAllMessages.

@Test
@UsingDataSet(locations = "searchForExistingKeyword.json")
public void searchForAllMessages() {
    final ValidatableResponse result = doSearchFor("*");
    final JsonPath response = result.statusCode(200).extract().jsonPath();
    assertThat(response.getInt("total_results")).isEqualTo(2);
    assertThat(response.getList("messages")).hasSize(2);
    assertThat(response.getList("used_indices")).hasSize(1);
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) JsonPath(com.jayway.restassured.path.json.JsonPath) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 2 with ValidatableResponse

use of com.jayway.restassured.response.ValidatableResponse in project graylog2-server by Graylog2.

the class AbsoluteSearchResourceTest method searchForExistingKeywordOutsideOfTimeRange.

@Test
@UsingDataSet(locations = "searchForExistingKeyword.json")
public void searchForExistingKeywordOutsideOfTimeRange() {
    final ValidatableResponse result = doSearchFor("Testmessage", "2015-06-14T11:32:16.827Z", "2015-06-15T11:32:16.827Z");
    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);
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) JsonPath(com.jayway.restassured.path.json.JsonPath) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 3 with ValidatableResponse

use of com.jayway.restassured.response.ValidatableResponse in project graylog2-server by Graylog2.

the class AbsoluteSearchResourceTest method doSearchFor.

protected ValidatableResponse doSearchFor(String query, String from, String to) {
    final ValidatableResponse result = given().when().param("query", query).param("from", from).param("to", to).get("/search/universal/absolute").then().body(".", containsAllKeys("query", "built_query", "used_indices", "messages", "fields", "time", "total_results", "from", "to"));
    final JsonPath resultBody = result.extract().jsonPath();
    assertThat(resultBody.getString("query")).isEqualTo(query);
    return result;
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) JsonPath(com.jayway.restassured.path.json.JsonPath)

Example 4 with ValidatableResponse

use of com.jayway.restassured.response.ValidatableResponse in project graylog2-server by Graylog2.

the class StreamsTest method creatingStreamWithoutIndexSetIdShouldFail.

@Test
public void creatingStreamWithoutIndexSetIdShouldFail() throws Exception {
    final int beforeCount = streamCount();
    final ValidatableResponse response = createStreamFromRequest(jsonResourceForMethod());
    response.statusCode(400);
    assertThat(streamCount()).isEqualTo(beforeCount);
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Test(org.junit.Test) BaseRestTest(integration.BaseRestTest)

Example 5 with ValidatableResponse

use of com.jayway.restassured.response.ValidatableResponse in project graylog2-server by Graylog2.

the class StreamsTest method creatingInvalidStreamShouldFail.

@Test
public void creatingInvalidStreamShouldFail() throws Exception {
    final int beforeCount = streamCount();
    final ValidatableResponse response = createStreamFromRequest("{}");
    response.statusCode(400);
    final int afterCount = streamCount();
    assertThat(afterCount).isEqualTo(beforeCount);
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Test(org.junit.Test) BaseRestTest(integration.BaseRestTest)

Aggregations

ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)58 Test (org.junit.Test)51 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)27 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)24 Response (com.jayway.restassured.response.Response)17 CswQueryBuilder (org.codice.ddf.itests.common.csw.CswQueryBuilder)16 CswTestCommons.getMetacardIdFromCswInsertResponse (org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse)13 IOException (java.io.IOException)11 XPathExpressionException (javax.xml.xpath.XPathExpressionException)11 JsonPath (com.jayway.restassured.path.json.JsonPath)6 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)5 BaseRestTest (integration.BaseRestTest)4 Configuration (org.osgi.service.cm.Configuration)4 Hashtable (java.util.Hashtable)3 JSONObject (org.json.simple.JSONObject)3 HashMap (java.util.HashMap)2 XmlPath (com.jayway.restassured.path.xml.XmlPath)1 File (java.io.File)1 InputStream (java.io.InputStream)1