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());
}
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"));
}
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"));
}
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());
}
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());
}
Aggregations