use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class StreamsTest method createStreamByTitleOnly.
@Test
public void createStreamByTitleOnly() throws Exception {
final int beforeCount = streamCount();
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("TestStream")).body("disabled", equalTo(true)).body("matching_type", equalTo("AND")).body("description", equalTo(null));
}
use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class StreamsTest method createStreamWithTitleAndDescription.
@Test
public void createStreamWithTitleAndDescription() throws Exception {
final int beforeCount = streamCount();
final String streamTitle = "Another Test Stream";
final String description = "This is a test stream.";
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("AND")).body("description", equalTo(description));
}
use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class StreamsTest method updatingNonexistendStreamShouldFail.
@Test
@MongoDbSeed(locations = { "single-stream", "second-single-stream" })
public void updatingNonexistendStreamShouldFail() {
// id of nonexistent stream to be updated
final String streamId = "55affeaffeaffeaffeaffeaf";
// id of stream that is supposed to be left untampered
final String otherStreamId = "552b92b2e4b0c055e41ffb8e";
given().when().body("{\"title\":\"foo\", \"description\":\"bar\", \"index_set_id\":\"582f3c4e43761335e4859f72\"}").put("/streams/" + streamId).then().statusCode(404);
final JsonPath otherStreamResponse = given().when().get("/streams/" + otherStreamId).then().statusCode(200).extract().jsonPath();
assertThat(otherStreamResponse.getString("title")).isEqualTo("Just a stream");
assertThat(otherStreamResponse.getString("description")).isEqualTo("This is just a stream");
}
use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class StreamsTest method updatingTitleOfSingleStream.
@Test
@MongoDbSeed(locations = { "single-stream", "second-single-stream" })
public void updatingTitleOfSingleStream() {
// id of stream to be updated
final String streamId = "552b92b2e4b0c055e41ffb8d";
// id of stream that is supposed to be left untampered
final String otherStreamId = "552b92b2e4b0c055e41ffb8e";
assertThat(streamCount()).isEqualTo(2);
final JsonPath response = given().when().body(jsonResourceForMethod()).put("/streams/" + streamId).then().statusCode(200).contentType(ContentType.JSON).extract().jsonPath();
assertThat(response.getString("title")).isEqualTo("Updated Title");
assertThat(response.getString("description")).isEqualTo("This is yet another stream");
final JsonPath getResponse = given().when().get("/streams/" + streamId).then().statusCode(200).extract().jsonPath();
assertThat(getResponse.getString("title")).isEqualTo("Updated Title");
assertThat(getResponse.getString("description")).isEqualTo("This is yet another stream");
final JsonPath otherStreamResponse = given().when().get("/streams/" + otherStreamId).then().statusCode(200).extract().jsonPath();
assertThat(otherStreamResponse.getString("title")).isEqualTo("Just a stream");
assertThat(otherStreamResponse.getString("description")).isEqualTo("This is just a stream");
}
use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class StreamsTest method updatingUsingInvalidMatchingTypeOfStreamShouldFail.
@Test
@MongoDbSeed(locations = { "single-stream", "second-single-stream" })
public void updatingUsingInvalidMatchingTypeOfStreamShouldFail() {
final String streamId = "552b92b2e4b0c055e41ffb8d";
given().when().body("{\"matching_type\":\"INVALID\"}").put("/streams/" + streamId).then().statusCode(400);
final JsonPath getResponse = getStream(streamId).statusCode(200).extract().jsonPath();
assertThat(getResponse.getString("matching_type")).isEqualTo("AND");
}
Aggregations