SearchBarPortletDisplayBuilder { public SearchBarPortletDisplayContext build() throws PortletException { SearchBarPortletDisplayContext searchBarPortletDisplayContext = createSearchBarPortletDisplayContext(); searchBarPortletDisplayContext.setAvailableEverythingSearchScope( isAvailableEverythingSearchScope()); searchBarPortletDisplayContext.setCurrentSiteSearchScopeParameterString( SearchScope.THIS_SITE.getParameterString()); searchBarPortletDisplayContext.setEmptySearchEnabled( _emptySearchEnabled); searchBarPortletDisplayContext.setEverythingSearchScopeParameterString( SearchScope.EVERYTHING.getParameterString()); searchBarPortletDisplayContext.setKeywords(getKeywords()); searchBarPortletDisplayContext.setKeywordsParameterName( _keywordsParameterName); if (_searchScopePreference == SearchScopePreference.LET_THE_USER_CHOOSE) { searchBarPortletDisplayContext.setLetTheUserChooseTheSearchScope( true); } searchBarPortletDisplayContext.setPaginationStartParameterName( getPaginationStartParameterName()); searchBarPortletDisplayContext.setScopeParameterName( _scopeParameterName); searchBarPortletDisplayContext.setScopeParameterValue( getScopeParameterValue()); setSelectedSearchScope(searchBarPortletDisplayContext); if (Validator.isBlank(_destination)) { searchBarPortletDisplayContext.setSearchURL(getURLCurrentPath()); } else { String destinationURL = getDestinationURL(_destination); if (destinationURL == null) { searchBarPortletDisplayContext.setDestinationUnreachable(true); searchBarPortletDisplayContext.setRenderNothing(true); } else { searchBarPortletDisplayContext.setSearchURL(destinationURL); } } if (_invisible) { searchBarPortletDisplayContext.setRenderNothing(true); } return searchBarPortletDisplayContext; } SearchBarPortletDisplayBuilder(
		Http http, LayoutLocalService layoutLocalService, Portal portal,
		RenderRequest renderRequest); SearchBarPortletDisplayContext build(); SearchBarPortletDisplayBuilder setDestination(String destination); SearchBarPortletDisplayBuilder setEmptySearchEnabled(
		boolean emptySearchEnabled); SearchBarPortletDisplayBuilder setInvisible(boolean invisible); SearchBarPortletDisplayBuilder setKeywords(
		Optional<String> keywordsOptional); SearchBarPortletDisplayBuilder setKeywordsParameterName(
		String keywordsParameterName); SearchBarPortletDisplayBuilder setPaginationStartParameterName(
		String paginationStartParameterName); SearchBarPortletDisplayBuilder setScopeParameterName(
		String scopeParameterName); SearchBarPortletDisplayBuilder setScopeParameterValue(
		Optional<String> scopeParameterValueOptional); SearchBarPortletDisplayBuilder setSearchScopePreference(
		SearchScopePreference searchScopePreference); SearchBarPortletDisplayBuilder setThemeDisplay(
		ThemeDisplay themeDisplay);  }
@Test public void testSamePageNoDestination() throws PortletException { Mockito.doReturn( "http: ).when( _themeDisplay ).getURLCurrent(); SearchBarPortletDisplayBuilder searchBarPortletDisplayBuilder = createSearchBarPortletDisplayBuilder(); SearchBarPortletDisplayContext searchBarPortletDisplayContext = searchBarPortletDisplayBuilder.build(); Assert.assertFalse( searchBarPortletDisplayContext.isDestinationUnreachable()); Assert.assertEquals( "/web/guest/home", searchBarPortletDisplayContext.getSearchURL()); }