Search in sources :

Example 71 with Response

use of io.restassured.response.Response in project rest-assured by rest-assured.

the class ResponseITest method pathThrowsExceptionWhenTryingToUseXmlPathAfterHavingUsedJsonPath.

@Test
public void pathThrowsExceptionWhenTryingToUseXmlPathAfterHavingUsedJsonPath() throws Exception {
    exception.expect(XmlPathException.class);
    exception.expectMessage("Failed to parse the XML document");
    Response response = get("/jsonStore");
    response.path("store.book.price.min()");
    response.xmlPath().get("store.book.price.min()");
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test)

Example 72 with Response

use of io.restassured.response.Response in project rest-assured by rest-assured.

the class ResponseITest method canParsePathAfterPrint.

@Test
public void canParsePathAfterPrint() throws Exception {
    Response response = get("/videos");
    response.print();
    String title = response.path("videos.music[0].title.toString().trim()");
    String artist = response.path("videos.music[0].artist.toString().trim()");
    assertThat(title, equalTo("Video Title 1"));
    assertThat(artist, equalTo("Artist 1"));
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test)

Example 73 with Response

use of io.restassured.response.Response in project rest-assured by rest-assured.

the class ResponseITest method canGetAsByteArrayMultipleTimes.

@Test
public void canGetAsByteArrayMultipleTimes() throws Exception {
    // When
    Response response = get("/videos");
    response.asByteArray();
    final byte[] bytes = response.asByteArray();
    // Then
    assertThat(bytes, not(nullValue()));
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test)

Example 74 with Response

use of io.restassured.response.Response in project rest-assured by rest-assured.

the class ResponseITest method responseSupportsGettingCookies.

@Test
public void responseSupportsGettingCookies() throws Exception {
    final Response response = get("/setCookies");
    assertEquals(3, response.getCookies().size());
    assertEquals(3, response.cookies().size());
    assertEquals("value1", response.getCookie("key1"));
    assertEquals("value2", response.cookie("key2"));
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test)

Example 75 with Response

use of io.restassured.response.Response in project rest-assured by rest-assured.

the class ResponseITest method canParsePathAfterPeek.

@Test
public void canParsePathAfterPeek() throws Exception {
    Response response = get("/videos").peek();
    String title = response.path("videos.music[0].title.toString().trim()");
    String artist = response.path("videos.music[0].artist.toString().trim()");
    assertThat(title, equalTo("Video Title 1"));
    assertThat(artist, equalTo("Artist 1"));
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test)

Aggregations

Response (io.restassured.response.Response)270 Test (org.junit.Test)209 Matchers.containsString (org.hamcrest.Matchers.containsString)43 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 Matchers.emptyString (org.hamcrest.Matchers.emptyString)24 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)12 IOException (java.io.IOException)11