Skip to content

Commit

Permalink
LPD-43352 Integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfopa authored and nikki-pru committed Dec 9, 2024
1 parent 0615e45 commit 43f7bde
Showing 1 changed file with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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, "<img src=\"" + previewURL + "\"/>"
).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(
"<img src=\"",
DLURLHelperUtil.getPreviewURL(
new LiferayFileEntry(_dlFileEntry),
new LiferayFileVersion(
_dlFileEntry.getFileVersion()),
null, null),
"\"/><img src=\"/documents/d/orphan/document\"",
"/>")
).build()),
LanguageUtil.getLanguageId(LocaleUtil.US)),
"BASIC-WEB-CONTENT", "BASIC-WEB-CONTENT");
}
finally {
ExportImportThreadLocal.setPortletImportInProcess(
portletImportInProcess);
}
}

private void _assertContains(String content, String fragment) {
Expand Down

0 comments on commit 43f7bde

Please sign in to comment.