@Test public void updateBook() throws Exception { // Initialize the database bookRepository.save(book); int databaseSizeBeforeUpdate = bookRepository.findAll().size(); // Update the book book.setTitle(UPDATED_TITLE); book.setDescription(UPDATED_DESCRIPTION); book.setPublisher(UPDATED_PUBLISHER); book.setPublicationDate(UPDATED_PUBLICATION_DATE); book.setPrice(UPDATED_PRICE); restBookMockMvc .perform( put("/api/books") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(book))) .andExpect(status().isOk()); // Validate the Book in the database List<Book> books = bookRepository.findAll(); assertThat(books).hasSize(databaseSizeBeforeUpdate); Book testBook = books.get(books.size() - 1); assertThat(testBook.getTitle()).isEqualTo(UPDATED_TITLE); assertThat(testBook.getDescription()).isEqualTo(UPDATED_DESCRIPTION); assertThat(testBook.getPublisher()).isEqualTo(UPDATED_PUBLISHER); assertThat(testBook.getPublicationDate()).isEqualTo(UPDATED_PUBLICATION_DATE); assertThat(testBook.getPrice()).isEqualTo(UPDATED_PRICE); }
@Before public void initTest() { bookRepository.deleteAll(); book = new Book(); book.setTitle(DEFAULT_TITLE); book.setDescription(DEFAULT_DESCRIPTION); book.setPublisher(DEFAULT_PUBLISHER); book.setPublicationDate(DEFAULT_PUBLICATION_DATE); book.setPrice(DEFAULT_PRICE); }