ALF-9153 Add unit tests for the new discussions hot topics CQ and service method

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30028 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2011-08-24 14:30:21 +00:00
parent b94a0af2e9
commit 2aedabf4c0
5 changed files with 197 additions and 22 deletions

View File

@@ -111,11 +111,29 @@ public class GetDiscussionTopcisWithPostsCannedQuery extends AbstractCannedQuery
result.setChildren(wantedPosts);
}
// Ignore any topic with no replies
// (As topics have a primary post, that means any with less than 2 children)
if(result.getChildren().size() <= 1)
// If required, filter out the primary post
if(paramBean.getExcludePrimaryPost())
{
// No posts at all, or only the primary one
List<NameAndCreatedAt> wantedPosts = new ArrayList<NameAndCreatedAt>();
for(NameAndCreatedAt post : result.getChildren())
{
if(post.getName().equals( result.getName() ))
{
// Primary post, skip
continue;
}
else
{
wantedPosts.add(post);
}
}
result.setChildren(wantedPosts);
}
// Ignore any topic with no posts
if(result.getChildren().size() == 0)
{
// No valid posts
continue;
}