### Question:
TransactionalPostService extends AbstractTransactionalEntityService<Post, PostDao> implements PostService, PluginPostService { @Override public List<Post> getLastPostsFor(Branch branch, int postCount) { return getDao().getLastPostsFor(Arrays.asList(branch.getId()), postCount); } 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 testGetLastPostsForBranch() { Branch postBranch = new Branch(null, null); Post expectedPost = new Post(null, null); List<Post> posts = Arrays.asList(expectedPost); List<Long> branches = Arrays.asList(postBranch.getId()); when(postDao.getLastPostsFor(Mockito.<List<Long>>any(), Mockito.eq(42))) .thenReturn(posts); List<Post> actualPosts = postService.getLastPostsFor(postBranch, 42); assertEquals(actualPosts, posts, "Service returned incorrect last posts for branch"); verify(postDao).getLastPostsFor(branches, 42); }