protected DLFileEntry addDLFileEntry() throws Exception { long pk = RandomTestUtil.nextLong(); DLFileEntry dlFileEntry = _persistence.create(pk); dlFileEntry.setUuid(RandomTestUtil.randomString()); dlFileEntry.setGroupId(RandomTestUtil.nextLong()); dlFileEntry.setCompanyId(RandomTestUtil.nextLong()); dlFileEntry.setUserId(RandomTestUtil.nextLong()); dlFileEntry.setUserName(RandomTestUtil.randomString()); dlFileEntry.setCreateDate(RandomTestUtil.nextDate()); dlFileEntry.setModifiedDate(RandomTestUtil.nextDate()); dlFileEntry.setClassNameId(RandomTestUtil.nextLong()); dlFileEntry.setClassPK(RandomTestUtil.nextLong()); dlFileEntry.setRepositoryId(RandomTestUtil.nextLong()); dlFileEntry.setFolderId(RandomTestUtil.nextLong()); dlFileEntry.setTreePath(RandomTestUtil.randomString()); dlFileEntry.setName(RandomTestUtil.randomString()); dlFileEntry.setFileName(RandomTestUtil.randomString()); dlFileEntry.setExtension(RandomTestUtil.randomString()); dlFileEntry.setMimeType(RandomTestUtil.randomString()); dlFileEntry.setTitle(RandomTestUtil.randomString()); dlFileEntry.setDescription(RandomTestUtil.randomString()); dlFileEntry.setExtraSettings(RandomTestUtil.randomString()); dlFileEntry.setFileEntryTypeId(RandomTestUtil.nextLong()); dlFileEntry.setVersion(RandomTestUtil.randomString()); dlFileEntry.setSize(RandomTestUtil.nextLong()); dlFileEntry.setReadCount(RandomTestUtil.nextInt()); dlFileEntry.setSmallImageId(RandomTestUtil.nextLong()); dlFileEntry.setLargeImageId(RandomTestUtil.nextLong()); dlFileEntry.setCustom1ImageId(RandomTestUtil.nextLong()); dlFileEntry.setCustom2ImageId(RandomTestUtil.nextLong()); dlFileEntry.setManualCheckInRequired(RandomTestUtil.randomBoolean()); dlFileEntry.setLastPublishDate(RandomTestUtil.nextDate()); _dlFileEntries.add(_persistence.update(dlFileEntry)); return dlFileEntry; }
protected static Object[] setUp( long repositoryId, String titleSuffix, ServiceContext serviceContext) throws Exception { Folder folder = DLAppLocalServiceUtil.addFolder( TestPropsValues.getUserId(), repositoryId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Folder A", StringPool.BLANK, serviceContext); DLAppLocalServiceUtil.addFolder( TestPropsValues.getUserId(), repositoryId, folder.getFolderId(), "Folder B", StringPool.BLANK, serviceContext); Folder folderC = DLAppLocalServiceUtil.addFolder( TestPropsValues.getUserId(), repositoryId, folder.getFolderId(), "Folder C", StringPool.BLANK, serviceContext); DLTrashServiceUtil.moveFolderToTrash(folderC.getFolderId()); FileEntry fileEntry = addFileEntry( _user.getUserId(), repositoryId, folder.getFolderId(), "FE1.txt", titleSuffix, ContentTypes.TEXT_PLAIN, DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT); LiferayFileEntry liferayFileEntry = (LiferayFileEntry) fileEntry; DLFileEntry dlFileEntry = liferayFileEntry.getDLFileEntry(); dlFileEntry.setExtraSettings("hello=world"); dlFileEntry.setSmallImageId(_SMALL_IMAGE_ID); dlFileEntry = DLFileEntryLocalServiceUtil.updateDLFileEntry(dlFileEntry); DLFileVersion dlFileVersion = dlFileEntry.getFileVersion(); addFileEntry( TestPropsValues.getUserId(), repositoryId, folder.getFolderId(), "FE2.pdf", titleSuffix, ContentTypes.APPLICATION_PDF, DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_ALL); fileEntry = addFileEntry( TestPropsValues.getUserId(), repositoryId, folder.getFolderId(), "FE3.txt", titleSuffix, ContentTypes.TEXT_PLAIN, DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_ALL); fileEntry = DLAppServiceUtil.updateFileEntry( fileEntry.getFileEntryId(), "FE3.txt", ContentTypes.TEXT_PLAIN, "FE3.txt".concat(titleSuffix), StringPool.BLANK, StringPool.BLANK, false, RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE), serviceContext); dlFileEntry = ((LiferayFileEntry) fileEntry).getDLFileEntry(); dlFileEntry.setDescription("FE3.txt"); DLFileEntryLocalServiceUtil.updateDLFileEntry(dlFileEntry); DLFileVersion dlFileVersion3 = dlFileEntry.getFileVersion(); dlFileVersion3.setExtraSettings("hello=world"); DLFileVersionLocalServiceUtil.updateDLFileVersion(dlFileVersion3); DLTrashServiceUtil.moveFileEntryToTrash(fileEntry.getFileEntryId()); return new Object[] {folder, dlFileVersion}; }
@Test public void testUpdateExisting() throws Exception { long pk = RandomTestUtil.nextLong(); DLFileEntry newDLFileEntry = _persistence.create(pk); newDLFileEntry.setUuid(RandomTestUtil.randomString()); newDLFileEntry.setGroupId(RandomTestUtil.nextLong()); newDLFileEntry.setCompanyId(RandomTestUtil.nextLong()); newDLFileEntry.setUserId(RandomTestUtil.nextLong()); newDLFileEntry.setUserName(RandomTestUtil.randomString()); newDLFileEntry.setCreateDate(RandomTestUtil.nextDate()); newDLFileEntry.setModifiedDate(RandomTestUtil.nextDate()); newDLFileEntry.setClassNameId(RandomTestUtil.nextLong()); newDLFileEntry.setClassPK(RandomTestUtil.nextLong()); newDLFileEntry.setRepositoryId(RandomTestUtil.nextLong()); newDLFileEntry.setFolderId(RandomTestUtil.nextLong()); newDLFileEntry.setTreePath(RandomTestUtil.randomString()); newDLFileEntry.setName(RandomTestUtil.randomString()); newDLFileEntry.setFileName(RandomTestUtil.randomString()); newDLFileEntry.setExtension(RandomTestUtil.randomString()); newDLFileEntry.setMimeType(RandomTestUtil.randomString()); newDLFileEntry.setTitle(RandomTestUtil.randomString()); newDLFileEntry.setDescription(RandomTestUtil.randomString()); newDLFileEntry.setExtraSettings(RandomTestUtil.randomString()); newDLFileEntry.setFileEntryTypeId(RandomTestUtil.nextLong()); newDLFileEntry.setVersion(RandomTestUtil.randomString()); newDLFileEntry.setSize(RandomTestUtil.nextLong()); newDLFileEntry.setReadCount(RandomTestUtil.nextInt()); newDLFileEntry.setSmallImageId(RandomTestUtil.nextLong()); newDLFileEntry.setLargeImageId(RandomTestUtil.nextLong()); newDLFileEntry.setCustom1ImageId(RandomTestUtil.nextLong()); newDLFileEntry.setCustom2ImageId(RandomTestUtil.nextLong()); newDLFileEntry.setManualCheckInRequired(RandomTestUtil.randomBoolean()); newDLFileEntry.setLastPublishDate(RandomTestUtil.nextDate()); _dlFileEntries.add(_persistence.update(newDLFileEntry)); DLFileEntry existingDLFileEntry = _persistence.findByPrimaryKey(newDLFileEntry.getPrimaryKey()); Assert.assertEquals(existingDLFileEntry.getUuid(), newDLFileEntry.getUuid()); Assert.assertEquals(existingDLFileEntry.getFileEntryId(), newDLFileEntry.getFileEntryId()); Assert.assertEquals(existingDLFileEntry.getGroupId(), newDLFileEntry.getGroupId()); Assert.assertEquals(existingDLFileEntry.getCompanyId(), newDLFileEntry.getCompanyId()); Assert.assertEquals(existingDLFileEntry.getUserId(), newDLFileEntry.getUserId()); Assert.assertEquals(existingDLFileEntry.getUserName(), newDLFileEntry.getUserName()); Assert.assertEquals( Time.getShortTimestamp(existingDLFileEntry.getCreateDate()), Time.getShortTimestamp(newDLFileEntry.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingDLFileEntry.getModifiedDate()), Time.getShortTimestamp(newDLFileEntry.getModifiedDate())); Assert.assertEquals(existingDLFileEntry.getClassNameId(), newDLFileEntry.getClassNameId()); Assert.assertEquals(existingDLFileEntry.getClassPK(), newDLFileEntry.getClassPK()); Assert.assertEquals(existingDLFileEntry.getRepositoryId(), newDLFileEntry.getRepositoryId()); Assert.assertEquals(existingDLFileEntry.getFolderId(), newDLFileEntry.getFolderId()); Assert.assertEquals(existingDLFileEntry.getTreePath(), newDLFileEntry.getTreePath()); Assert.assertEquals(existingDLFileEntry.getName(), newDLFileEntry.getName()); Assert.assertEquals(existingDLFileEntry.getFileName(), newDLFileEntry.getFileName()); Assert.assertEquals(existingDLFileEntry.getExtension(), newDLFileEntry.getExtension()); Assert.assertEquals(existingDLFileEntry.getMimeType(), newDLFileEntry.getMimeType()); Assert.assertEquals(existingDLFileEntry.getTitle(), newDLFileEntry.getTitle()); Assert.assertEquals(existingDLFileEntry.getDescription(), newDLFileEntry.getDescription()); Assert.assertEquals(existingDLFileEntry.getExtraSettings(), newDLFileEntry.getExtraSettings()); Assert.assertEquals( existingDLFileEntry.getFileEntryTypeId(), newDLFileEntry.getFileEntryTypeId()); Assert.assertEquals(existingDLFileEntry.getVersion(), newDLFileEntry.getVersion()); Assert.assertEquals(existingDLFileEntry.getSize(), newDLFileEntry.getSize()); Assert.assertEquals(existingDLFileEntry.getReadCount(), newDLFileEntry.getReadCount()); Assert.assertEquals(existingDLFileEntry.getSmallImageId(), newDLFileEntry.getSmallImageId()); Assert.assertEquals(existingDLFileEntry.getLargeImageId(), newDLFileEntry.getLargeImageId()); Assert.assertEquals( existingDLFileEntry.getCustom1ImageId(), newDLFileEntry.getCustom1ImageId()); Assert.assertEquals( existingDLFileEntry.getCustom2ImageId(), newDLFileEntry.getCustom2ImageId()); Assert.assertEquals( existingDLFileEntry.getManualCheckInRequired(), newDLFileEntry.getManualCheckInRequired()); Assert.assertEquals( Time.getShortTimestamp(existingDLFileEntry.getLastPublishDate()), Time.getShortTimestamp(newDLFileEntry.getLastPublishDate())); }