List of usage examples for com.liferay.portal.kernel.test.util TestPropsValues getGroupId
public static long getGroupId() throws PortalException
From source file:com.liferay.announcements.uad.test.AnnouncementsEntryUADEntityTestHelper.java
License:Open Source License
public AnnouncementsEntry addAnnouncementsEntry(long userId) throws Exception { Calendar calendar = CalendarFactoryUtil.getCalendar(); calendar.add(Calendar.DATE, 1); Date displayDate = calendar.getTime(); calendar.add(Calendar.DATE, 1); return _announcementsEntryLocalService.addEntry(userId, _classNameLocalService.getClassNameId(Group.class), TestPropsValues.getGroupId(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), "http://localhost", "general", displayDate, calendar.getTime(), 1, false); }
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);/*www. jav a 2 s . c o 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);/*from w ww . j a 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);/*from w w w .j a v a2 s .com*/ 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(); }
From source file:com.liferay.bookmarks.uad.test.BookmarksEntryUADEntityTestHelper.java
License:Open Source License
public BookmarksEntry addBookmarksEntry(long userId) throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(TestPropsValues.getGroupId()); return _bookmarksEntryLocalService.addEntry(userId, serviceContext.getScopeGroupId(), BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString(), "http://www.liferay.com", RandomTestUtil.randomString(), serviceContext); }
From source file:com.liferay.bookmarks.util.test.BookmarksTestUtil.java
License:Open Source License
public static BookmarksEntry addEntry(boolean approved) throws Exception { return addEntry(TestPropsValues.getGroupId(), approved); }
From source file:com.liferay.bookmarks.util.test.BookmarksTestUtil.java
License:Open Source License
public static BookmarksFolder addFolder(String name) throws Exception { return addFolder(TestPropsValues.getGroupId(), name); }
From source file:com.liferay.document.library.service.test.DLFileShortcutLocalServiceTreeTest.java
License:Open Source License
@Test public void testFileShortcutTreePathWhenMovingSubfolderWithFileShortcut() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId()); Folder folderA = DLAppServiceUtil.addFolder(_group.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Folder A", RandomTestUtil.randomString(), serviceContext); Folder folderAA = DLAppServiceUtil.addFolder(_group.getGroupId(), folderA.getFolderId(), "Folder AA", RandomTestUtil.randomString(), serviceContext); FileEntry fileEntry = addFileEntry(folderA.getFolderId(), "Entry.txt"); FileShortcut fileShortcut = addFileShortcut(fileEntry, TestPropsValues.getGroupId(), folderAA.getFolderId());// ww w. ja v a 2 s . c om DLAppLocalServiceUtil.moveFolder(TestPropsValues.getUserId(), folderAA.getFolderId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, serviceContext); DLFileShortcut dlFileShortcut = DLFileShortcutLocalServiceUtil .getDLFileShortcut(fileShortcut.getFileShortcutId()); Assert.assertEquals(dlFileShortcut.buildTreePath(), dlFileShortcut.getTreePath()); }
From source file:com.liferay.document.library.service.test.DLFileShortcutLocalServiceTreeTest.java
License:Open Source License
protected void createTree() throws Exception { _fileEntry = addFileEntry(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Entry A.txt"); FileShortcut fileShortcutA = addFileShortcut(_fileEntry, TestPropsValues.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); _fileShortcuts.add(fileShortcutA);/*from w ww . j av a 2 s.c om*/ ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId()); _folder = DLAppServiceUtil.addFolder(_group.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Folder A", RandomTestUtil.randomString(), serviceContext); FileShortcut fileShortcutAA = addFileShortcut(_fileEntry, TestPropsValues.getGroupId(), _folder.getFolderId()); _fileShortcuts.add(fileShortcutAA); }
From source file:com.liferay.dynamic.data.mapping.storage.test.StorageAdapterTest.java
License:Open Source License
@Test public void testDocLibraryField() throws Exception { String definition = read("ddm-structure-doc-lib-field.xsd"); DDMStructure structure = addStructure(_classNameId, null, "Documents and Media Field Structure", definition, StorageType.JSON.getValue(), DDMStructureConstants.TYPE_DEFAULT); Fields fields = new Fields(); Map<Locale, List<Serializable>> dataMap = new HashMap<>(); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(TestPropsValues.getGroupId(), TestPropsValues.getUserId()); FileEntry file1 = DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(), TestPropsValues.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Test 1.txt", ContentTypes.TEXT_PLAIN, RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE), serviceContext);/*from w ww. j a v a2 s . com*/ String file1Value = getDocLibraryFieldValue(file1); FileEntry file2 = DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(), TestPropsValues.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Test 2.txt", ContentTypes.TEXT_PLAIN, RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE), serviceContext); String file2Value = getDocLibraryFieldValue(file2); List<Serializable> enValues = ListUtil.fromArray(new Serializable[] { file1Value, file2Value }); dataMap.put(_enLocale, enValues); List<Serializable> ptValues = ListUtil.fromArray(new Serializable[] { file1Value, file2Value }); dataMap.put(_ptLocale, ptValues); Field documentLibraryField = new Field(structure.getStructureId(), "doc_library", dataMap, _enLocale); fields.put(documentLibraryField); Field fieldsDisplayField = createFieldsDisplayField(structure.getStructureId(), "doc_library_INSTANCE_rztm,doc_library_INSTANCE_ovho"); fields.put(fieldsDisplayField); validate(structure.getStructureId(), fields); }