SearchResultSummaryDisplayBuilder { public SearchResultSummaryDisplayContext build() throws Exception { try { if (_documentBuilderFactory != null) { _document = _documentBuilderFactory.builder( _legacyDocument ).build(); } String className = getFieldValueString(Field.ENTRY_CLASS_NAME); long classPK = getEntryClassPK(); if (Validator.isBlank(className) && (classPK == 0)) { return buildFromPlainDocument(); } return build(className, classPK); } catch (Exception exception) { if (_log.isDebugEnabled()) { _log.debug(exception, exception); } return buildTemporarilyUnavailable(); } }  SearchResultSummaryDisplayContext build(); SearchResultSummaryDisplayBuilder setAbridged(boolean abridged); SearchResultSummaryDisplayBuilder setAssetEntryLocalService(
		AssetEntryLocalService assetEntryLocalService); SearchResultSummaryDisplayBuilder setAssetRendererFactoryLookup(
		AssetRendererFactoryLookup assetRendererFactoryLookup); SearchResultSummaryDisplayBuilder setCurrentURL(String currentURL); SearchResultSummaryDisplayBuilder setDocument(
		com.liferay.portal.kernel.search.Document document); SearchResultSummaryDisplayBuilder setDocumentBuilderFactory(
		DocumentBuilderFactory documentBuilderFactory); SearchResultSummaryDisplayBuilder setFastDateFormatFactory(
		FastDateFormatFactory fastDateFormatFactory); SearchResultSummaryDisplayBuilder setGroupLocalService(
		GroupLocalService groupLocalService); SearchResultSummaryDisplayBuilder setHighlightEnabled(
		boolean highlightEnabled); SearchResultSummaryDisplayBuilder setImageRequested(
		boolean imageRequested); SearchResultSummaryDisplayBuilder setIndexerRegistry(
		IndexerRegistry indexerRegistry); SearchResultSummaryDisplayBuilder setLanguage(Language language); SearchResultSummaryDisplayBuilder setLocale(Locale locale); SearchResultSummaryDisplayBuilder setPortletURLFactory(
		PortletURLFactory portletURLFactory); SearchResultSummaryDisplayBuilder setRenderRequest(
		RenderRequest renderRequest); SearchResultSummaryDisplayBuilder setRenderResponse(
		RenderResponse renderResponse); SearchResultSummaryDisplayBuilder setRequest(
		HttpServletRequest httpServletRequest); SearchResultSummaryDisplayBuilder setResourceActions(
		ResourceActions resourceActions); SearchResultSummaryDisplayBuilder setSearchResultImageContributorsStream(
			Stream<SearchResultImageContributor>
				searchResultImageContributorsStream); SearchResultSummaryDisplayBuilder setSearchResultPreferences(
		SearchResultPreferences searchResultPreferences); SearchResultSummaryDisplayBuilder setSearchResultViewURLSupplier(
		SearchResultViewURLSupplier searchResultViewURLSupplier); SearchResultSummaryDisplayBuilder setSummaryBuilderFactory(
		SummaryBuilderFactory summaryBuilderFactory); SearchResultSummaryDisplayBuilder setThemeDisplay(
		ThemeDisplay themeDisplay);  }
@Test public void testClassFieldsWithoutAssetTagsOrCategories() throws Exception { PortletURL portletURL = Mockito.mock(PortletURL.class); Mockito.doReturn( portletURL ).when( portletURLFactory ).getPortletURL(); String entryClassName = RandomTestUtil.randomString(); long entryClassPK = RandomTestUtil.randomLong(); whenAssetRendererFactoryGetAssetRenderer(entryClassPK, assetRenderer); whenAssetRendererFactoryLookupGetAssetRendererFactoryByClassName( entryClassName); SearchResultSummaryDisplayContext searchResultSummaryDisplayContext = build(createDocument(entryClassName, entryClassPK)); Assert.assertEquals( entryClassName, searchResultSummaryDisplayContext.getClassName()); Assert.assertEquals( entryClassPK, searchResultSummaryDisplayContext.getClassPK()); Assert.assertEquals( portletURL, searchResultSummaryDisplayContext.getPortletURL()); }
@Test public void testNoStagingLabel() throws Exception { String entryClassName = RandomTestUtil.randomString(); long entryClassPK = RandomTestUtil.randomLong(); whenAssetRendererFactoryGetAssetRenderer(entryClassPK, assetRenderer); whenAssetRendererFactoryLookupGetAssetRendererFactoryByClassName( entryClassName); whenGroupLocalServiceGetGroup(false); SearchResultSummaryDisplayContext searchResultSummaryDisplayContext = build(createDocument(entryClassName, entryClassPK)); Assert.assertEquals( _SUMMARY_TITLE, searchResultSummaryDisplayContext.getHighlightedTitle()); }
@Test public void testResultIsTemporarilyUnavailable() throws Exception { ruinAssetRendererFactoryLookup(); SearchResultSummaryDisplayContext searchResultSummaryDisplayContext = build(Mockito.mock(Document.class)); Assert.assertTrue( searchResultSummaryDisplayContext.isTemporarilyUnavailable()); }
@Test public void testStagingLabel() throws Exception { String entryClassName = RandomTestUtil.randomString(); long entryClassPK = RandomTestUtil.randomLong(); whenAssetRendererFactoryGetAssetRenderer(entryClassPK, assetRenderer); whenAssetRendererFactoryLookupGetAssetRendererFactoryByClassName( entryClassName); whenGroupLocalServiceGetGroup(true); whenLanguageGet("staged"); SearchResultSummaryDisplayContext searchResultSummaryDisplayContext = build(createDocument(entryClassName, entryClassPK)); Assert.assertEquals( _SUMMARY_TITLE + " (staged)", searchResultSummaryDisplayContext.getHighlightedTitle()); }
@Test public void testTagsURLDownloadAndUserPortraitFromResult() throws Exception { long userId = RandomTestUtil.randomLong(); AssetEntry assetEntry = createAssetEntryWithTagsPresent(userId); String className = RandomTestUtil.randomString(); long entryClassPK = RandomTestUtil.randomLong(); whenAssetEntryLocalServiceFetchEntry( className, entryClassPK, assetEntry); whenAssetRendererFactoryGetAssetRenderer(entryClassPK, assetRenderer); whenAssetRendererFactoryLookupGetAssetRendererFactoryByClassName( className); String urlDownload = RandomTestUtil.randomString(); whenAssetRendererGetURLDownload(assetRenderer, urlDownload); whenIndexerRegistryGetIndexer(className, createIndexer()); SearchResultSummaryDisplayContext searchResultSummaryDisplayContext = build(createDocument(className, entryClassPK)); assertAssetRendererURLDownloadVisible( urlDownload, searchResultSummaryDisplayContext); assertTagsVisible(entryClassPK, searchResultSummaryDisplayContext); assertUserPortraitVisible(userId, searchResultSummaryDisplayContext); }
@Test public void testUserPortraitFromResultButTagsAndURLDownloadFromRoot() throws Exception { long userId = RandomTestUtil.randomInt(2, Integer.MAX_VALUE); AssetEntry assetEntry = createAssetEntry(userId); long rootUserId = userId - 1; AssetEntry rootAssetEntry = createAssetEntryWithTagsPresent(rootUserId); String className = RandomTestUtil.randomString(); long entryClassPK = RandomTestUtil.randomInt(2, Integer.MAX_VALUE); long rootEntryClassPK = entryClassPK - 1; whenAssetEntryLocalServiceFetchEntry( className, entryClassPK, assetEntry); whenAssetEntryLocalServiceFetchEntry( className, rootEntryClassPK, rootAssetEntry); whenAssetRendererFactoryGetAssetRenderer(entryClassPK, assetRenderer); AssetRenderer<?> rootAssetRenderer = Mockito.mock(AssetRenderer.class); whenAssetRendererFactoryGetAssetRenderer( rootEntryClassPK, rootAssetRenderer); whenAssetRendererFactoryLookupGetAssetRendererFactoryByClassName( className); String rootURLDownload = RandomTestUtil.randomString(); whenAssetRendererGetURLDownload(rootAssetRenderer, rootURLDownload); whenIndexerRegistryGetIndexer(className, createIndexer()); Document document = createDocument(className, entryClassPK); document.addKeyword(Field.ROOT_ENTRY_CLASS_PK, rootEntryClassPK); SearchResultSummaryDisplayContext searchResultSummaryDisplayContext = build(document); assertAssetRendererURLDownloadVisible( rootURLDownload, searchResultSummaryDisplayContext); assertTagsVisible(rootEntryClassPK, searchResultSummaryDisplayContext); assertUserPortraitVisible(userId, searchResultSummaryDisplayContext); }