Example usage for com.liferay.portal.kernel.model Portlet getPreferencesUniquePerLayout

List of usage examples for com.liferay.portal.kernel.model Portlet getPreferencesUniquePerLayout

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Portlet getPreferencesUniquePerLayout.

Prototype

public boolean getPreferencesUniquePerLayout();

Source Link

Document

Returns true if preferences are unique per layout.

Usage

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 ww w  . ja  v a 2 s.  c  o 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);
    }
}