@Test
  public void createCommentEntryExistingCommentary() throws Exception {
    Commentary commentary = new Commentary();
    commentary.setId(1L);

    CommentEntry entry = new CommentEntry();
    entry.setTitle("Test Title");
    entry.setId(1L);

    when(commentaryService.createCommentEntry(eq(1L), any(CommentEntry.class))).thenReturn(entry);

    mockMvc
        .perform(
            post("/rest/commentaries/1/comment-entries")
                .content("{\"content\":\"Generic content\"}")
                .contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.title", is(entry.getTitle())))
        .andExpect(jsonPath("$.links[*].href", hasItem(endsWith("rest/comment-entries/1"))))
        .andExpect(header().string("Location", endsWith("rest/comment-entries/1")))
        .andExpect(status().isCreated());
  }
  @Test
  public void listBlogEntriesForExistingBlog() throws Exception {

    CommentEntry entryA = new CommentEntry();
    entryA.setId(1L);
    entryA.setTitle("Test Title");

    CommentEntry entryB = new CommentEntry();
    entryB.setId(2L);
    entryB.setTitle("Test Title");

    List<CommentEntry> commentListings = new ArrayList();
    commentListings.add(entryA);
    commentListings.add(entryB);

    CommentEntryList list = new CommentEntryList(1L, commentListings);

    when(commentaryService.findAllCommentEntries(1L)).thenReturn(list);

    mockMvc
        .perform(get("/rest/commentaries/1/comment-entries"))
        .andDo(print())
        .andExpect(
            jsonPath("$.links[*].href", hasItem(endsWith("/commentaries/1/comment-entries"))))
        .andExpect(jsonPath("$.entries[*].title", hasItem(is("Test Title"))))
        .andExpect(status().isOk());
  }