From 43f7bdec88bcf2ba76bf7c00515a6c5fb62f56c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20P=C3=A9rez=20=C3=81lvarez?= Date: Tue, 3 Dec 2024 14:25:54 +0100 Subject: [PATCH] LPD-43352 Integration test --- .../DDMFieldAttributeUpgradeProcessTest.java | 46 +++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/modules/apps/dynamic-data-mapping/dynamic-data-mapping-test/src/testIntegration/java/com/liferay/dynamic/data/mapping/internal/upgrade/v5_6_1/test/DDMFieldAttributeUpgradeProcessTest.java b/modules/apps/dynamic-data-mapping/dynamic-data-mapping-test/src/testIntegration/java/com/liferay/dynamic/data/mapping/internal/upgrade/v5_6_1/test/DDMFieldAttributeUpgradeProcessTest.java index f1e8ca68c9af4a..59b2b8561f4594 100644 --- a/modules/apps/dynamic-data-mapping/dynamic-data-mapping-test/src/testIntegration/java/com/liferay/dynamic/data/mapping/internal/upgrade/v5_6_1/test/DDMFieldAttributeUpgradeProcessTest.java +++ b/modules/apps/dynamic-data-mapping/dynamic-data-mapping-test/src/testIntegration/java/com/liferay/dynamic/data/mapping/internal/upgrade/v5_6_1/test/DDMFieldAttributeUpgradeProcessTest.java @@ -13,10 +13,12 @@ import com.liferay.document.library.util.DLURLHelperUtil; import com.liferay.dynamic.data.mapping.service.DDMStructureLocalService; import com.liferay.dynamic.data.mapping.test.util.DDMStructureTestUtil; +import com.liferay.exportimport.kernel.lar.ExportImportThreadLocal; import com.liferay.journal.model.JournalArticle; import com.liferay.journal.service.JournalArticleLocalService; import com.liferay.journal.test.util.JournalTestUtil; import com.liferay.petra.io.unsync.UnsyncByteArrayInputStream; +import com.liferay.petra.string.StringBundler; import com.liferay.petra.string.StringPool; import com.liferay.portal.kernel.cache.MultiVMPool; import com.liferay.portal.kernel.dao.orm.EntityCache; @@ -74,6 +76,8 @@ public void testUpgradeProcess() throws Exception { _assertContains( journalArticle.getContent(), "data-fileentryid=\"" + _dlFileEntry.getFileEntryId() + "\""); + _assertContains( + journalArticle.getContent(), "/documents/d/orphan/document"); } private void _addDLFileEntry() throws Exception { @@ -91,19 +95,35 @@ null, new UnsyncByteArrayInputStream(new byte[0]), 0, null, null, } private void _addJournalArticle() throws Exception { - String previewURL = DLURLHelperUtil.getPreviewURL( - new LiferayFileEntry(_dlFileEntry), - new LiferayFileVersion(_dlFileEntry.getFileVersion()), null, null); - - _journalArticle = JournalTestUtil.addArticleWithXMLContent( - DDMStructureTestUtil.getSampleStructuredContent( - "content", - Collections.singletonList( - HashMapBuilder.put( - LocaleUtil.US, "" - ).build()), - LanguageUtil.getLanguageId(LocaleUtil.US)), - "BASIC-WEB-CONTENT", "BASIC-WEB-CONTENT"); + boolean portletImportInProcess = + ExportImportThreadLocal.isPortletImportInProcess(); + + try { + ExportImportThreadLocal.setPortletImportInProcess(true); + + _journalArticle = JournalTestUtil.addArticleWithXMLContent( + DDMStructureTestUtil.getSampleStructuredContent( + "content", + Collections.singletonList( + HashMapBuilder.put( + LocaleUtil.US, + StringBundler.concat( + "") + ).build()), + LanguageUtil.getLanguageId(LocaleUtil.US)), + "BASIC-WEB-CONTENT", "BASIC-WEB-CONTENT"); + } + finally { + ExportImportThreadLocal.setPortletImportInProcess( + portletImportInProcess); + } } private void _assertContains(String content, String fragment) {