From 95c3cb5ef52cb4afd799e427b0f50902645bdaee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alicia=20Garc=C3=ADa?= Date: Wed, 9 Oct 2024 17:41:43 +0200 Subject: [PATCH] LPD-38847 add test to check that the behavior is consistent when adding and updating --- .../test/JournalArticleLocalServiceTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/modules/apps/journal/journal-test/src/testIntegration/java/com/liferay/journal/service/test/JournalArticleLocalServiceTest.java b/modules/apps/journal/journal-test/src/testIntegration/java/com/liferay/journal/service/test/JournalArticleLocalServiceTest.java index 52174ed8cebad7..daf1466fba33ed 100644 --- a/modules/apps/journal/journal-test/src/testIntegration/java/com/liferay/journal/service/test/JournalArticleLocalServiceTest.java +++ b/modules/apps/journal/journal-test/src/testIntegration/java/com/liferay/journal/service/test/JournalArticleLocalServiceTest.java @@ -180,6 +180,40 @@ public void testAddArticleWithExistingExternalReferenceCode() article.getArticleId(), true); } + @Test + public void testAddArticleWithoutFriendlyURLWithTitleWithTrailingSlashes() + throws Exception { + + ServiceContext serviceContext = + ServiceContextTestUtil.getServiceContext(); + + serviceContext.setCommand(Constants.ADD); + serviceContext.setLayoutFullURL("http://localhost"); + + Locale defaultLocale = _portal.getSiteDefaultLocale( + _group.getGroupId()); + + JournalArticle journalArticle = JournalTestUtil.addArticle( + null, _group.getGroupId(), + JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, + JournalArticleConstants.CLASS_NAME_ID_DEFAULT, StringPool.BLANK, + true, + HashMapBuilder.put( + defaultLocale, "test///" + ).build(), + RandomTestUtil.randomLocaleStringMap(), Collections.emptyMap(), + RandomTestUtil.randomLocaleStringMap(), null, defaultLocale, null, + null, true, true, serviceContext); + + Map friendlyURLMap = journalArticle.getFriendlyURLMap(); + + Assert.assertFalse(friendlyURLMap.isEmpty()); + + for (Map.Entry entry : friendlyURLMap.entrySet()) { + Assert.assertEquals("test", entry.getValue()); + } + } + @Test public void testAddArticleWithURLWithURLWithConsecutiveSlashes() throws Exception {