use of org.baeldung.persistence.model.Book in project tutorials by eugenp.
the class RestApiLiveTest 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_URI);
assertEquals(HttpStatus.CONFLICT.value(), response.getStatusCode());
}
use of org.baeldung.persistence.model.Book in project tutorials by eugenp.
the class SpringBootBootstrapIntegrationTest method whenCreateNewBook_thenCreated.
// POST
@Test
public void whenCreateNewBook_thenCreated() {
final Book book = createRandomBook();
final Response response = RestAssured.given().contentType(MediaType.APPLICATION_JSON_VALUE).body(book).post(API_ROOT);
assertEquals(HttpStatus.CREATED.value(), response.getStatusCode());
}
use of org.baeldung.persistence.model.Book in project tutorials by eugenp.
the class SpringBootBootstrapIntegrationTest method createRandomBook.
// ===============================
private Book createRandomBook() {
final Book book = new Book();
book.setTitle(randomAlphabetic(10));
book.setAuthor(randomAlphabetic(15));
return book;
}
use of org.baeldung.persistence.model.Book in project tutorials by eugenp.
the class RestApiLiveTest method whenCreateNewBook_thenCreated.
// POST
@Test
public void whenCreateNewBook_thenCreated() {
final Book book = createRandomBook();
final Response response = RestAssured.given().contentType(MediaType.APPLICATION_JSON_VALUE).body(book).post(API_URI);
assertEquals(HttpStatus.CREATED.value(), response.getStatusCode());
}
use of org.baeldung.persistence.model.Book in project tutorials by eugenp.
the class RestApiLiveTest 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"));
}
Aggregations