### Question:
TransactionalTopicFetchService extends AbstractTransactionalEntityService<Topic, TopicDao> implements TopicFetchService, PluginTopicFetchService { @Override public Page<Topic> getTopics(Branch branch, String page) { int pageSize = userService.getCurrentUser().getPageSize(); PageRequest pageRequest = new PageRequest(page, pageSize); return getDao().getTopics(branch, pageRequest); } TransactionalTopicFetchService(TopicDao dao, ComponentService componentService, UserService userService, TopicSearchDao searchDao); @Override Topic get(Long id); @Override Page<Topic> getRecentTopics(String page); @Override Page<Topic> getUnansweredTopics(String page); @Override Topic getTopicSilently(Long id); @Override Page<Topic> getTopics(Branch branch, String page); @Override Page<Topic> searchByTitleAndContent(String phrase, String page); @Override void rebuildSearchIndex(); @PreAuthorize("hasPermission(#branchId, 'BRANCH', 'BranchPermission.VIEW_TOPICS')") @Override void checkViewTopicPermission(Long branchId);  }### Answer:
@Test public void testGetTopics() { String pageNumber = "50"; Branch branch = createBranch(); Page<Topic> expectedPage = new PageImpl<>(Collections.<Topic>emptyList()); JCUser currentUser = new JCUser("current", null, null); currentUser.setPageSize(50); when(userService.getCurrentUser()).thenReturn(currentUser); when(topicDao.getTopics( Matchers.any(Branch.class), Matchers.any(PageRequest.class))) .thenReturn(expectedPage); Page<Topic> actualPage = topicFetchService.getTopics(branch, pageNumber); assertEquals(actualPage, expectedPage, "Service returned incorrect data for one page of topics"); verify(topicDao).getTopics( Matchers.any(Branch.class), Matchers.any(PageRequest.class)); }