Example usage for com.liferay.portal.kernel.test.util TestPropsValues getUserId

List of usage examples for com.liferay.portal.kernel.test.util TestPropsValues getUserId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.test.util TestPropsValues getUserId.

Prototype

public static long getUserId() throws PortalException 

Source Link

Usage

From source file:com.liferay.adaptive.media.blogs.internal.exportimport.data.handler.test.AMBlogsEntryStagedModelDataHandlerTest.java

License:Open Source License

private BlogsEntry _addBlogsEntry(String content, ServiceContext serviceContext) throws Exception {

    return _blogsEntryLocalService.addEntry(TestPropsValues.getUserId(), RandomTestUtil.randomString(),
            RandomTestUtil.randomString(), RandomTestUtil.randomString(), content, new Date(), true, true,
            new String[0], StringPool.BLANK, null, null, serviceContext);
}

From source file:com.liferay.adaptive.media.blogs.internal.exportimport.data.handler.test.AMBlogsEntryStagedModelDataHandlerTest.java

License:Open Source License

private FileEntry _addImageFileEntry(ServiceContext serviceContext) throws Exception {

    return _dlAppLocalService.addFileEntry(TestPropsValues.getUserId(), stagingGroup.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString(), ContentTypes.IMAGE_JPEG,
            FileUtil.getBytes(getClass(), "image.jpg"), serviceContext);
}

From source file:com.liferay.adaptive.media.blogs.internal.exportimport.data.handler.test.AMBlogsEntryStagedModelDataHandlerTest.java

License:Open Source License

private ServiceContext _getServiceContext() throws PortalException {
    return ServiceContextTestUtil.getServiceContext(stagingGroup.getGroupId(), TestPropsValues.getUserId());
}

From source file:com.liferay.adaptive.media.image.internal.configuration.test.AMImageDeleteConfigurationTest.java

License:Open Source License

private FileEntry _addFileEntry() throws Exception {
    return DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(), _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString() + ".jpg",
            ContentTypes.IMAGE_JPEG,/*from   w ww .  j  a  va 2  s . c  om*/
            FileUtil.getBytes(AMImageDeleteConfigurationTest.class, _JPG_IMAGE_FILE_PATH),
            new ServiceContext());
}

From source file:com.liferay.adaptive.media.image.internal.scaler.test.AMGIFImageScalerTest.java

License:Open Source License

private FileEntry _addFileEntry() throws Exception {
    return DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(), _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString() + ".gif",
            ContentTypes.IMAGE_GIF, FileUtil.getBytes(AMGIFImageScalerTest.class, _FILE_PATH_GIF_IMAGE),
            new ServiceContext());
}

From source file:com.liferay.adaptive.media.image.internal.test.AdaptiveMediaImageDeleteConfigurationTest.java

License:Open Source License

private FileEntry _addFileEntry() throws Exception {
    return DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(), _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".jpg",
            ContentTypes.IMAGE_JPEG,//  w ww . j  av  a  2s.  c  o  m
            FileUtil.getBytes(AdaptiveMediaImageDeleteConfigurationTest.class, _PNG_IMAGE_FILE_PATH),
            new ServiceContext());
}

From source file:com.liferay.adaptive.media.image.item.selector.internal.resolver.test.FileEntryAdaptiveMediaImageFileEntryItemSelectorReturnTypeResolverTest.java

License:Open Source License

@Test
public void testAddingFileEntryWithImageCreatesMedia() throws Exception {
    try (DestinationReplacer destinationReplacer = new DestinationReplacer(
            "liferay/adaptive_media_processor")) {

        ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group,
                TestPropsValues.getUserId());

        final FileEntry fileEntry = _addImageFileEntry(serviceContext);

        String value = _resolver.getValue(fileEntry, null);

        JSONObject jsonObject = JSONFactoryUtil.createJSONObject(value);

        String url = jsonObject.getString("url");
        long fileEntryId = jsonObject.getLong("fileEntryId");

        Assert.assertEquals(DLUtil.getPreviewURL(fileEntry, fileEntry.getFileVersion(), null, StringPool.BLANK,
                false, false), url);/*from   w  ww  . j  ava 2s  .  c om*/

        Assert.assertEquals(fileEntry.getFileEntryId(), fileEntryId);
    }
}

From source file:com.liferay.adaptive.media.image.item.selector.internal.resolver.test.FileEntryAdaptiveMediaImageFileEntryItemSelectorReturnTypeResolverTest.java

License:Open Source License

private FileEntry _addImageFileEntry(ServiceContext serviceContext) throws Exception {

    return _dlAppLocalService.addFileEntry(TestPropsValues.getUserId(), _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString(), ContentTypes.IMAGE_JPEG,
            _getImageBytes(), serviceContext);
}

From source file:com.liferay.adaptive.media.image.item.selector.internal.resolver.test.FileEntryAdaptiveMediaImageURLItemSelectorReturnTypeResolverTest.java

License:Open Source License

@Test
public void testAddingFileEntryWithHDMediaQueries() throws Exception {
    try (DestinationReplacer destinationReplacer = new DestinationReplacer(
            "liferay/adaptive_media_processor")) {

        _addTestVariant("small", "uuid0", 50, 50);
        _addTestVariant("small.hd", "uuid1", 100, 100);
        _addTestVariant("medium", "uuid2", 300, 300);

        ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group,
                TestPropsValues.getUserId());

        final FileEntry fileEntry = _addImageFileEntry(serviceContext);

        String value = _resolver.getValue(fileEntry, null);

        JSONObject jsonObject = JSONFactoryUtil.createJSONObject(value);

        String defaultSource = jsonObject.getString("defaultSource");

        Assert.assertEquals(DLUtil.getPreviewURL(fileEntry, fileEntry.getFileVersion(), null, StringPool.BLANK,
                false, false), defaultSource);

        JSONArray sourcesJSONArray = jsonObject.getJSONArray("sources");

        Assert.assertEquals(3, sourcesJSONArray.length());

        _assertHDSrcSource(sourcesJSONArray.getJSONObject(0), fileEntry.getFileEntryId(), "uuid0", "uuid1",
                fileEntry.getTitle());/*from  ww  w . java2 s.co  m*/
        _assertSrcSource(sourcesJSONArray.getJSONObject(1), fileEntry.getFileEntryId(), "uuid1",
                fileEntry.getTitle());
        _assertSrcSource(sourcesJSONArray.getJSONObject(2), fileEntry.getFileEntryId(), "uuid2",
                fileEntry.getTitle());

        _assertAttibutes(sourcesJSONArray.getJSONObject(0), 50, 0);
        _assertAttibutes(sourcesJSONArray.getJSONObject(1), 100, 50);
        _assertAttibutes(sourcesJSONArray.getJSONObject(2), 300, 100);
    }
}

From source file:com.liferay.adaptive.media.image.item.selector.internal.resolver.test.FileEntryAdaptiveMediaImageURLItemSelectorReturnTypeResolverTest.java

License:Open Source License

@Test
public void testAddingFileEntryWithImageCreatesMedia() throws Exception {
    try (DestinationReplacer destinationReplacer = new DestinationReplacer(
            "liferay/adaptive_media_processor")) {

        _addTestVariant("small", "uuid0", 50, 50);
        _addTestVariant("big", "uuid1", 400, 280);
        _addTestVariant("medium", "uuid2", 300, 200);
        _addTestVariant("extra", "uuid3", 500, 330);

        ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group,
                TestPropsValues.getUserId());

        final FileEntry fileEntry = _addImageFileEntry(serviceContext);

        String value = _resolver.getValue(fileEntry, null);

        JSONObject jsonObject = JSONFactoryUtil.createJSONObject(value);

        String defaultSource = jsonObject.getString("defaultSource");

        Assert.assertEquals(DLUtil.getPreviewURL(fileEntry, fileEntry.getFileVersion(), null, StringPool.BLANK,
                false, false), defaultSource);

        JSONArray sourcesJSONArray = jsonObject.getJSONArray("sources");

        Assert.assertEquals(4, sourcesJSONArray.length());

        _assertSrcSource(sourcesJSONArray.getJSONObject(0), fileEntry.getFileEntryId(), "uuid0",
                fileEntry.getTitle());/*from  w w w  .  j a  va 2s.  c om*/
        _assertSrcSource(sourcesJSONArray.getJSONObject(1), fileEntry.getFileEntryId(), "uuid2",
                fileEntry.getTitle());
        _assertSrcSource(sourcesJSONArray.getJSONObject(2), fileEntry.getFileEntryId(), "uuid1",
                fileEntry.getTitle());
        _assertSrcSource(sourcesJSONArray.getJSONObject(3), fileEntry.getFileEntryId(), "uuid3",
                fileEntry.getTitle());

        _assertAttibutes(sourcesJSONArray.getJSONObject(0), 50, 0);
        _assertAttibutes(sourcesJSONArray.getJSONObject(1), 200, 50);
        _assertAttibutes(sourcesJSONArray.getJSONObject(2), 280, 200);
        _assertAttibutes(sourcesJSONArray.getJSONObject(3), 330, 280);
    }
}