List of usage examples for com.liferay.portal.kernel.test.util RandomTestUtil randomLong
public static long randomLong()
From source file:com.liferay.adaptive.media.blogs.web.internal.exportimport.content.processor.AMBlogsEntryExportImportContentProcessorTest.java
License:Open Source License
@Test(expected = PortalException.class) public void testValidateContentFailsWhenBlogsEntryExportImportContentProcessorProcessorFails() throws Exception { String content = RandomTestUtil.randomString(); Mockito.doThrow(PortalException.class).when(_blogsEntryExportImportContentProcessor) .validateContentReferences(Mockito.anyLong(), Mockito.anyString()); _amBlogsEntryExportImportContentProcessor.validateContentReferences(RandomTestUtil.randomLong(), content); }
From source file:com.liferay.adaptive.media.blogs.web.internal.exportimport.content.processor.AMBlogsEntryExportImportContentProcessorTest.java
License:Open Source License
@Test(expected = PortalException.class) public void testValidateContentFailsWhenHTMLExportImportContentProcessorFails() throws Exception { String content = RandomTestUtil.randomString(); Mockito.doThrow(PortalException.class).when(_htmlExportImportContentProcessor) .validateContentReferences(Mockito.anyLong(), Mockito.anyString()); _amBlogsEntryExportImportContentProcessor.validateContentReferences(RandomTestUtil.randomLong(), content); }
From source file:com.liferay.adaptive.media.blogs.web.internal.exportimport.content.processor.AMBlogsEntryExportImportContentProcessorTest.java
License:Open Source License
@Test public void testValidateContentSucceedsWhenBothExportImportContentProcessorsSucceed() throws Exception { _amBlogsEntryExportImportContentProcessor.validateContentReferences(RandomTestUtil.randomLong(), RandomTestUtil.randomString()); }
From source file:com.liferay.adaptive.media.blogs.web.internal.optimizer.test.BlogsAMImageOptimizerTest.java
License:Open Source License
private AMImageConfigurationEntry _addAMImageConfigurationEntry(long companyId) throws Exception { String amImageConfigurationEntry1Name = RandomTestUtil.randomString(); Map<String, String> properties = new HashMap<>(); properties.put("max-height", String.valueOf(RandomTestUtil.randomLong())); properties.put("max-width", String.valueOf(RandomTestUtil.randomLong())); return _amImageConfigurationHelper.addAMImageConfigurationEntry(companyId, amImageConfigurationEntry1Name, StringPool.BLANK, amImageConfigurationEntry1Name, properties); }
From source file:com.liferay.adaptive.media.document.library.web.internal.counter.test.DLAMImageCounterTest.java
License:Open Source License
@Test public void testDLAMImageCounterOnlyCountsDefaultRepositoryImages() throws Exception { Assert.assertEquals(0, _amImageCounter.countExpectedAMImageEntries(_company1.getCompanyId())); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group1, _user1.getUserId()); _dlAppLocalService.addFileEntry(_user1.getUserId(), _group1.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString() + ".jpg", ContentTypes.IMAGE_JPEG, _getImageBytes(), serviceContext); PortletFileRepositoryUtil.addPortletFileEntry(_group1.getGroupId(), _user1.getUserId(), BlogsEntry.class.getName(), RandomTestUtil.randomLong(), BlogsConstants.SERVICE_NAME, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, _getImageBytes(), RandomTestUtil.randomString(), ContentTypes.IMAGE_JPEG, true); Assert.assertEquals(1, _amImageCounter.countExpectedAMImageEntries(_company1.getCompanyId())); }
From source file:com.liferay.adaptive.media.document.library.web.internal.counter.test.DLAMImageCounterTest.java
License:Open Source License
@Test public void testDLAMImageCounterOnlyCountsDefaultRepositoryImagesPerCompany() throws Exception { Assert.assertEquals(0, _amImageCounter.countExpectedAMImageEntries(_company1.getCompanyId())); Assert.assertEquals(0, _amImageCounter.countExpectedAMImageEntries(_company2.getCompanyId())); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group1, _user1.getUserId()); _dlAppLocalService.addFileEntry(_user1.getUserId(), _group1.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString() + ".jpg", ContentTypes.IMAGE_JPEG, _getImageBytes(), serviceContext); PortletFileRepositoryUtil.addPortletFileEntry(_group1.getGroupId(), _user1.getUserId(), BlogsEntry.class.getName(), RandomTestUtil.randomLong(), BlogsConstants.SERVICE_NAME, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, _getImageBytes(), RandomTestUtil.randomString(), ContentTypes.IMAGE_JPEG, true); Assert.assertEquals(1, _amImageCounter.countExpectedAMImageEntries(_company1.getCompanyId())); Assert.assertEquals(0, _amImageCounter.countExpectedAMImageEntries(_company2.getCompanyId())); }
From source file:com.liferay.adaptive.media.image.internal.exportimport.content.processor.AMImageHTMLExportImportContentProcessorTest.java
License:Open Source License
@Test(expected = NoSuchFileEntryException.class) public void testValidateContentFailsWithInvalidReferences() throws Exception { StringBundler sb = new StringBundler(5); sb.append("<img data-fileentryid=\""); sb.append(RandomTestUtil.randomLong()); sb.append("\" src=\"PATH_"); sb.append(_fileEntryId1);//from w w w . j ava 2s.c o m sb.append("\" />"); _amImageHTMLExportImportContentProcessor.validateContentReferences(RandomTestUtil.randomLong(), sb.toString()); }
From source file:com.liferay.adaptive.media.image.internal.exportimport.content.processor.AMImageHTMLExportImportContentProcessorTest.java
License:Open Source License
@Test(expected = NoSuchFileEntryException.class) public void testValidateContentFailsWithInvalidStaticReferences() throws Exception { String content = "<picture data-fileentryid=\"" + RandomTestUtil.randomLong() + "\"></picture>"; _amImageHTMLExportImportContentProcessor.validateContentReferences(RandomTestUtil.randomLong(), content); }
From source file:com.liferay.adaptive.media.image.internal.exportimport.content.processor.AMImageHTMLExportImportContentProcessorTest.java
License:Open Source License
@Test public void testValidateContentSucceedsWhenAllReferencesAreValid() throws Exception { StringBundler sb = new StringBundler(5); sb.append("<img data-fileentryid=\""); sb.append(_fileEntryId1);//from w ww .j a v a 2 s . c o m sb.append("\" src=\"PATH_"); sb.append(_fileEntryId1); sb.append("\" />"); _amImageHTMLExportImportContentProcessor.validateContentReferences(RandomTestUtil.randomLong(), sb.toString()); }
From source file:com.liferay.adaptive.media.image.internal.exportimport.content.processor.AMImageHTMLExportImportContentProcessorTest.java
License:Open Source License
@Test public void testValidateContentSucceedsWhenAllStaticReferencesAreValid() throws Exception { Mockito.doReturn(_fileEntry1).when(_dlAppLocalService).getFileEntry(_fileEntryId1); String content = "<picture data-fileentryid=\"" + _fileEntryId1 + "\"></picture>"; _amImageHTMLExportImportContentProcessor.validateContentReferences(RandomTestUtil.randomLong(), content); }