Skip to content

Commit

Permalink
LPD-22160 portal-search-rest-test: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmirFe authored and liferay-continuous-integration committed Apr 19, 2024
1 parent 3bc70e6 commit 92e97c5
Showing 1 changed file with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,14 @@ private SXPBlueprint _addSXPBlueprint(boolean highlightingEnabled)
}

private SearchPage<SearchResult> _assertFacetConfiguration(
boolean anyMatch, Map<String, Object> facetAttributes,
String facetName, Object facetValues, String... expectedValues)
boolean anyMatch, String entryClassNames,
Map<String, Object> facetAttributes, String facetName,
Object facetValues, String... expectedValues)
throws Exception {

SearchPage<SearchResult> searchPage =
_postSearchPageWithFacetConfiguration(
entryClassNames,
new FacetConfiguration() {
{
attributes = facetAttributes;
Expand Down Expand Up @@ -409,11 +411,9 @@ private SearchPage<SearchResult> _postSearchPage(
}

private SearchPage<SearchResult> _postSearchPageWithFacetConfiguration(
FacetConfiguration facetConfiguration)
String entryClassNames, FacetConfiguration facetConfiguration)
throws Exception {

facetConfiguration.setFrequencyThreshold(0);

SearchRequestBody searchRequestBody = new SearchRequestBody() {
{
attributes = HashMapBuilder.<String, Object>put(
Expand All @@ -427,8 +427,9 @@ private SearchPage<SearchResult> _postSearchPageWithFacetConfiguration(
};

return _postSearchPage(
null, "groupIds/any(g:g eq " + testGroup.getGroupId() + ")", null,
null, searchRequestBody);
entryClassNames,
"groupIds/any(g:g eq " + testGroup.getGroupId() + ")", null, null,
searchRequestBody);
}

private SearchPage<SearchResult>
Expand All @@ -454,7 +455,7 @@ private void _testPostSearchPageWithCategoryTreeFacetConfiguration()
throws Exception {

_assertFacetConfiguration(
false,
false, null,
HashMapBuilder.<String, Object>put(
"mode", "tree"
).put(
Expand All @@ -469,7 +470,7 @@ private void _testPostSearchPageWithCustomFacetConfiguration()
throws Exception {

_assertFacetConfiguration(
false,
false, null,
HashMapBuilder.<String, Object>put(
"field", Field.COMPANY_ID
).build(),
Expand Down Expand Up @@ -500,7 +501,7 @@ private void _testPostSearchPageWithDateRangeFacetConfiguration()
));

SearchPage<SearchResult> searchPage = _assertFacetConfiguration(
false,
false, null,
HashMapBuilder.<String, Object>put(
"field", "modified"
).put(
Expand Down Expand Up @@ -559,7 +560,7 @@ private void _testPostSearchPageWithFolderFacetConfiguration()
throws Exception {

_assertFacetConfiguration(
false, null, "folder", _journalArticle.getFolderId(),
false, null, null, "folder", _journalArticle.getFolderId(),
String.valueOf(_journalArticle.getFolderId()));
}

Expand Down Expand Up @@ -593,7 +594,7 @@ private void _testPostSearchPageWithNestedFacetConfiguration()
}

_assertFacetConfiguration(
false,
false, null,
HashMapBuilder.<String, Object>put(
"field",
"ddmFieldArray.ddmFieldValueKeyword_" +
Expand Down Expand Up @@ -640,31 +641,35 @@ private void _testPostSearchPageWithSiteFacetConfiguration()
throws Exception {

_assertFacetConfiguration(
true, null, "site", testGroup.getGroupId(),
true, null, null, "site", testGroup.getGroupId(),
String.valueOf(testGroup.getGroupId()));
}

private void _testPostSearchPageWithTagFacetConfiguration()
throws Exception {

_assertFacetConfiguration(
true, null, "tag", _assetTag.getName(), _assetTag.getName());
true, null, null, "tag", _assetTag.getName(), _assetTag.getName());
}

private void _testPostSearchPageWithTypeFacetConfiguration()
throws Exception {

_assertFacetConfiguration(
false, null, "type", StringPool.BLANK,
JournalArticle.class.getName(), JournalFolder.class.getName(),
User.class.getName());
false,
StringBundler.concat(
JournalArticle.class.getName(), StringPool.COMMA,
JournalFolder.class.getName(), StringPool.COMMA,
User.class.getName()),
null, "type", StringPool.BLANK, JournalArticle.class.getName(),
JournalFolder.class.getName(), User.class.getName());
}

private void _testPostSearchPageWithUserFacetConfiguration()
throws Exception {

_assertFacetConfiguration(
true, null, "user", StringUtil.toLowerCase(_user.getFullName()),
true, null, null, "user", _user.getUserId(),
String.valueOf(_user.getUserId()));
}

Expand Down

0 comments on commit 92e97c5

Please sign in to comment.