Search in sources :

Example 36 with Post

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);
}
Also used : Post(net.jforum.entities.Post) Date(java.util.Date)

Example 37 with Post

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());
}
Also used : User(net.jforum.entities.User) PostDAO(net.jforum.dao.PostDAO) Post(net.jforum.entities.Post) List(java.util.List)

Example 38 with Post

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());
}
Also used : Post(net.jforum.entities.Post) List(java.util.List) ArrayList(java.util.ArrayList)

Example 39 with Post

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());
}
Also used : Post(net.jforum.entities.Post) List(java.util.List) ArrayList(java.util.ArrayList)

Example 40 with Post

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());
}
Also used : Post(net.jforum.entities.Post) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

Post (net.jforum.entities.Post)47 List (java.util.List)20 PostDAO (net.jforum.dao.PostDAO)15 ArrayList (java.util.ArrayList)13 Date (java.util.Date)11 PreparedStatement (java.sql.PreparedStatement)9 SQLException (java.sql.SQLException)9 Iterator (java.util.Iterator)9 DatabaseException (net.jforum.exceptions.DatabaseException)9 ResultSet (java.sql.ResultSet)8 Topic (net.jforum.entities.Topic)8 User (net.jforum.entities.User)8 TopicDAO (net.jforum.dao.TopicDAO)7 AttachmentCommon (net.jforum.view.forum.common.AttachmentCommon)6 UserDAO (net.jforum.dao.UserDAO)5 SimpleDateFormat (java.text.SimpleDateFormat)4 ModerationLog (net.jforum.entities.ModerationLog)4 ForumDAO (net.jforum.dao.ForumDAO)3 AttachmentException (net.jforum.exceptions.AttachmentException)3 IOException (java.io.IOException)2