Search in sources :

Example 1 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.

the class AlarmCallbackHistoryResourceTest method listHistoriesWhenNoHistoriesArePresent.

@Test
public void listHistoriesWhenNoHistoriesArePresent() throws Exception {
    final JsonPath response = given().when().get(url).then().statusCode(200).assertThat().body(".", containsAllKeys("total", "histories")).extract().jsonPath();
    assertThat(response.getInt("total")).isEqualTo(0);
    assertThat(response.getList("histories")).isEmpty();
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test) BaseRestTest(integration.BaseRestTest)

Example 2 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.

the class AlarmCallbackHistoryResourceTest method getHistoryForAlert.

@Test
public void getHistoryForAlert() throws Exception {
    final JsonPath response = given().when().get(url).then().statusCode(200).assertThat().body(".", containsAllKeys("total", "histories")).extract().jsonPath();
    assertThat(response.getInt("total")).isEqualTo(2);
    assertThat(response.getList("histories")).isNotEmpty();
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test) BaseRestTest(integration.BaseRestTest)

Example 3 with JsonPath

use of com.jayway.restassured.path.json.JsonPath 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 4 with JsonPath

use of com.jayway.restassured.path.json.JsonPath 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 5 with JsonPath

use of com.jayway.restassured.path.json.JsonPath 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)

Aggregations

JsonPath (com.jayway.restassured.path.json.JsonPath)85 Test (org.junit.Test)56 Response (com.jayway.restassured.response.Response)27 BaseRestTest (integration.BaseRestTest)11 BaseRestIntegrationTest (se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)10 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)9 Matchers.anyString (org.mockito.Matchers.anyString)8 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 Ignore (org.junit.Ignore)5 MongoDbSeed (integration.MongoDbSeed)4 HashMap (java.util.HashMap)3 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)2 BaseMatcher (org.hamcrest.BaseMatcher)2 Description (org.hamcrest.Description)2 UserPreparation (org.talend.dataprep.preparation.service.UserPreparation)2 Application (org.talend.dataprep.transformation.Application)2