Search in sources :

Example 26 with Response

use of io.restassured.response.Response in project tutorials by eugenp.

the class LiveTest method whenSendRequest_thenHeaderAdded.

@Test
public void whenSendRequest_thenHeaderAdded() {
    final Response response = RestAssured.get("http://localhost:8080/foos/1");
    assertEquals(200, response.getStatusCode());
    assertEquals("TestSample", response.getHeader("Test"));
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test)

Example 27 with Response

use of io.restassured.response.Response in project tutorials by eugenp.

the class SpringBootBootstrapIntegrationTest method whenGetBooksByTitle_thenOK.

@Test
public void whenGetBooksByTitle_thenOK() {
    final Book book = createRandomBook();
    createBookAsUri(book);
    final Response response = RestAssured.get(API_ROOT + "/title/" + book.getTitle());
    assertEquals(HttpStatus.OK.value(), response.getStatusCode());
    assertTrue(response.as(List.class).size() > 0);
}
Also used : Response(io.restassured.response.Response) Book(org.baeldung.persistence.model.Book) List(java.util.List) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 28 with Response

use of io.restassured.response.Response in project tutorials by eugenp.

the class SpringBootBootstrapIntegrationTest method whenDeleteCreatedBook_thenOk.

@Test
public void whenDeleteCreatedBook_thenOk() {
    final Book book = createRandomBook();
    final String location = createBookAsUri(book);
    Response response = RestAssured.delete(location);
    assertEquals(HttpStatus.OK.value(), response.getStatusCode());
    response = RestAssured.get(location);
    assertEquals(HttpStatus.NOT_FOUND.value(), response.getStatusCode());
}
Also used : Response(io.restassured.response.Response) Book(org.baeldung.persistence.model.Book) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 29 with Response

use of io.restassured.response.Response in project tutorials by eugenp.

the class SpringBootBootstrapIntegrationTest method whenGetAllBooks_thenOK.

@Test
public void whenGetAllBooks_thenOK() {
    final Response response = RestAssured.get(API_ROOT);
    assertEquals(HttpStatus.OK.value(), response.getStatusCode());
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 30 with Response

use of io.restassured.response.Response in project tutorials by eugenp.

the class SpringBootBootstrapIntegrationTest method whenInvalidBook_thenError.

@Test
public void whenInvalidBook_thenError() {
    final Book book = createRandomBook();
    book.setAuthor(null);
    final Response response = RestAssured.given().contentType(MediaType.APPLICATION_JSON_VALUE).body(book).post(API_ROOT);
    assertEquals(HttpStatus.BAD_REQUEST.value(), response.getStatusCode());
}
Also used : Response(io.restassured.response.Response) Book(org.baeldung.persistence.model.Book) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Response (io.restassured.response.Response)262 Test (org.junit.Test)209 Matchers.containsString (org.hamcrest.Matchers.containsString)44 ValidatableResponse (io.restassured.response.ValidatableResponse)32 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)31 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)29 RestAssuredClient (guru.nidi.ramltester.restassured3.RestAssuredClient)25 HttpResponse (org.apache.http.HttpResponse)25 IsEmptyString.isEmptyString (org.hamcrest.text.IsEmptyString.isEmptyString)25 FilterContext (io.restassured.filter.FilterContext)17 FilterableRequestSpecification (io.restassured.specification.FilterableRequestSpecification)17 FilterableResponseSpecification (io.restassured.specification.FilterableResponseSpecification)17 CswTestCommons.getMetacardIdFromCswInsertResponse (org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse)17 Filter (io.restassured.filter.Filter)16 VerifyTest (org.apache.knox.test.category.VerifyTest)15 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)14 Book (org.baeldung.persistence.model.Book)13 JSONObject (org.json.simple.JSONObject)13 ResponseBuilder (io.restassured.builder.ResponseBuilder)11 IOException (java.io.IOException)11