List of usage examples for com.liferay.portal.kernel.util LocaleUtil US
Locale US
To view the source code for com.liferay.portal.kernel.util LocaleUtil US.
Click Source Link
From source file:com.liferay.asset.publisher.portlet.test.DisplayPageFriendlyURLResolverTest.java
License:Open Source License
@Test public void testJournalArticleFriendlyURL() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(); LayoutLocalServiceUtil.addLayout(TestPropsValues.getUserId(), _group.getGroupId(), false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "Home", StringPool.BLANK, StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, StringPool.BLANK, serviceContext); Layout layout = LayoutLocalServiceUtil.addLayout(TestPropsValues.getUserId(), _group.getGroupId(), false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "Test " + RandomTestUtil.nextInt(), StringPool.BLANK, StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, StringPool.BLANK, serviceContext); LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); String portletId = layoutTypePortlet.addPortletId(TestPropsValues.getUserId(), AssetPublisherPortletKeys.ASSET_PUBLISHER, "column-1", 0); layoutTypePortlet.setTypeSettingsProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID, portletId);//w ww . ja v a2 s.c o m layout = LayoutLocalServiceUtil.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings()); Map<Locale, String> titleMap = new HashMap<>(); titleMap.put(LocaleUtil.US, "Test Journal Article"); Map<Locale, String> contentMap = new HashMap<>(); contentMap.put(LocaleUtil.US, "This test content is in English."); JournalTestUtil.addArticle(_group.getGroupId(), JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, JournalArticleConstants.CLASSNAME_ID_DEFAULT, titleMap, titleMap, contentMap, layout.getUuid(), LocaleUtil.US, null, false, false, serviceContext); String actualURL = PortalUtil.getActualURL(_group.getGroupId(), false, Portal.PATH_MAIN, "/-/test-journal-article", new HashMap<String, String[]>(), getRequestContext()); Assert.assertNotNull(actualURL); try { PortalUtil.getActualURL(_group.getGroupId(), false, Portal.PATH_MAIN, "/-/nonexistent-test-journal-article", new HashMap<String, String[]>(), getRequestContext()); Assert.fail(); } catch (NoSuchLayoutException nsle) { } }
From source file:com.liferay.asset.service.test.AssetCategoryLocalServiceTest.java
License:Open Source License
@Test public void testDeleteCategory() throws Exception { Map<Locale, String> titleMap = new HashMap<>(); titleMap.put(LocaleUtil.US, RandomTestUtil.randomString()); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId()); AssetVocabulary assetVocabulary = AssetVocabularyLocalServiceUtil.addVocabulary(TestPropsValues.getUserId(), _group.getGroupId(), RandomTestUtil.randomString(), titleMap, null, null, serviceContext); AssetCategory assetCategory = AssetCategoryLocalServiceUtil.addCategory(TestPropsValues.getUserId(), _group.getGroupId(), RandomTestUtil.randomString(), assetVocabulary.getVocabularyId(), serviceContext);//from w w w .j ava 2s . c o m serviceContext.setAssetCategoryIds(new long[] { assetCategory.getCategoryId() }); _organization = OrganizationLocalServiceUtil.addOrganization(TestPropsValues.getUserId(), OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, RandomTestUtil.randomString(), OrganizationConstants.TYPE_ORGANIZATION, 0, 0, ListTypeConstants.ORGANIZATION_STATUS_DEFAULT, RandomTestUtil.randomString(), true, serviceContext); TestAssetIndexer testAssetIndexer = new TestAssetIndexer(); testAssetIndexer.setExpectedValues(Organization.class.getName(), _organization.getOrganizationId()); if (_organizationIndexer == null) { _organizationIndexer = IndexerRegistryUtil.getIndexer(Organization.class); } IndexerRegistryUtil.register(testAssetIndexer); AssetCategoryLocalServiceUtil.deleteCategory(assetCategory, true); }
From source file:com.liferay.asset.service.test.AssetVocabularyServiceTest.java
License:Open Source License
@Test public void testLocalizedSiteAddDefaultVocabulary() throws Exception { LocaleThreadLocal.setSiteDefaultLocale(LocaleUtil.SPAIN); AssetVocabulary vocabulary = AssetVocabularyLocalServiceUtil.addDefaultVocabulary(_group.getGroupId()); Assert.assertEquals(PropsValues.ASSET_VOCABULARY_DEFAULT, vocabulary.getTitle(LocaleUtil.US, true)); }
From source file:com.liferay.asset.service.test.AssetVocabularyServiceTest.java
License:Open Source License
@Test public void testLocalizedSiteAddLocalizedVocabulary() throws Exception { LocaleThreadLocal.setSiteDefaultLocale(LocaleUtil.SPAIN); String title = RandomTestUtil.randomString(); Map<Locale, String> titleMap = new HashMap<>(); titleMap.put(LocaleUtil.US, title + "_US"); titleMap.put(LocaleUtil.SPAIN, title + "_ES"); String description = RandomTestUtil.randomString(); Map<Locale, String> descriptionMap = new HashMap<>(); descriptionMap.put(LocaleUtil.SPAIN, description + "_ES"); descriptionMap.put(LocaleUtil.US, description + "_US"); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); AssetVocabulary vocabulary = AssetVocabularyLocalServiceUtil.addVocabulary(TestPropsValues.getUserId(), _group.getGroupId(), StringPool.BLANK, titleMap, descriptionMap, StringPool.BLANK, serviceContext); Assert.assertEquals(titleMap.get(LocaleUtil.SPAIN), vocabulary.getName()); Assert.assertEquals(titleMap.get(LocaleUtil.SPAIN), vocabulary.getTitle(LocaleUtil.GERMANY, true)); Assert.assertEquals(titleMap.get(LocaleUtil.SPAIN), vocabulary.getTitle(LocaleUtil.SPAIN, true)); Assert.assertEquals(titleMap.get(LocaleUtil.US), vocabulary.getTitle(LocaleUtil.US, true)); Assert.assertEquals(descriptionMap.get(LocaleUtil.SPAIN), vocabulary.getDescription(LocaleUtil.GERMANY, true)); Assert.assertEquals(descriptionMap.get(LocaleUtil.SPAIN), vocabulary.getDescription(LocaleUtil.SPAIN, true)); Assert.assertEquals(descriptionMap.get(LocaleUtil.US), vocabulary.getDescription(LocaleUtil.US, true)); }
From source file:com.liferay.asset.service.test.AssetVocabularyServiceTest.java
License:Open Source License
@Test public void testLocalizedSiteAddVocabulary() throws Exception { LocaleThreadLocal.setSiteDefaultLocale(LocaleUtil.SPAIN); String title = RandomTestUtil.randomString(); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); AssetVocabulary vocabulary = AssetVocabularyLocalServiceUtil.addVocabulary(TestPropsValues.getUserId(), serviceContext.getScopeGroupId(), title, serviceContext); Assert.assertEquals(title, vocabulary.getTitle(LocaleUtil.US, true)); Assert.assertEquals(title, vocabulary.getName()); }
From source file:com.liferay.calendar.search.test.CalendarBookingIndexerIndexedFieldsTest.java
License:Open Source License
@Test public void testIndexedFields() throws Exception { String originalTitle = "entity title"; String translatedTitle = "entitas neve"; String description = StringUtil.toLowerCase(RandomTestUtil.randomString()); CalendarBooking calendarBooking = addCalendarBooking(new LocalizedValuesMap() { {/* ww w . j a va 2 s.co m*/ put(LocaleUtil.US, originalTitle); put(LocaleUtil.HUNGARY, translatedTitle); } }, new LocalizedValuesMap() { { put(LocaleUtil.US, originalTitle); put(LocaleUtil.HUNGARY, translatedTitle); } }, new LocalizedValuesMap() { { put(LocaleUtil.US, description); put(LocaleUtil.HUNGARY, description); } }); Map<String, String> map = new HashMap<>(); map.put(Field.CLASS_NAME_ID, String.valueOf(portal.getClassNameId(Calendar.class))); map.put(Field.EXPIRATION_DATE, "99950812133000"); map.put(Field.EXPIRATION_DATE.concat("_sortable"), "9223372036854775807"); map.put(Field.PRIORITY, "0.0"); map.put(Field.PUBLISH_DATE, "19700101000000"); map.put(Field.PUBLISH_DATE.concat("_sortable"), "0"); map.put(Field.RELATED_ENTRY, "true"); map.put(Field.STAGING_GROUP, "false"); map.put(Field.STATUS, "0"); map.put("viewActionId", CalendarActionKeys.VIEW_BOOKING_DETAILS); populateTitle(originalTitle, map); populateTranslatedTitle(translatedTitle, map); CalendarResource calendarResource = calendarBooking.getCalendarResource(); populateCalendarResource(calendarResource, map); Calendar calendar = calendarResource.getDefaultCalendar(); populateCalendar(calendar, map); populateCalendarBooking(calendarBooking, map); DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat("yyyyMMddHHmm"); populateCalendarDate(Field.CREATE_DATE, calendar.getCreateDate(), dateFormat, map); populateCalendarDate(Field.MODIFIED_DATE, calendar.getModifiedDate(), dateFormat, map); calendarFieldsFixture.populateGroupRoleId(map); calendarFieldsFixture.populateRoleId("Owner", map); calendarFieldsFixture.populateUID(calendarBooking, map); String keywords = "nev"; Document document = calendarSearchFixture.searchOnlyOne(keywords, LocaleUtil.HUNGARY); adjustDatePrecision(Field.CREATE_DATE, document, dateFormat); adjustDatePrecision(Field.MODIFIED_DATE, document, dateFormat); FieldValuesAssert.assertFieldValues(map, document, keywords); }
From source file:com.liferay.calendar.search.test.CalendarBookingIndexerLocalizedContentTest.java
License:Open Source License
@Test public void testJapaneseTitle() throws Exception { String originalName = "entity name"; String japaneseName = "??"; String description = StringUtil.toLowerCase(RandomTestUtil.randomString()); addCalendarBooking(new LocalizedValuesMap() { {//ww w . j a v a 2s .c o m put(LocaleUtil.US, originalName); put(LocaleUtil.JAPAN, japaneseName); } }, new LocalizedValuesMap() { { put(LocaleUtil.US, originalName); put(LocaleUtil.JAPAN, japaneseName); } }, new LocalizedValuesMap() { { put(LocaleUtil.US, description); put(LocaleUtil.JAPAN, description); } }); Map<String, String> titleMap = new HashMap<String, String>() { { put("title_en_US", originalName); put("title_ja_JP", japaneseName); } }; String word1 = "?"; String word2 = "?"; String prefix1 = ""; String prefix2 = ""; Stream<String> stream = Stream.of(word1, word2, prefix1, prefix2); stream.forEach(keywords -> assertFieldValues("title", LocaleUtil.JAPAN, titleMap, keywords)); }
From source file:com.liferay.calendar.search.test.CalendarBookingIndexerLocalizedContentTest.java
License:Open Source License
@Test public void testJapaneseTitleFullWordOnly() throws Exception { String full = "??"; String partial1 = ""; String partial2 = "?"; Stream<String> titlesStream = Stream.of(full, partial1, partial2); String description = StringUtil.toLowerCase(RandomTestUtil.randomString()); titlesStream.forEach(title -> {// w ww . j a v a 2 s . co m addCalendarBooking(new LocalizedValuesMap() { { put(LocaleUtil.JAPAN, title); } }, new LocalizedValuesMap() { { put(LocaleUtil.US, description); put(LocaleUtil.HUNGARY, description); } }, new LocalizedValuesMap() { { put(LocaleUtil.US, description); put(LocaleUtil.HUNGARY, description); } }); }); Map<String, String> titleMap = new HashMap<String, String>() { { put("title_ja_JP", "??"); } }; String word1 = "?"; String word2 = "?"; Stream<String> keywordsStream = Stream.of(word1, word2); keywordsStream.forEach(keywords -> assertFieldValues("title", LocaleUtil.JAPAN, titleMap, keywords)); }
From source file:com.liferay.calendar.search.test.CalendarBookingIndexerTest.java
License:Open Source License
@Test public void testIndexedFields() throws Exception { setUpSearchContext(_group, TestPropsValues.getUser()); String originalTitle = "entity title"; String translatedTitle = "entitas neve"; addCalendarBooking(new LocalizedValuesMap() { {//from ww w .j a v a 2 s. c o m put(LocaleUtil.US, originalTitle); put(LocaleUtil.HUNGARY, translatedTitle); } }); String searchTerm = "nev"; assertSearchHitsLength(searchTerm, 1, LocaleUtil.HUNGARY); }
From source file:com.liferay.calendar.search.test.CalendarBookingIndexerTest.java
License:Open Source License
@Test public void testSearch() throws Exception { setUpSearchContext(_group, TestPropsValues.getUser()); String title = RandomTestUtil.randomString(); addCalendarBooking(new LocalizedValuesMap() { {/*from w ww . j av a2s. co m*/ put(LocaleUtil.US, title); } }); assertSearchHitsLength(title, 1, LocaleUtil.US); }