use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class PostCommon method fillPostFromRequest.
public static Post fillPostFromRequest() {
Post p = new Post();
p.setTime(new Date());
return fillPostFromRequest(p, false);
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class POPListenerTestCase method assertPost.
/**
* Asserts the post instance, after execution some part of the testcase
* @param topicId the topic's id of the new message
* @param sender the matching sender email
* @param subject the matching subject
* @param contents the matching message contents
*/
private void assertPost(int topicId, String sender, String subject, String contents) {
PostDAO postDAO = DataAccessDriver.getInstance().newPostDAO();
List posts = postDAO.selectAllByTopic(topicId);
assertTrue("There should be exactly one post", posts.size() == 1);
Post p = (Post) posts.get(0);
User user = DataAccessDriver.getInstance().newUserDAO().selectById(p.getUserId());
assertNotNull("User should not be null", user);
assertEquals("sender", sender, user.getEmail());
assertEquals("subject", subject, p.getSubject());
assertEquals("text", contents, p.getText());
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class LuceneSearchTestCase method testANDExpressionUsingTwoPostsWithOneCommonWordSearchTwoTermsExpectOneResult.
public void testANDExpressionUsingTwoPostsWithOneCommonWordSearchTwoTermsExpectOneResult() {
// 1
Post p = this.newPost();
p.setText("a regular text with some magic word");
this.indexer.create(p);
// 2
p = this.newPost();
p.setText("say shazan to see the magic happen");
this.indexer.create(p);
// Search
SearchArgs args = new SearchArgs();
args.matchAllKeywords();
args.setKeywords("magic regular");
List results = this.search.search(args).records();
Assert.assertEquals(1, results.size());
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class LuceneSearchTestCase method testThreePostsSearchContentsExpectOneResult.
public void testThreePostsSearchContentsExpectOneResult() {
// 1
Post p = this.newPost();
p.setSubject("java");
this.indexer.create(p);
// 2
p = this.newPost();
p.setSubject("something else");
this.indexer.create(p);
// 3
p = this.newPost();
p.setSubject("debug");
this.indexer.create(p);
// Search
SearchArgs args = new SearchArgs();
args.setKeywords("java");
List results = this.search.search(args).records();
Assert.assertEquals(1, results.size());
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class LuceneSearchTestCase method testFivePostsInTwoForumsSearchOneForumAndTwoValidTermsAndOneInvalidTermExpectThreeResults.
public void testFivePostsInTwoForumsSearchOneForumAndTwoValidTermsAndOneInvalidTermExpectThreeResults() {
List l = this.createThreePosts();
((Post) l.get(0)).setForumId(1);
((Post) l.get(1)).setForumId(2);
((Post) l.get(2)).setForumId(1);
this.indexer.create((Post) l.get(0));
this.indexer.create((Post) l.get(1));
this.indexer.create((Post) l.get(2));
// Post 4
Post p = this.newPost();
p.setText("It introduces you to searching, sorting, filtering and highlighting [...]");
p.setForumId(1);
this.indexer.create(p);
// Post 5
p = this.newPost();
p.setText("How to integrate lucene into your applications");
p.setForumId(2);
l.add(p);
this.indexer.create(p);
// Search
SearchArgs args = new SearchArgs();
args.setForumId(1);
args.setKeywords("open lucene xpto authoritative");
List results = this.search.search(args).records();
Assert.assertEquals(3, results.size());
}
Aggregations