protected void doTestPortletPreferencesPropagation(boolean linkEnabled, boolean globalScope)
      throws Exception {

    setLinkEnabled(linkEnabled);

    PortletPreferences layoutSetPrototypePortletPreferences =
        LayoutTestUtil.getPortletPreferences(prototypeLayout, journalContentPortletId);

    MergeLayoutPrototypesThreadLocal.clearMergeComplete();

    layoutSetPrototypePortletPreferences.setValue("articleId", StringPool.BLANK);

    layoutSetPrototypePortletPreferences.setValue("showAvailableLocales", Boolean.FALSE.toString());

    if (globalScope) {
      layoutSetPrototypePortletPreferences.setValue("groupId", String.valueOf(globalGroupId));
      layoutSetPrototypePortletPreferences.setValue("lfrScopeType", "company");
    }

    layoutSetPrototypePortletPreferences.store();

    layout = propagateChanges(layout);

    PortletPreferences portletPreferences =
        LayoutTestUtil.getPortletPreferences(layout, journalContentPortletId);

    if (linkEnabled) {
      if (globalScope) {
        Assert.assertEquals(
            StringPool.BLANK, portletPreferences.getValue("articleId", StringPool.BLANK));
      } else {

        // Changes in preferences of local ids are not propagated

        Assert.assertEquals(
            journalArticle.getArticleId(),
            portletPreferences.getValue("articleId", StringPool.BLANK));
      }

      Assert.assertEquals(
          Boolean.FALSE.toString(),
          portletPreferences.getValue("showAvailableLocales", StringPool.BLANK));
    } else {
      Assert.assertEquals(
          journalArticle.getArticleId(),
          portletPreferences.getValue("articleId", StringPool.BLANK));
    }
  }
  protected Layout propagateChanges(Layout layout) throws Exception {
    MergeLayoutPrototypesThreadLocal.clearMergeComplete();

    return LayoutLocalServiceUtil.getLayout(layout.getPlid());
  }