List of usage examples for com.liferay.portal.kernel.portlet PortletPreferencesFactoryUtil getPortletSetup
public static PortletPreferences getPortletSetup(long siteGroupId, Layout layout, String portletId, String defaultPreferences)
From source file:com.liferay.exportimport.test.LayoutSetPrototypePropagationTest.java
License:Open Source License
@Test public void testPortletPreferencesPropagationWithPreferencesUniquePerLayoutEnabled() throws Exception { Portlet portlet = PortletLocalServiceUtil.getPortletById(TestPropsValues.getCompanyId(), JournalContentPortletKeys.JOURNAL_CONTENT); boolean preferencesUniquePerLayout = portlet.getPreferencesUniquePerLayout(); try {//from w ww . j a va2 s . co m portlet.setPreferencesUniquePerLayout(false); _layoutSetPrototypeLayout = LayoutTestUtil.addLayout(_layoutSetPrototypeGroup, true, layoutPrototype, true); Map<String, String[]> preferenceMap = new HashMap<>(); preferenceMap.put("bulletStyle", new String[] { "Dots" }); String testPortletId1 = LayoutTestUtil.addPortletToLayout(TestPropsValues.getUserId(), _layoutSetPrototypeLayout, JournalContentPortletKeys.JOURNAL_CONTENT, "column-1", preferenceMap); preferenceMap.put("bulletStyle", new String[] { "Arrows" }); String testPortletId2 = LayoutTestUtil.addPortletToLayout(TestPropsValues.getUserId(), _layoutSetPrototypeLayout, JournalContentPortletKeys.JOURNAL_CONTENT, "column-2", preferenceMap); propagateChanges(group); Layout layout = LayoutLocalServiceUtil.getFriendlyURLLayout(group.getGroupId(), false, _layoutSetPrototypeLayout.getFriendlyURL()); PortletPreferences testPortletIdPortletPreferences = PortletPreferencesFactoryUtil .getPortletSetup(group.getGroupId(), layout, JournalContentPortletKeys.JOURNAL_CONTENT, null); Assert.assertEquals("Arrows", testPortletIdPortletPreferences.getValue("bulletStyle", StringPool.BLANK)); PortletPreferences testPortletId1PortletPreferences = PortletPreferencesFactoryUtil .getPortletSetup(layout, testPortletId1, null); Assert.assertEquals("Arrows", testPortletId1PortletPreferences.getValue("bulletStyle", StringPool.BLANK)); PortletPreferences testPortletId2PortletPreferences = PortletPreferencesFactoryUtil .getPortletSetup(layout, testPortletId2, null); Assert.assertEquals("Arrows", testPortletId2PortletPreferences.getValue("bulletStyle", StringPool.BLANK)); } finally { portlet.setPreferencesUniquePerLayout(preferencesUniquePerLayout); } }