List of usage examples for com.liferay.portal.kernel.comment CommentManagerUtil addComment
public static long addComment(long userId, long groupId, String className, long classPK, String body, Function<String, ServiceContext> serviceContextFunction) throws PortalException
From source file:com.liferay.blogs.service.impl.test.BlogsEntryLocalServiceImplTest.java
License:Open Source License
@Test public void testAddDiscussion() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(); BlogsEntry blogsEntry = BlogsEntryLocalServiceUtil.addEntry(TestPropsValues.getUserId(), StringUtil.randomString(), StringUtil.randomString(), new Date(), serviceContext); _blogsEntries.add(blogsEntry);//from www. j a va 2 s .co m long initialCommentsCount = CommentManagerUtil.getCommentsCount(BlogsEntry.class.getName(), blogsEntry.getEntryId()); CommentManagerUtil.addComment(TestPropsValues.getUserId(), TestPropsValues.getGroupId(), BlogsEntry.class.getName(), blogsEntry.getEntryId(), StringUtil.randomString(), new IdentityServiceContextFunction(serviceContext)); Assert.assertEquals(initialCommentsCount + 1, CommentManagerUtil.getCommentsCount(BlogsEntry.class.getName(), blogsEntry.getEntryId())); }
From source file:com.liferay.blogs.service.impl.test.BlogsEntryLocalServiceImplTest.java
License:Open Source License
@Test public void testDeleteDiscussion() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(); BlogsEntry blogsEntry = BlogsEntryLocalServiceUtil.addEntry(TestPropsValues.getUserId(), StringUtil.randomString(), StringUtil.randomString(), new Date(), serviceContext); _blogsEntries.add(blogsEntry);/* w ww. ja v a 2 s . c o m*/ CommentManagerUtil.addComment(TestPropsValues.getUserId(), TestPropsValues.getGroupId(), BlogsEntry.class.getName(), blogsEntry.getEntryId(), StringUtil.randomString(), new IdentityServiceContextFunction(serviceContext)); Assert.assertTrue(CommentManagerUtil.hasDiscussion(BlogsEntry.class.getName(), blogsEntry.getEntryId())); CommentManagerUtil.deleteDiscussion(BlogsEntry.class.getName(), blogsEntry.getEntryId()); Assert.assertFalse(CommentManagerUtil.hasDiscussion(BlogsEntry.class.getName(), blogsEntry.getEntryId())); }
From source file:com.liferay.blogs.trackback.test.TrackbackImplTest.java
License:Open Source License
@Test public void testAddTrackback() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(); _blogsEntry = BlogsEntryLocalServiceUtil.addEntry(TestPropsValues.getUserId(), StringUtil.randomString(), StringUtil.randomString(), new Date(), serviceContext); IdentityServiceContextFunction serviceContextFunction = new IdentityServiceContextFunction(serviceContext); CommentManagerUtil.addComment(TestPropsValues.getUserId(), TestPropsValues.getGroupId(), BlogsEntry.class.getName(), _blogsEntry.getEntryId(), StringUtil.randomString(), serviceContextFunction);// w ww . j av a 2 s.c o m int initialCommentsCount = CommentManagerUtil.getCommentsCount(BlogsEntry.class.getName(), _blogsEntry.getEntryId()); Trackback trackback = new TrackbackImpl(); ThemeDisplay themeDisplay = new ThemeDisplay(); Company company = CompanyLocalServiceUtil.getCompany(TestPropsValues.getCompanyId()); themeDisplay.setCompany(company); trackback.addTrackback(_blogsEntry, themeDisplay, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), serviceContextFunction); Assert.assertEquals(initialCommentsCount + 1, CommentManagerUtil.getCommentsCount(BlogsEntry.class.getName(), _blogsEntry.getEntryId())); LinkbackConsumerUtil.verifyNewTrackbacks(); }