  @Test
  public void postingANewBookShouldCreateANewBook() throws Exception {


    BookRequest bookRequest = new BookRequest();
    bookRequest.setAuthor("Duke");
    bookRequest.setIsbn("1337");
    bookRequest.setTitle("Java 11");

    when(bookService.createNewBook(bookRequestArgumentCaptor.capture())).thenReturn(1L);

    this.mockMvc
      .perform(post("/api/books")
        .contentType(MediaType.APPLICATION_JSON)
        .content(objectMapper.writeValueAsString(bookRequest)))
      .andExpect(status().isCreated())
      .andExpect(header().exists("Location"))
      .andExpect(header().string("Location", "http://localhost/api/books/1"));

    assertThat(bookRequestArgumentCaptor.getValue().getAuthor(), is("Duke"));
    assertThat(bookRequestArgumentCaptor.getValue().getIsbn(), is("1337"));
    assertThat(bookRequestArgumentCaptor.getValue().getTitle(), is("Java 11"));

  }