@Test
  public void testGetUnansweredTopics() {
    int pageNumber = 1;
    int pageSize = 20;
    List<Topic> expectedList = Collections.nCopies(2, new Topic(user, "title"));
    Page<Topic> expectedPage = new PageImpl<Topic>(expectedList);
    when(topicDao.getUnansweredTopics(Matchers.<JCommunePageRequest>any(), eq(user)))
        .thenReturn(expectedPage);
    user.setPageSize(pageSize);
    when(userService.getCurrentUser()).thenReturn(user);

    Page<Topic> actualPage = topicFetchService.getUnansweredTopics(pageNumber);
    assertNotNull(actualPage);
    assertEquals(actualPage, expectedPage);
  }
  @Test
  public void testGetTopics() {
    int pageSize = 50;
    Branch branch = createBranch();
    Page<Topic> expectedPage = new PageImpl<Topic>(Collections.<Topic>emptyList());

    JCUser currentUser = new JCUser("current", null, null);
    currentUser.setPageSize(pageSize);
    when(userService.getCurrentUser()).thenReturn(currentUser);
    when(topicDao.getTopics(Matchers.any(Branch.class), Matchers.any(JCommunePageRequest.class)))
        .thenReturn(expectedPage);

    Page<Topic> actualPage = topicFetchService.getTopics(branch, pageSize, true);

    assertEquals(
        actualPage, expectedPage, "Service returned incorrect data for one page of topics");
    verify(topicDao).getTopics(Matchers.any(Branch.class), Matchers.any(JCommunePageRequest.class));
  }
  @Test
  public void testGetAllTopicsPastLastDay() throws NotFoundException {
    int pageNumber = 1;
    int pageSize = 20;
    List<Topic> expectedList = Collections.nCopies(2, new Topic(user, "title"));
    Page<Topic> expectedPage = new PageImpl<Topic>(expectedList);
    when(topicDao.getTopicsUpdatedSince(
            Matchers.<DateTime>any(), Matchers.<JCommunePageRequest>any(), eq(user)))
        .thenReturn(expectedPage);
    user.setPageSize(pageSize);
    when(userService.getCurrentUser()).thenReturn(user);

    Page<Topic> actualPage = topicFetchService.getRecentTopics(pageNumber);

    assertNotNull(actualPage);
    assertEquals(expectedPage, actualPage);
    verify(topicDao)
        .getTopicsUpdatedSince(
            Matchers.<DateTime>any(), Matchers.<JCommunePageRequest>any(), eq(user));
  }