@Before
 public void initTest() {
   author = new Author();
   author.setName(DEFAULT_NAME);
   author.setSurname(DEFAULT_SURNAME);
   author.setDescription(DEFAULT_DESCRIPTION);
   author.setBirthDate(DEFAULT_BIRTH_DATE);
 }
  @Test
  @Transactional
  public void updateAuthor() throws Exception {
    // Initialize the database
    authorRepository.saveAndFlush(author);

    int databaseSizeBeforeUpdate = authorRepository.findAll().size();

    // Update the author
    author.setName(UPDATED_NAME);
    author.setSurname(UPDATED_SURNAME);
    author.setDescription(UPDATED_DESCRIPTION);
    author.setBirthDate(UPDATED_BIRTH_DATE);
    restAuthorMockMvc
        .perform(
            put("/api/authors")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(author)))
        .andExpect(status().isOk());

    // Validate the Author in the database
    List<Author> authors = authorRepository.findAll();
    assertThat(authors).hasSize(databaseSizeBeforeUpdate);
    Author testAuthor = authors.get(authors.size() - 1);
    assertThat(testAuthor.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testAuthor.getSurname()).isEqualTo(UPDATED_SURNAME);
    assertThat(testAuthor.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
    assertThat(testAuthor.getBirthDate()).isEqualTo(UPDATED_BIRTH_DATE);
  }
  @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 createAuthor() throws Exception {
    int databaseSizeBeforeCreate = authorRepository.findAll().size();

    // Create the Author
    restAuthorMockMvc
        .perform(
            post("/api/authors")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(author)))
        .andExpect(status().isCreated());

    // Validate the Author in the database
    List<Author> authors = authorRepository.findAll();
    assertThat(authors).hasSize(databaseSizeBeforeCreate + 1);
    Author testAuthor = authors.get(authors.size() - 1);
    assertThat(testAuthor.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testAuthor.getSurname()).isEqualTo(DEFAULT_SURNAME);
    assertThat(testAuthor.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
    assertThat(testAuthor.getBirthDate()).isEqualTo(DEFAULT_BIRTH_DATE);
  }
  @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);
  }