ItemSelectorImpl implements ItemSelector { @Override public ItemSelectorRendering getItemSelectorRendering( RequestBackedPortletURLFactory requestBackedPortletURLFactory, Map<String, String[]> parameters, ThemeDisplay themeDisplay) { String itemSelectedEventName = getValue( parameters, PARAMETER_ITEM_SELECTED_EVENT_NAME); String selectedTab = getValue(parameters, PARAMETER_SELECTED_TAB); List<ItemSelectorViewRenderer> itemSelectorViewRenderers = new ArrayList<>(); List<ItemSelectorCriterion> itemSelectorCriteria = getItemSelectorCriteria(parameters); ItemSelectorCriterion[] itemSelectorCriteriaArray = itemSelectorCriteria.toArray(new ItemSelectorCriterion[0]); for (ItemSelectorCriterion itemSelectorCriterion : itemSelectorCriteria) { Class<? extends ItemSelectorCriterion> itemSelectorCriterionClass = itemSelectorCriterion.getClass(); ItemSelectorCriterionHandler<ItemSelectorCriterion> itemSelectorCriterionHandler = _itemSelectionCriterionHandlers.get( itemSelectorCriterionClass.getName()); List<ItemSelectorView<ItemSelectorCriterion>> itemSelectorViews = itemSelectorCriterionHandler.getItemSelectorViews( itemSelectorCriterion); for (ItemSelectorView<ItemSelectorCriterion> itemSelectorView : itemSelectorViews) { if (!itemSelectorView.isVisible( itemSelectorCriterion, themeDisplay)) { continue; } PortletURL portletURL = getPortletURL( requestBackedPortletURLFactory, itemSelectorView.getTitle(themeDisplay.getLocale()), selectedTab, itemSelectedEventName, itemSelectorCriteriaArray, themeDisplay); itemSelectorViewRenderers.add( _applyCustomizations( new ItemSelectorViewRendererImpl( itemSelectorView, itemSelectorCriterion, portletURL, itemSelectedEventName, isSearch(parameters)))); } } return new ItemSelectorRenderingImpl( itemSelectedEventName, selectedTab, itemSelectorViewRenderers); }  @Override String getItemSelectedEventName(String itemSelectorURL); @Override List<ItemSelectorCriterion> getItemSelectorCriteria(
		Map<String, String[]> parameters); @Override List<ItemSelectorCriterion> getItemSelectorCriteria(
		String itemSelectorURL); @Override ItemSelectorRendering getItemSelectorRendering(
		RequestBackedPortletURLFactory requestBackedPortletURLFactory,
		Map<String, String[]> parameters, ThemeDisplay themeDisplay); @Override PortletURL getItemSelectorURL(
		RequestBackedPortletURLFactory requestBackedPortletURLFactory,
		Group group, long refererGroupId, String itemSelectedEventName,
		ItemSelectorCriterion... itemSelectorCriteria); @Override PortletURL getItemSelectorURL(
		RequestBackedPortletURLFactory requestBackedPortletURLFactory,
		String itemSelectedEventName,
		ItemSelectorCriterion... itemSelectorCriteria); static final String JSON; static final String PARAMETER_CRITERIA; static final String PARAMETER_ITEM_SELECTED_EVENT_NAME; static final String PARAMETER_SELECTED_TAB; }
@Test public void testGetItemSelectorRendering() { setUpItemSelectionCriterionHandlers(); ItemSelectorRendering itemSelectorRendering = getItemSelectorRendering(); Assert.assertEquals( "itemSelectedEventName", itemSelectorRendering.getItemSelectedEventName()); List<ItemSelectorViewRenderer> itemSelectorViewRenderers = itemSelectorRendering.getItemSelectorViewRenderers(); ItemSelectorViewRenderer mediaItemSelectorViewRenderer = itemSelectorViewRenderers.get(0); MediaItemSelectorCriterion mediaItemSelectorCriterion = (MediaItemSelectorCriterion) mediaItemSelectorViewRenderer.getItemSelectorCriterion(); Assert.assertEquals( _mediaItemSelectorCriterion.getFileExtension(), mediaItemSelectorCriterion.getFileExtension()); Assert.assertEquals( _mediaItemSelectorCriterion.getMaxSize(), mediaItemSelectorCriterion.getMaxSize()); Assert.assertTrue( (ItemSelectorView<?>) mediaItemSelectorViewRenderer.getItemSelectorView() instanceof MediaItemSelectorView); ItemSelectorViewRenderer flickrItemSelectorViewRenderer = itemSelectorViewRenderers.get(1); FlickrItemSelectorCriterion flickrItemSelectorCriterion = (FlickrItemSelectorCriterion) flickrItemSelectorViewRenderer.getItemSelectorCriterion(); Assert.assertEquals( _flickrItemSelectorCriterion.getUser(), flickrItemSelectorCriterion.getUser()); Assert.assertTrue( (ItemSelectorView<?>) flickrItemSelectorViewRenderer.getItemSelectorView() instanceof FlickrItemSelectorView); Assert.assertEquals( itemSelectorViewRenderers.toString(), 2, itemSelectorViewRenderers.size()); }