@Test @Transactional public void getAuthor() throws Exception { // Initialize the database authorRepository.saveAndFlush(author); // Get the author restAuthorMockMvc .perform(get("/api/authors/{id}", author.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(author.getId().intValue())) .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString())) .andExpect(jsonPath("$.surname").value(DEFAULT_SURNAME.toString())) .andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())) .andExpect(jsonPath("$.birthDate").value(DEFAULT_BIRTH_DATE.toString())); }
@Test @Transactional public void deleteAuthor() throws Exception { // Initialize the database authorRepository.saveAndFlush(author); int databaseSizeBeforeDelete = authorRepository.findAll().size(); // Get the author restAuthorMockMvc .perform(delete("/api/authors/{id}", author.getId()).accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<Author> authors = authorRepository.findAll(); assertThat(authors).hasSize(databaseSizeBeforeDelete - 1); }