Skip to content

Commit

Permalink
LPD-39772 Migrates to integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
ealonso authored and brianchandotcom committed Oct 20, 2024
1 parent 511f4da commit b3033ae
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import com.liferay.asset.kernel.model.AssetCategory;
import com.liferay.asset.kernel.model.AssetVocabulary;
import com.liferay.asset.kernel.service.AssetCategoryLocalService;
import com.liferay.asset.list.constants.AssetListEntryTypeConstants;
import com.liferay.asset.list.model.AssetListEntry;
import com.liferay.asset.list.service.AssetListEntryLocalService;
import com.liferay.asset.test.util.AssetTestUtil;
import com.liferay.client.extension.constants.ClientExtensionEntryConstants;
import com.liferay.client.extension.model.ClientExtensionEntry;
Expand Down Expand Up @@ -44,11 +47,13 @@
import com.liferay.info.form.InfoForm;
import com.liferay.info.item.InfoItemServiceRegistry;
import com.liferay.info.item.provider.InfoItemFormProvider;
import com.liferay.item.selector.criteria.InfoListItemSelectorReturnType;
import com.liferay.journal.constants.JournalArticleConstants;
import com.liferay.journal.constants.JournalFolderConstants;
import com.liferay.journal.model.JournalArticle;
import com.liferay.journal.service.JournalArticleLocalService;
import com.liferay.journal.test.util.JournalTestUtil;
import com.liferay.layout.constants.LayoutTypeSettingsConstants;
import com.liferay.layout.page.template.constants.LayoutPageTemplateEntryTypeConstants;
import com.liferay.layout.page.template.model.LayoutPageTemplateEntry;
import com.liferay.layout.page.template.service.LayoutPageTemplateEntryLocalService;
Expand All @@ -70,6 +75,7 @@
import com.liferay.portal.kernel.model.Company;
import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.model.Layout;
import com.liferay.portal.kernel.model.LayoutConstants;
import com.liferay.portal.kernel.model.LayoutFriendlyURL;
import com.liferay.portal.kernel.model.PortletPreferencesIds;
import com.liferay.portal.kernel.model.StagedModel;
Expand All @@ -79,6 +85,7 @@
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.security.permission.ResourceActions;
import com.liferay.portal.kernel.service.CompanyLocalService;
import com.liferay.portal.kernel.service.GroupLocalService;
import com.liferay.portal.kernel.service.LayoutFriendlyURLLocalService;
import com.liferay.portal.kernel.service.LayoutLocalService;
import com.liferay.portal.kernel.service.PortletPreferencesLocalService;
Expand Down Expand Up @@ -650,6 +657,85 @@ public void testStyleBookEntry() throws Exception {
importedLayout.getStyleBookEntryId()));
}

@Test
@TestInfo("LPS-139864")
public void testTypeCollectionLayout() throws Exception {
Group group = GroupTestUtil.addGroup();

AssetListEntry assetListEntry =
_assetListEntryLocalService.addAssetListEntry(
RandomTestUtil.randomString(), TestPropsValues.getUserId(),
group.getGroupId(), RandomTestUtil.randomString(),
AssetListEntryTypeConstants.TYPE_MANUAL,
ServiceContextTestUtil.getServiceContext(group.getGroupId()));

Layout layout = _layoutLocalService.addLayout(
null, TestPropsValues.getUserId(), group.getGroupId(), false,
LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, 0, 0,
RandomTestUtil.randomLocaleStringMap(), null,
Collections.emptyMap(), Collections.emptyMap(),
Collections.emptyMap(), LayoutConstants.TYPE_COLLECTION,
UnicodePropertiesBuilder.put(
LayoutTypeSettingsConstants.KEY_PUBLISHED, "true"
).put(
"collectionPK", assetListEntry.getAssetListEntryId()
).put(
"collectionType", InfoListItemSelectorReturnType.class.getName()
).buildString(),
false, false, Collections.emptyMap(), 0,
ServiceContextTestUtil.getServiceContext(group.getGroupId()));

StagingLocalServiceUtil.enableLocalStaging(
TestPropsValues.getUserId(), group, true, false,
ServiceContextTestUtil.getServiceContext(group.getGroupId()));

Group stagingGroup = group.getStagingGroup();

AssetListEntry stagingGroupAssetListEntry =
_assetListEntryLocalService.fetchAssetListEntryByUuidAndGroupId(
assetListEntry.getUuid(), stagingGroup.getGroupId());

Layout stagingGroupLayout =
_layoutLocalService.fetchLayoutByUuidAndGroupId(
layout.getUuid(), stagingGroup.getGroupId(), false);

UnicodeProperties stagingGroupLayoutTypeSettingsUnicodeProperties =
stagingGroupLayout.getTypeSettingsProperties();

Assert.assertEquals(
stagingGroupAssetListEntry.getAssetListEntryId(),
GetterUtil.getLong(
stagingGroupLayoutTypeSettingsUnicodeProperties.getProperty(
"collectionPK")));
Assert.assertEquals(
stagingGroupLayoutTypeSettingsUnicodeProperties.getProperty(
"collectionType"),
InfoListItemSelectorReturnType.class.getName());

AssetListEntry liveGroupAssetListEntry =
_assetListEntryLocalService.fetchAssetListEntryByUuidAndGroupId(
assetListEntry.getUuid(), group.getGroupId());

Layout liveGroupLayout =
_layoutLocalService.fetchLayoutByUuidAndGroupId(
layout.getUuid(), group.getGroupId(), false);

UnicodeProperties liveGroupLayoutTypeSettingsUnicodeProperties =
liveGroupLayout.getTypeSettingsProperties();

Assert.assertEquals(
liveGroupAssetListEntry.getAssetListEntryId(),
GetterUtil.getLong(
liveGroupLayoutTypeSettingsUnicodeProperties.getProperty(
"collectionPK")));
Assert.assertEquals(
liveGroupLayoutTypeSettingsUnicodeProperties.getProperty(
"collectionType"),
InfoListItemSelectorReturnType.class.getName());

_groupLocalService.deleteGroup(group);
}

@Test
public void testTypeLinkToLayout() throws Exception {
initExport();
Expand Down Expand Up @@ -1581,6 +1667,9 @@ private LayoutSEOEntry _updateLayoutSEOEntry(Layout layout)
@Inject
private AssetCategoryLocalService _assetCategoryLocalService;

@Inject
private AssetListEntryLocalService _assetListEntryLocalService;

@Inject
private BackgroundTaskLocalService _backgroundTaskLocalService;

Expand Down Expand Up @@ -1615,6 +1704,9 @@ private LayoutSEOEntry _updateLayoutSEOEntry(Layout layout)
@Inject
private FriendlyURLEntryLocalService _friendlyURLEntryLocalService;

@Inject
private GroupLocalService _groupLocalService;

@Inject
private InfoItemServiceRegistry _infoItemServiceRegistry;

Expand Down

This file was deleted.

0 comments on commit b3033ae

Please sign in to comment.