@Test public void testGetPortletDataHandlerPortlets() throws Exception { LayoutTestUtil.addPortletToLayout(layout, PortletKeys.BOOKMARKS); LayoutTestUtil.addPortletToLayout(layout, PortletKeys.LOGIN); ServiceContext serviceContext = ServiceTestUtil.getServiceContext(group.getGroupId()); serviceContext.setAttribute( StagingConstants.STAGED_PORTLET + PortletKeys.BOOKMARKS, Boolean.TRUE); ServiceContextThreadLocal.pushServiceContext(serviceContext); StagingLocalServiceUtil.enableLocalStaging( TestPropsValues.getUserId(), group, false, false, serviceContext); Group stagingGroup = group.getStagingGroup(); Layout stagingLayout = LayoutLocalServiceUtil.getLayoutByUuidAndGroupId( layout.getUuid(), stagingGroup.getGroupId(), layout.isPrivateLayout()); List<Layout> layouts = new ArrayList<Layout>(); layouts.add(stagingLayout); List<Portlet> portlets = LayoutExporter.getPortletDataHandlerPortlets(layouts); Assert.assertEquals(2, portlets.size()); for (Portlet portlet : portlets) { String portletId = portlet.getPortletId(); if (!portletId.equals(PortletKeys.BOOKMARKS) && !portletId.equals(PortletKeys.LOGIN)) { Assert.fail(); } } ServiceContextThreadLocal.popServiceContext(); }