Skip to content

Commit

Permalink
LPS-112495 Test recent content info list provider
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-savinov authored and david-gutierrez-mesa committed Apr 29, 2020
1 parent ff39562 commit 5c1d14d
Showing 1 changed file with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.liferay.portal.kernel.test.util.ServiceContextTestUtil;
import com.liferay.portal.kernel.test.util.TestPropsValues;
import com.liferay.portal.kernel.util.Accessor;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.test.rule.Inject;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import com.liferay.portal.test.rule.PermissionCheckerMethodTestRule;
Expand Down Expand Up @@ -172,6 +173,49 @@ public void testMostViewedAssetsInfoListProvider() throws Exception {
_CLASS_PK_ACCESSOR.get(assetEntries.get(1)));
}

@Test
public void testRecentContentInfoListProvider() throws Exception {
InfoListProvider<AssetEntry> infoListProvider =
_infoListProviderTracker.getInfoListProvider(
_RECENT_CONTENT_INFO_LIST_PROVIDER_KEY);

JournalArticle article1 = JournalTestUtil.addArticle(
_group.getGroupId(),
JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID);

JournalArticle article2 = JournalTestUtil.addArticle(
_group.getGroupId(),
JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID);

List<AssetEntry> assetEntries = infoListProvider.getInfoList(
_infoListProviderContext);

int assetEntriesCount = infoListProvider.getInfoListCount(
_infoListProviderContext);

Assert.assertEquals(2, assetEntriesCount);

Assert.assertEquals(
Long.valueOf(article2.getResourcePrimKey()),
_CLASS_PK_ACCESSOR.get(assetEntries.get(0)));

Assert.assertEquals(
Long.valueOf(article1.getResourcePrimKey()),
_CLASS_PK_ACCESSOR.get(assetEntries.get(1)));

JournalTestUtil.updateArticle(article1, StringUtil.randomString());

assetEntries = infoListProvider.getInfoList(_infoListProviderContext);

Assert.assertEquals(
Long.valueOf(article1.getResourcePrimKey()),
_CLASS_PK_ACCESSOR.get(assetEntries.get(0)));

Assert.assertEquals(
Long.valueOf(article2.getResourcePrimKey()),
_CLASS_PK_ACCESSOR.get(assetEntries.get(1)));
}

private static final Accessor<AssetEntry, Long> _CLASS_PK_ACCESSOR =
new Accessor<AssetEntry, Long>() {

Expand Down Expand Up @@ -200,6 +244,10 @@ public Class<AssetEntry> getTypeClass() {
"com.liferay.asset.internal.info.list.provider." +
"MostViewedAssetsInfoListProvider";

private static final String _RECENT_CONTENT_INFO_LIST_PROVIDER_KEY =
"com.liferay.asset.internal.info.list.provider." +
"RecentContentInfoListProvider";

@Inject
private AssetEntryLocalService _assetEntryLocalService;

Expand Down

0 comments on commit 5c1d14d

Please sign in to comment.