List of usage examples for com.liferay.portal.kernel.test.util GroupTestUtil updateDisplaySettings
public static Group updateDisplaySettings(long groupId, Collection<Locale> availableLocales, Locale defaultLocale) throws Exception
From source file:com.liferay.document.library.search.test.DLFileEntryIndexerLocalizedContentTest.java
License:Open Source License
@Test public void testJapaneseContent() throws Exception { GroupTestUtil.updateDisplaySettings(_group.getGroupId(), null, LocaleUtil.JAPAN); addFileEntry("content_search.txt"); List<String> contentStrings = new ArrayList<>(Collections.singletonList("content_ja_JP")); String word1 = "?"; String word2 = "?"; String prefix1 = ""; String prefix2 = ""; Stream<String> searchTerms = Stream.of(word1, word2, prefix1, prefix2); searchTerms.forEach(searchTerm -> { Document document = _search(searchTerm, LocaleUtil.JAPAN); assertLocalization(contentStrings, document); });/*from ww w . j ava 2 s . co m*/ }
From source file:com.liferay.document.library.search.test.DLFileEntryIndexerLocalizedContentTest.java
License:Open Source License
@Test public void testJapaneseContentFullWordOnly() throws Exception { GroupTestUtil.updateDisplaySettings(_group.getGroupId(), null, LocaleUtil.JAPAN); addFileEntry("japanese_1.txt"); addFileEntry("japanese_2.txt"); addFileEntry("japanese_3.txt"); List<String> contentStrings = new ArrayList<>(Collections.singletonList("content_ja_JP")); String word1 = "?"; String word2 = "?"; Stream<String> searchTerms = Stream.of(word1, word2); searchTerms.forEach(searchTerm -> { Document document = _search(searchTerm, LocaleUtil.JAPAN); assertLocalization(contentStrings, document); });/*from w w w .j a v a 2 s . c om*/ }
From source file:com.liferay.document.library.search.test.DLFileEntryIndexerLocalizedContentTest.java
License:Open Source License
@Test public void testSiteLocale() throws Exception { Group testGroup = GroupTestUtil.addGroup(); List<String> japaneseContentStrings = new ArrayList<>(Collections.singletonList("content_ja_JP")); List<String> englishContentStrings = new ArrayList<>(Collections.singletonList("content_en_US")); try {/*from w w w . ja va 2 s . com*/ GroupTestUtil.updateDisplaySettings(_group.getGroupId(), null, LocaleUtil.JAPAN); GroupTestUtil.updateDisplaySettings(testGroup.getGroupId(), null, LocaleUtil.US); addFileEntry("locale_ja.txt", _group.getGroupId()); addFileEntry("locale_en.txt", testGroup.getGroupId()); Document japenseDocument = _search("?", LocaleUtil.JAPAN, _group.getGroupId()); assertLocalization(japaneseContentStrings, japenseDocument); Document englishDocument = _search("Locale Test", LocaleUtil.ENGLISH, testGroup.getGroupId()); assertLocalization(englishContentStrings, englishDocument); } finally { GroupLocalServiceUtil.deleteGroup(testGroup); } }
From source file:com.liferay.exportimport.test.LayoutExportImportTest.java
License:Open Source License
protected void testAvailableLocales(Collection<Locale> sourceAvailableLocales, Collection<Locale> targetAvailableLocales, boolean expectFailure) throws Exception { group = GroupTestUtil.updateDisplaySettings(group.getGroupId(), sourceAvailableLocales, null); importedGroup = GroupTestUtil.updateDisplaySettings(importedGroup.getGroupId(), targetAvailableLocales, null);//from ww w .j a va2 s . co m LayoutTestUtil.addLayout(group); long[] layoutIds = new long[0]; try { exportImportLayouts(layoutIds, getImportParameterMap()); Assert.assertFalse(expectFailure); } catch (LocaleException le) { Assert.assertTrue(expectFailure); } }
From source file:com.liferay.exportimport.test.util.lar.BasePortletExportImportTestCase.java
License:Open Source License
protected void testExportImportAvailableLocales(Collection<Locale> sourceAvailableLocales, Collection<Locale> targetAvailableLocales, boolean expectFailure) throws Exception { Portlet portlet = PortletLocalServiceUtil.getPortletById(group.getCompanyId(), getPortletId()); if (portlet == null) { return;//w w w . j av a 2 s. co m } PortletDataHandler portletDataHandler = portlet.getPortletDataHandlerInstance(); if (!portletDataHandler.isDataLocalized()) { Assert.assertTrue("This test does not apply", true); return; } GroupTestUtil.updateDisplaySettings(group.getGroupId(), sourceAvailableLocales, null); GroupTestUtil.updateDisplaySettings(importedGroup.getGroupId(), targetAvailableLocales, null); try { exportImportPortlet(getPortletId()); Assert.assertFalse(expectFailure); } catch (LocaleException le) { Assert.assertTrue(expectFailure); } }
From source file:com.liferay.layout.service.test.LayoutFriendlyURLServiceTest.java
License:Open Source License
@Test public void testLocalizedSiteAddLayoutFriendlyURLs() throws Exception { List<Locale> availableLocales = Arrays.asList(LocaleUtil.US, LocaleUtil.SPAIN); _group = GroupTestUtil.updateDisplaySettings(_group.getGroupId(), availableLocales, LocaleUtil.SPAIN); Map<Locale, String> nameMap = new HashMap<>(); String name = RandomTestUtil.randomString(); nameMap.put(LocaleUtil.GERMANY, name); nameMap.put(LocaleUtil.US, name);//from w w w. ja va 2s . c o m nameMap.put(LocaleUtil.SPAIN, name); Map<Locale, String> friendlyURLMap = new HashMap<>(); friendlyURLMap.put(LocaleUtil.GERMANY, "/germanurl"); friendlyURLMap.put(LocaleUtil.SPAIN, "/spanishurl"); friendlyURLMap.put(LocaleUtil.US, "/englishurl"); Layout layout = LayoutTestUtil.addLayout(_group.getGroupId(), false, nameMap, friendlyURLMap); List<LayoutFriendlyURL> layoutFriendlyURLs = LayoutFriendlyURLLocalServiceUtil .getLayoutFriendlyURLs(layout.getPlid()); Assert.assertEquals(layoutFriendlyURLs.toString(), availableLocales.size(), layoutFriendlyURLs.size()); String[] availableLanguageIds = LocaleUtil.toLanguageIds(availableLocales); for (LayoutFriendlyURL layoutFriendlyURL : layoutFriendlyURLs) { Assert.assertTrue(ArrayUtil.contains(availableLanguageIds, layoutFriendlyURL.getLanguageId())); } }
From source file:com.liferay.layout.service.test.LayoutFriendlyURLServiceTest.java
License:Open Source License
@Test public void testLocalizedSiteFetchLayoutFriendlyURL() throws Exception { List<Locale> availableLocales = Arrays.asList(LocaleUtil.US, LocaleUtil.SPAIN); Locale defaultLocale = LocaleUtil.SPAIN; _group = GroupTestUtil.updateDisplaySettings(_group.getGroupId(), availableLocales, defaultLocale); Map<Locale, String> nameMap = new HashMap<>(); String name = RandomTestUtil.randomString(); nameMap.put(LocaleUtil.SPAIN, name); nameMap.put(LocaleUtil.US, name);//from www .j a v a2 s . co m Map<Locale, String> friendlyURLMap = new HashMap<>(); friendlyURLMap.put(LocaleUtil.SPAIN, "/spanishurl"); friendlyURLMap.put(LocaleUtil.US, "/englishurl"); Layout layout = LayoutTestUtil.addLayout(_group.getGroupId(), false, nameMap, friendlyURLMap); Locale locale = LocaleThreadLocal.getSiteDefaultLocale(); try { LocaleThreadLocal.setSiteDefaultLocale(defaultLocale); LayoutFriendlyURL layoutFriendlyURL = LayoutFriendlyURLLocalServiceUtil .fetchLayoutFriendlyURL(layout.getPlid(), LocaleUtil.toLanguageId(LocaleUtil.GERMANY), true); Assert.assertEquals("/spanishurl", layoutFriendlyURL.getFriendlyURL()); Assert.assertEquals(LocaleUtil.toLanguageId(defaultLocale), layoutFriendlyURL.getLanguageId()); } finally { LocaleThreadLocal.setSiteDefaultLocale(locale); } }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testUpdateAvailableLocales() throws Exception { Group group = GroupTestUtil.addGroup(); try {//from w w w. j a v a 2 s . co m List<Locale> availableLocales = Arrays.asList(LocaleUtil.GERMANY, LocaleUtil.SPAIN, LocaleUtil.US); group = GroupTestUtil.updateDisplaySettings(group.getGroupId(), availableLocales, null); Assert.assertEquals(new HashSet<>(availableLocales), LanguageUtil.getAvailableLocales(group.getGroupId())); } finally { GroupLocalServiceUtil.deleteGroup(group); } }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testUpdateDefaultLocale() throws Exception { Group group = GroupTestUtil.addGroup(); try {/*from ww w.jav a2s .com*/ group = GroupTestUtil.updateDisplaySettings(group.getGroupId(), null, LocaleUtil.SPAIN); Assert.assertEquals(LocaleUtil.SPAIN, PortalUtil.getSiteDefaultLocale(group.getGroupId())); } finally { GroupLocalServiceUtil.deleteGroup(group); } }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
protected void testUpdateDisplaySettings(Collection<Locale> portalAvailableLocales, Collection<Locale> groupAvailableLocales, Locale groupDefaultLocale, boolean expectFailure) throws Exception { Set<Locale> availableLocales = LanguageUtil.getAvailableLocales(); CompanyTestUtil.resetCompanyLocales(TestPropsValues.getCompanyId(), portalAvailableLocales, LocaleUtil.getDefault());//from w ww . j a va 2s. com Group group = GroupTestUtil.addGroup(GroupConstants.DEFAULT_PARENT_GROUP_ID); try { GroupTestUtil.updateDisplaySettings(group.getGroupId(), groupAvailableLocales, groupDefaultLocale); Assert.assertFalse(expectFailure); } catch (LocaleException le) { Assert.assertTrue(expectFailure); } finally { CompanyTestUtil.resetCompanyLocales(TestPropsValues.getCompanyId(), availableLocales, LocaleUtil.getDefault()); } GroupLocalServiceUtil.deleteGroup(group); }