@Test
  public void getRecentPublicCommentPosts_ShouldReturnRecentCommentPosts() throws Exception {
    Pageable pageable = new PageRequest(0, 4);

    when(commentPostRepositoryMock.findByStatusOrderByCreatedTimeDesc(
            eq(CommentStatusType.APPROVED), any(Pageable.class)))
        .thenReturn(new PageImpl<CommentPost>(getTestApprovedCommentPostList(), pageable, 2));

    mockMvc
        .perform(get(ApiUrls.API_ROOT + ApiUrls.URL_SITE_RECENT_COMMENTS))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaTypes.HAL_JSON))
        .andExpect(jsonPath("$._embedded.commentPostList", hasSize(2)))
        .andExpect(jsonPath("$._embedded.commentPostList[0].id", is(COMMENTS_1_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[0].blogPostId", is(BLOG_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[0].authorId", is(COMMENTS_1_AUTHOR_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[0].content", is(COMMENTS_1_CONTENT)))
        .andExpect(jsonPath("$._embedded.commentPostList[1].id", is(COMMENTS_2_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[1].blogPostId", is(BLOG_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[1].authorId", is(COMMENTS_2_AUTHOR_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[1].content", is(COMMENTS_2_CONTENT)))
        // check links
        .andExpect(jsonPath("$._links.self.href", endsWith(ApiUrls.URL_SITE_RECENT_COMMENTS)));

    verify(commentPostRepositoryMock, times(1))
        .findByStatusOrderByCreatedTimeDesc(CommentStatusType.APPROVED, pageable);
    verifyNoMoreInteractions(commentPostRepositoryMock);
  }
  @Test
  public void getUserApprovedCommentPosts() throws Exception {
    Page<CommentPost> page =
        new PageImpl<CommentPost>(getTestApprovedCommentPostList(), new PageRequest(0, 10), 2);

    when(commentPostRepositoryMock.findByAuthorIdAndStatusOrderByCreatedTimeDesc(
            eq(USER_ID), eq(CommentStatusType.APPROVED), any(Pageable.class)))
        .thenReturn(page);

    mockMvc
        .perform(get(ApiUrls.API_ROOT + ApiUrls.URL_SITE_PROFILES_USER_COMMENTS, USER_ID))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaTypes.HAL_JSON))
        .andExpect(jsonPath("$._embedded.commentPostList", hasSize(2)))
        .andExpect(jsonPath("$._embedded.commentPostList[0].id", is(COMMENTS_1_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[0].blogPostId", is(BLOG_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[0].authorId", is(COMMENTS_1_AUTHOR_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[0].content", is(COMMENTS_1_CONTENT)))
        .andExpect(jsonPath("$._embedded.commentPostList[1].id", is(COMMENTS_2_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[1].blogPostId", is(BLOG_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[1].authorId", is(COMMENTS_2_AUTHOR_ID)))
        .andExpect(jsonPath("$._embedded.commentPostList[1].content", is(COMMENTS_2_CONTENT)))
        .andExpect(jsonPath("$._links.self.templated", is(true)))
        .andExpect(jsonPath("$._links.self.href", endsWith("/comments{?page,size,sort}")))
        .andExpect(jsonPath("$.page.size", is(10)))
        .andExpect(jsonPath("$.page.totalElements", is(2)))
        .andExpect(jsonPath("$.page.totalPages", is(1)))
        .andExpect(jsonPath("$.page.number", is(0)));

    verify(commentPostRepositoryMock, times(1))
        .findByAuthorIdAndStatusOrderByCreatedTimeDesc(
            eq(USER_ID), eq(CommentStatusType.APPROVED), any(Pageable.class));
    verifyNoMoreInteractions(commentPostRepositoryMock);
  }