Skip to content

Commit 05e8295

Browse files
AliciaGarciaGarciabrianchandotcom
authored andcommitted
LPS-189478 add test to check if categories can be copied to a related group when coping a folder
1 parent 29cb648 commit 05e8295

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

modules/apps/document-library/document-library-test/src/testIntegration/java/com/liferay/document/library/app/service/test/DLAppServiceWhenCopyingWithAssetCategoriesRatingsEntriesAndAssetTagsTest.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,58 @@ public void testCopyFileShouldNotCopyAssetTagsDifferentGroup()
368368
className, fileEntry2.getFileEntryId())));
369369
}
370370

371+
@Test
372+
public void testCopyFolderShouldCopyAssetCategoriesAndAssetTagsParentGroup()
373+
throws Exception {
374+
375+
ServiceContext serviceContext =
376+
ServiceContextTestUtil.getServiceContext(group.getGroupId());
377+
378+
serviceContext.setAssetCategoryIds(
379+
new long[] {_assetCategory.getCategoryId()});
380+
381+
String assetTagName = RandomTestUtil.randomString();
382+
383+
AssetTestUtil.addTag(group.getGroupId(), assetTagName);
384+
385+
serviceContext.setAssetTagNames(new String[] {assetTagName});
386+
387+
FileEntry fileEntry1 = _dlAppService.addFileEntry(
388+
RandomTestUtil.randomString(), group.getGroupId(),
389+
parentFolder.getFolderId(), DLAppServiceTestUtil.FILE_NAME,
390+
ContentTypes.TEXT_PLAIN, DLAppServiceTestUtil.FILE_NAME,
391+
StringPool.BLANK, StringPool.BLANK, StringPool.BLANK,
392+
BaseDLAppTestCase.CONTENT.getBytes(), null, null, serviceContext);
393+
394+
Folder folder = _dlAppService.copyFolder(
395+
group.getGroupId(), parentFolder.getFolderId(),
396+
_childGroup.getGroupId(),
397+
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
398+
new long[] {group.getGroupId()},
399+
ServiceContextTestUtil.getServiceContext(_childGroup.getGroupId()));
400+
401+
List<FileEntry> fileEntries = _dlAppService.getFileEntries(
402+
_childGroup.getGroupId(), folder.getFolderId());
403+
404+
Assert.assertEquals(fileEntries.toString(), 1, fileEntries.size());
405+
406+
FileEntry fileEntry2 = fileEntries.get(0);
407+
408+
String className = DLFileEntryConstants.getClassName();
409+
410+
Assert.assertArrayEquals(
411+
_assetCategoryLocalService.getCategoryIds(
412+
className, fileEntry1.getFileEntryId()),
413+
_assetCategoryLocalService.getCategoryIds(
414+
className, fileEntry2.getFileEntryId()));
415+
416+
Assert.assertArrayEquals(
417+
_assetTagLocalService.getTagNames(
418+
className, fileEntry1.getFileEntryId()),
419+
_assetTagLocalService.getTagNames(
420+
className, fileEntry2.getFileEntryId()));
421+
}
422+
371423
@Test
372424
public void testCopyFolderShouldCopyAssetTagsSameGroup() throws Exception {
373425
ServiceContext serviceContext =

0 commit comments

Comments
 (0)