### Question:
TransactionalPostService extends AbstractTransactionalEntityService<Post, PostDao> implements PostService, PluginPostService { @Override public Post getLastPostFor(Branch branch) { return getDao().getLastPostFor(branch); } 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 testGetLastPostForBranch() { Branch postBranch = new Branch(null, null); Post expectedPost = new Post(null, null); when(postDao.getLastPostFor(Mockito.<Branch>any())) .thenReturn(expectedPost); Post actualPost = postService.getLastPostFor(postBranch); assertEquals(actualPost, expectedPost, "Service returned incorrect last post for branch"); verify(postDao).getLastPostFor(postBranch); }