Search in sources :

Example 51 with JsonPath

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));
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Application(org.talend.dataprep.transformation.Application) Test(org.junit.Test)

Example 52 with JsonPath

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);
}
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 53 with JsonPath

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);
}
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 54 with JsonPath

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);
}
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 55 with JsonPath

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);
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test) BaseRestTest(integration.BaseRestTest)

Aggregations

JsonPath (com.jayway.restassured.path.json.JsonPath)87 Test (org.junit.Test)56 Response (com.jayway.restassured.response.Response)29 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 Then (cucumber.api.java.en.Then)2 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)2 BaseMatcher (org.hamcrest.BaseMatcher)2 Description (org.hamcrest.Description)2 PreparationDTO (org.talend.dataprep.api.preparation.PreparationDTO)2