### Question:
TransactionalPostService extends AbstractTransactionalEntityService<Post, PostDao> implements PostService, PluginPostService { @Override public Page<Post> getPosts(Topic topic, String page) { PageRequest pageRequest = new PageRequest(page, userService.getCurrentUser().getPageSize()); return getDao().getPosts(topic, pageRequest); } TransactionalPostService(
            PostDao dao,
            TopicDao topicDao,
            SecurityService securityService,
            NotificationService notificationService,
            UserService userService,
            BranchLastPostService branchLastPostService,
            PermissionService permissionService,
            PluginLoader pluginLoader,
            Crud<PostDraft> postDraftDao); @PreAuthorize("(hasPermission(#post.id, 'POST', 'GeneralPermission.WRITE') and " + "hasPermission(#post.topic.branch.id, 'BRANCH', 'BranchPermission.EDIT_OWN_POSTS')) or " + "(not hasPermission(#post.id, 'POST', 'GeneralPermission.WRITE') and " + "hasPermission(#post.topic.branch.id, 'BRANCH', 'BranchPermission.EDIT_OTHERS_POSTS'))") @Override void updatePost(Post post, String postContent); @Override @PreAuthorize("(hasPermission(#post.topic.branch.id, 'BRANCH', 'BranchPermission.DELETE_OWN_POSTS') and " + "#post.userCreated.username == principal.username) or " + "(hasPermission(#post.topic.branch.id, 'BRANCH', 'BranchPermission.DELETE_OTHERS_POSTS') and " + "#post.userCreated.username != principal.username)") void deletePost(Post post); @Override @PreAuthorize("hasPermission(#topic.branch.id, 'BRANCH', 'BranchPermission.CREATE_POSTS')") PostDraft saveOrUpdateDraft(Topic topic, String content); @Override Page<Post> getPostsOfUser(JCUser userCreated, String page); @Override int calculatePageForPost(Post post); @Override Page<Post> getPosts(Topic topic, String page); @Override Post getLastPostFor(Branch branch); @Override List<Post> getLastPostsFor(Branch branch, int postCount); @Override PostComment addComment(Long postId, Map<String, String> attributes, String body); @PreAuthorize("(hasPermission(#post.topic.branch.id, 'BRANCH', 'BranchPermission.DELETE_OWN_POSTS') and " + "#comment.author.username == principal.username) or " + "(hasPermission(#post.topic.branch.id, 'BRANCH', 'BranchPermission.DELETE_OTHERS_POSTS') and " + "#comment.author.username != principal.username)") void deleteComment(Post post, PostComment comment); @Override @PreAuthorize("hasPermission(#post.topic.branch.id, 'BRANCH', 'BranchPermission.CREATE_POSTS') " + "and #post.userCreated.username != principal.username") Post vote(Post post, PostVote vote); @Override void deleteDraft(Long draftId);  }### Answer:
@Test public void testGetPosts() { String pageNumber = "50"; Topic topic = new Topic(user, ""); Page<Post> expectedPage = new PageImpl<>(Collections.<Post>emptyList()); currentUser.setPageSize(50); when(postDao.getPosts( Matchers.any(Topic.class), Matchers.any(PageRequest.class))) .thenReturn(expectedPage); Page<Post> actualPage = postService.getPosts(topic, pageNumber); assertEquals(actualPage, expectedPage, "Service returned incorrect data for one page of posts"); verify(postDao).getPosts(Matchers.any(Topic.class), Matchers.any(PageRequest.class)); }