protected void testAllCallsAreDelegated(CommentManager commentManager) throws PortalException { long userId = RandomTestUtil.randomLong(); long groupId = RandomTestUtil.randomLong(); String className = RandomTestUtil.randomString(); long classPK = RandomTestUtil.randomLong(); String userName = RandomTestUtil.randomString(); String subject = RandomTestUtil.randomString(); String body = RandomTestUtil.randomString(); long commentId = RandomTestUtil.randomLong(); ServiceContext serviceContext = new ServiceContext(); _commentManagerImpl.addComment(userId, groupId, className, classPK, body, serviceContext); Mockito.verify(commentManager) .addComment(userId, groupId, className, classPK, body, serviceContext); when(commentManager.addComment( userId, groupId, className, classPK, userName, subject, body, _serviceContextFunction)) .thenReturn(commentId); Assert.assertEquals( commentId, _commentManagerImpl.addComment( userId, groupId, className, classPK, userName, subject, body, _serviceContextFunction)); _commentManagerImpl.addDiscussion(userId, groupId, className, classPK, userName); Mockito.verify(commentManager).addDiscussion(userId, groupId, className, classPK, userName); _commentManagerImpl.deleteComment(commentId); Mockito.verify(commentManager).deleteComment(commentId); _commentManagerImpl.deleteDiscussion(className, classPK); Mockito.verify(commentManager).deleteDiscussion(className, classPK); int commentsCount = RandomTestUtil.randomInt(); when(commentManager.getCommentsCount(className, classPK)).thenReturn(commentsCount); Assert.assertEquals(commentsCount, _commentManagerImpl.getCommentsCount(className, classPK)); }