/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.portlet.documentlibrary.search; import com.liferay.document.library.kernel.model.DLFolder; import com.liferay.document.library.kernel.model.DLFolderConstants; import com.liferay.document.library.kernel.service.DLAppLocalServiceUtil; import com.liferay.document.library.kernel.service.DLAppServiceUtil; import com.liferay.document.library.kernel.service.DLFolderLocalServiceUtil; import com.liferay.portal.kernel.model.BaseModel; import com.liferay.portal.kernel.model.Group; import com.liferay.portal.kernel.repository.model.Folder; import com.liferay.portal.kernel.service.ServiceContext; import com.liferay.portal.kernel.test.rule.AggregateTestRule; import com.liferay.portal.kernel.test.rule.Sync; import com.liferay.portal.kernel.test.rule.SynchronousDestinationTestRule; import com.liferay.portal.kernel.test.util.RandomTestUtil; import com.liferay.portal.search.test.BaseSearchTestCase; import com.liferay.portal.test.rule.LiferayIntegrationTestRule; import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; /** * @author Eudaldo Alonso */ @Sync public class DLFolderSearchTest extends BaseSearchTestCase { @ClassRule @Rule public static final AggregateTestRule aggregateTestRule = new AggregateTestRule( new LiferayIntegrationTestRule(), SynchronousDestinationTestRule.INSTANCE); @Ignore @Override @Test public void testLocalizedSearch() throws Exception { } @Ignore @Override @Test public void testSearchAttachments() throws Exception { } @Override @Test public void testSearchBaseModel() throws Exception { searchBaseModel(1); } @Override @Test public void testSearchBaseModelWithDelete() throws Exception { searchBaseModelWithDelete(1); } @Override @Test public void testSearchBaseModelWithTrash() throws Exception { searchBaseModelWithTrash(1); } @Ignore @Override @Test public void testSearchByDDMStructureField() throws Exception { } @Ignore @Override @Test public void testSearchComments() throws Exception { } @Ignore @Override @Test public void testSearchExpireAllVersions() throws Exception { } @Ignore @Override @Test public void testSearchExpireLatestVersion() throws Exception { } @Ignore @Override @Test public void testSearchMyEntries() throws Exception { } @Ignore @Override @Test public void testSearchRecentEntries() throws Exception { } @Ignore @Override @Test public void testSearchStatus() throws Exception { } @Ignore @Override @Test public void testSearchVersions() throws Exception { } @Ignore @Override @Test public void testSearchWithinDDMStructure() throws Exception { } @Override protected BaseModel<?> addBaseModelWithWorkflow( BaseModel<?> parentBaseModel, boolean approved, String keywords, ServiceContext serviceContext) throws Exception { DLFolder parentDLFolder = (DLFolder)parentBaseModel; long folderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID; if (parentDLFolder != null) { folderId = parentDLFolder.getFolderId(); } Folder folder = DLAppServiceUtil.addFolder( serviceContext.getScopeGroupId(), folderId, keywords, RandomTestUtil.randomString(), serviceContext); return (DLFolder)folder.getModel(); } @Override protected void deleteBaseModel(long primaryKey) throws Exception { DLAppLocalServiceUtil.deleteFolder(primaryKey); } @Override protected Class<?> getBaseModelClass() { return DLFolder.class; } @Override protected BaseModel<?> getParentBaseModel( BaseModel<?> parentBaseModel, ServiceContext serviceContext) throws Exception { Folder folder = DLAppServiceUtil.addFolder( serviceContext.getScopeGroupId(), (Long)parentBaseModel.getPrimaryKeyObj(), RandomTestUtil.randomString(_FOLDER_NAME_MAX_LENGTH), RandomTestUtil.randomString(), serviceContext); return (DLFolder)folder.getModel(); } @Override protected BaseModel<?> getParentBaseModel( Group group, ServiceContext serviceContext) throws Exception { Folder folder = DLAppServiceUtil.addFolder( serviceContext.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString(_FOLDER_NAME_MAX_LENGTH), RandomTestUtil.randomString(), serviceContext); return (DLFolder)folder.getModel(); } @Override protected String getSearchKeywords() { return "Title"; } @Override protected BaseModel<?> updateBaseModel( BaseModel<?> baseModel, String keywords, ServiceContext serviceContext) throws Exception { DLFolder dlFolder = (DLFolder)baseModel; dlFolder.setName(keywords); return DLFolderLocalServiceUtil.updateDLFolder(dlFolder); } private static final int _FOLDER_NAME_MAX_LENGTH = 100; }