use of io.restassured.response.Response in project tutorials by eugenp.
the class LiveTest method whenGetAllBooks_thenSuccess.
@Test
public void whenGetAllBooks_thenSuccess() {
final Response response = RestAssured.get(ROOT_URI + "/book-service/books");
Assert.assertEquals(HttpStatus.OK.value(), response.getStatusCode());
Assert.assertNotNull(response.getBody());
}
use of io.restassured.response.Response in project tutorials by eugenp.
the class LiveTest method whenAccessAdminProtectedResource_thenForbidden.
@Test
public void whenAccessAdminProtectedResource_thenForbidden() {
final Response response = RestAssured.given().auth().form("user", "password", formConfig).get(ROOT_URI + "/rating-service/ratings");
Assert.assertEquals(HttpStatus.FORBIDDEN.value(), response.getStatusCode());
}
use of io.restassured.response.Response in project tutorials by eugenp.
the class RestApiLiveTest method whenDeleteCreatedBook_thenOk.
@Test
public void whenDeleteCreatedBook_thenOk() {
// create
final Book book = createRandomBook();
final String location = createBookAsUri(book);
// delete
Response response = RestAssured.delete(location);
assertEquals(HttpStatus.NO_CONTENT.value(), response.getStatusCode());
// confirm it was deleted
response = RestAssured.get(location);
assertEquals(HttpStatus.NOT_FOUND.value(), response.getStatusCode());
}
use of io.restassured.response.Response in project tutorials by eugenp.
the class RestApiLiveTest method whenGetCreatedBookByName_thenOK.
@Test
public void whenGetCreatedBookByName_thenOK() {
final Book book = createRandomBook();
createBookAsUri(book);
final Response response = RestAssured.get(API_URI + "/search/findByTitle?title=" + book.getTitle());
assertEquals(HttpStatus.OK.value(), response.getStatusCode());
assertTrue(response.jsonPath().getLong("page.totalElements") > 0);
}
use of io.restassured.response.Response in project tutorials by eugenp.
the class RestApiLiveTest method whenCreateDuplicateBook_thenError.
@Test
public void whenCreateDuplicateBook_thenError() {
final Book book = createRandomBook();
createBookAsUri(book);
// duplicate
final Response response = RestAssured.given().contentType(MediaType.APPLICATION_JSON_VALUE).body(book).post(API_URI);
assertEquals(HttpStatus.CONFLICT.value(), response.getStatusCode());
}
Aggregations