Search in sources :

Example 31 with Response

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

the class SpringBootBootstrapIntegrationTest method whenGetNotExistBookById_thenNotFound.

@Test
public void whenGetNotExistBookById_thenNotFound() {
    final Response response = RestAssured.get(API_ROOT + "/" + randomNumeric(4));
    assertEquals(HttpStatus.NOT_FOUND.value(), response.getStatusCode());
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 32 with Response

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

the class SpringBootBootstrapIntegrationTest method whenGetCreatedBookById_thenOK.

@Test
public void whenGetCreatedBookById_thenOK() {
    final Book book = createRandomBook();
    final String location = createBookAsUri(book);
    final Response response = RestAssured.get(location);
    assertEquals(HttpStatus.OK.value(), response.getStatusCode());
    assertEquals(book.getTitle(), response.jsonPath().get("title"));
}
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 33 with Response

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

the class SpringBootBootstrapIntegrationTest method whenUpdateCreatedBook_thenUpdated.

@Test
public void whenUpdateCreatedBook_thenUpdated() {
    final Book book = createRandomBook();
    final String location = createBookAsUri(book);
    book.setId(Long.parseLong(location.split("api/books/")[1]));
    book.setAuthor("newAuthor");
    Response response = RestAssured.given().contentType(MediaType.APPLICATION_JSON_VALUE).body(book).put(location);
    assertEquals(HttpStatus.OK.value(), response.getStatusCode());
    response = RestAssured.get(location);
    assertEquals(HttpStatus.OK.value(), response.getStatusCode());
    assertEquals("newAuthor", response.jsonPath().get("author"));
}
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 34 with Response

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

the class LiveTest method whenAdminAccessProtectedResource_thenSuccess.

@Test
public void whenAdminAccessProtectedResource_thenSuccess() {
    final Response response = RestAssured.given().auth().form("admin", "admin", formConfig).get(ROOT_URI + "/rating-service/ratings");
    Assert.assertEquals(HttpStatus.OK.value(), response.getStatusCode());
    Assert.assertNotNull(response.getBody());
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test)

Example 35 with Response

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

the class LiveTest method whenAccessProtectedResourceAfterLogin_thenSuccess.

@Test
public void whenAccessProtectedResourceAfterLogin_thenSuccess() {
    final Response response = RestAssured.given().auth().form("user", "password", formConfig).get(ROOT_URI + "/book-service/books/1");
    Assert.assertEquals(HttpStatus.OK.value(), response.getStatusCode());
    Assert.assertNotNull(response.getBody());
}
Also used : Response(io.restassured.response.Response) Test(org.junit.Test)

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