@Test public void testUpdateLastPost() throws Exception { Branch branch = new Branch("name", "description"); Post lastPost = new Post(); branchService.updateLastPost(branch, lastPost); assertSame(lastPost, branch.getLastPost()); }
@Test public void testFillBranchStatistics() { int expectedTopicCount = 5; int expectedPostCount = 10; Branch branch = new Branch("name", "description"); when(topicDao.getTopicCountInBranch(branch)).thenReturn(expectedTopicCount); when(postDao.getPostCountInBranch(branch)).thenReturn(expectedPostCount); branchService.fillBranchStatistics(branch); assertEquals(expectedTopicCount, branch.getTopicsCount()); assertEquals(expectedPostCount, branch.getPostsCount()); }