Skip to content

Commit

Permalink
Issue 29288 return total in content pull (#29817)
Browse files Browse the repository at this point in the history
* Return total in content pull
* Integration test
  • Loading branch information
dsilvam authored Aug 30, 2024
1 parent ea541c2 commit 8dc9297
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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());
}
}

0 comments on commit 8dc9297

Please sign in to comment.