Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 29288 return total in content pull #29817

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public PaginatedArrayList<ContentMap> pull(String query, int offset,int limit, S
ret.add(new ContentMap(cc,user,EDIT_OR_PREVIEW_MODE,currentHost,context));
}
ret.setQuery(cons.getQuery());
ret.setTotalResults(cons.getTotalResults());
return ret;
}
catch(Throwable ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.dotmarketing.portlets.languagesmanager.model.Language;
import com.dotmarketing.portlets.structure.model.Relationship;
import com.dotmarketing.util.PageMode;
import com.dotmarketing.util.PaginatedArrayList;
import com.dotmarketing.util.PaginatedContentList;
import com.dotmarketing.util.WebKeys.Relationship.RELATIONSHIP_CARDINALITY;
import com.liferay.portal.model.User;
Expand All @@ -53,6 +54,7 @@
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.velocity.context.Context;
Expand Down Expand Up @@ -880,4 +882,27 @@ public void testPullRelated_MultiLangContent() throws DotDataException, DotSecur


}

/**
* Method to Test: {@link ContentTool#pull(String, int, int, String)}}
* When: pulling content and having more than one content
* Should: Return the total under the key "totalResults"
*
*/
@Test
public void testPull_includeTotal() {
final ContentType blogLikeType = TestDataUtils.getBlogLikeContentType();

final ContentletDataGen contentletDataGen = new ContentletDataGen(blogLikeType.inode()).host(defaultHost);
IntStream.range(0, 10).forEach(i -> contentletDataGen.nextPersisted());

final ContentTool contentTool = getContentTool(defaultLanguage.getId());

final PaginatedArrayList<ContentMap> results = contentTool.pull(
"+contentType:" + blogLikeType.variable(), 0, 0,
"modDate desc"
);

Assert.assertEquals(10, results.getTotalResults());
}
}
Loading