Search in sources :

Example 1 with SearchCriteria

use of it.vige.rubia.search.SearchCriteria in project rubia-forums by flashboss.

the class SearchTopicTest method verifyPostFromTopicPage.

@Test
public void verifyPostFromTopicPage() {
    goTo(driver);
    SearchCriteria searchForumCriteria = new SearchCriteria();
    searchForumCriteria.setAuthor("root");
    searchForumCriteria.setCategory(null);
    searchForumCriteria.setDisplayAs(TOPICS.name());
    searchForumCriteria.setForum(null);
    searchForumCriteria.setKeywords("Topic");
    searchForumCriteria.setPageNumber(0);
    searchForumCriteria.setPageSize(0);
    searchForumCriteria.setSearching(null);
    searchForumCriteria.setSortBy(null);
    searchForumCriteria.setSortOrder(null);
    searchForumCriteria.setTimePeriod(null);
    List<Topic> topics = searchTopic(driver, searchForumCriteria);
    Topic topic = getTopic(driver, topics.get(3));
    assertTrue(topic != null);
    assertTrue(topic.getPosts() != null);
    assertEquals("Fourth Test Topic", topic.getSubject());
    assertEquals("root", topic.getPoster().getUserId());
    assertEquals(1, topic.getPosts().size());
    assertEquals("Fourth Test Topic", topic.getPosts().get(0).getMessage().getSubject());
    assertEquals("Fourth Test Body", topic.getPosts().get(0).getMessage().getText());
    assertEquals("Fourth Test Question", topic.getPoll().getTitle());
}
Also used : RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) ViewPageTopicSearch.searchTopic(it.vige.rubia.selenium.search.action.ViewPageTopicSearch.searchTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) ViewPageTopicSearch.getTopic(it.vige.rubia.selenium.search.action.ViewPageTopicSearch.getTopic) SearchCriteria(it.vige.rubia.search.SearchCriteria) Test(org.junit.Test)

Example 2 with SearchCriteria

use of it.vige.rubia.search.SearchCriteria in project rubia-forums by flashboss.

the class SearchTopicTest method verifyPostFromTopicPageLastPost.

@Test
public void verifyPostFromTopicPageLastPost() {
    goTo(driver);
    SearchCriteria searchForumCriteria = new SearchCriteria();
    searchForumCriteria.setAuthor("root");
    searchForumCriteria.setCategory(null);
    searchForumCriteria.setDisplayAs(TOPICS.name());
    searchForumCriteria.setForum(null);
    searchForumCriteria.setKeywords("Topic");
    searchForumCriteria.setPageNumber(0);
    searchForumCriteria.setPageSize(0);
    searchForumCriteria.setSearching(null);
    searchForumCriteria.setSortBy(null);
    searchForumCriteria.setSortOrder(null);
    searchForumCriteria.setTimePeriod(null);
    List<Topic> topics = searchTopic(driver, searchForumCriteria);
    Poster poster = getPosterLastPost(driver, topics.get(0));
    goTo(driver);
    topics = searchTopic(driver, searchForumCriteria);
    Post post = getLastPostOfCurrentForum(driver, topics.get(0));
    assertTrue(post != null);
    assertEquals("First Test with a large subject name triing to truncate over the 25 character Topic", post.getMessage().getSubject());
    assertTrue(poster != null);
    assertEquals("root", poster.getUserId());
    assertTrue(poster.getPostCount() >= 4);
}
Also used : ViewPageTopicSearch.getPosterLastPost(it.vige.rubia.selenium.search.action.ViewPageTopicSearch.getPosterLastPost) Post(it.vige.rubia.model.Post) Poster(it.vige.rubia.model.Poster) ViewPageTopicSearch.getPoster(it.vige.rubia.selenium.search.action.ViewPageTopicSearch.getPoster) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) ViewPageTopicSearch.searchTopic(it.vige.rubia.selenium.search.action.ViewPageTopicSearch.searchTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) ViewPageTopicSearch.getTopic(it.vige.rubia.selenium.search.action.ViewPageTopicSearch.getTopic) SearchCriteria(it.vige.rubia.search.SearchCriteria) Test(org.junit.Test)

Example 3 with SearchCriteria

use of it.vige.rubia.search.SearchCriteria in project rubia-forums by flashboss.

the class SearchTopicTest method searchTopics.

@Test
public void searchTopics() {
    goTo(driver);
    SearchCriteria searchForumCriteria = new SearchCriteria();
    searchForumCriteria.setAuthor("root");
    searchForumCriteria.setCategory(null);
    searchForumCriteria.setDisplayAs(TOPICS.name());
    searchForumCriteria.setForum(null);
    searchForumCriteria.setKeywords("Topic");
    searchForumCriteria.setPageNumber(0);
    searchForumCriteria.setPageSize(0);
    searchForumCriteria.setSearching(null);
    searchForumCriteria.setSortBy(null);
    searchForumCriteria.setSortOrder(null);
    searchForumCriteria.setTimePeriod(null);
    List<Topic> topics = searchTopic(driver, searchForumCriteria);
    Date today = new Date();
    assertTrue(topics != null);
    assertEquals(4, topics.size());
    assertEquals("First Test with a large subject name triing to truncate over the 25 character Topic", topics.get(0).getSubject());
    assertEquals("root", topics.get(0).getPoster().getUserId());
    assertEquals(0, topics.get(0).getReplies());
    assertEquals(1, topics.get(0).getViewCount());
    assertTrue(topics.get(0).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(0).getPosts().size());
    assertTrue(topics.get(0).getPosts().get(0).getMessage().getSubject().startsWith("First Test with a large s..."));
    assertTrue(topics.get(0).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(0).getPosts().get(0).getPoster().getUserId());
    assertEquals("Second Test Topic", topics.get(1).getSubject());
    assertEquals("root", topics.get(1).getPoster().getUserId());
    assertEquals(0, topics.get(1).getReplies());
    assertEquals(0, topics.get(1).getViewCount());
    assertTrue(topics.get(1).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(1).getPosts().size());
    assertTrue(topics.get(1).getPosts().get(0).getMessage().getSubject().startsWith("Second Test Topic"));
    assertTrue(topics.get(1).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(1).getPosts().get(0).getPoster().getUserId());
    assertEquals("Third Test Topic", topics.get(2).getSubject());
    assertEquals("root", topics.get(2).getPoster().getUserId());
    assertEquals(0, topics.get(2).getReplies());
    assertEquals(0, topics.get(2).getViewCount());
    assertTrue(topics.get(2).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(2).getPosts().size());
    assertTrue(topics.get(2).getPosts().get(0).getMessage().getSubject().startsWith("Third Test Topic"));
    assertTrue(topics.get(2).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(2).getPosts().get(0).getPoster().getUserId());
    assertEquals("Fourth Test Topic", topics.get(3).getSubject());
    assertEquals("root", topics.get(3).getPoster().getUserId());
    assertEquals(0, topics.get(3).getReplies());
    assertEquals(0, topics.get(3).getViewCount());
    assertTrue(topics.get(3).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(3).getPosts().size());
    assertTrue(topics.get(3).getPosts().get(0).getMessage().getSubject().startsWith("Fourth Test Topic"));
    assertTrue(topics.get(3).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(3).getPosts().get(0).getPoster().getUserId());
    goTo(driver);
    searchForumCriteria.setCategory("First Test Category");
    topics = searchTopic(driver, searchForumCriteria);
    assertTrue(topics != null);
    assertEquals(4, topics.size());
    assertEquals("First Test with a large subject name triing to truncate over the 25 character Topic", topics.get(0).getSubject());
    assertEquals("root", topics.get(0).getPoster().getUserId());
    assertEquals(0, topics.get(0).getReplies());
    assertEquals(1, topics.get(0).getViewCount());
    assertTrue(topics.get(0).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(0).getPosts().size());
    assertTrue(topics.get(0).getPosts().get(0).getMessage().getSubject().startsWith("First Test with a large s..."));
    assertTrue(topics.get(0).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(0).getPosts().get(0).getPoster().getUserId());
    assertEquals("Second Test Topic", topics.get(1).getSubject());
    assertEquals("root", topics.get(1).getPoster().getUserId());
    assertEquals(0, topics.get(1).getReplies());
    assertEquals(0, topics.get(1).getViewCount());
    assertTrue(topics.get(1).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(1).getPosts().size());
    assertTrue(topics.get(1).getPosts().get(0).getMessage().getSubject().startsWith("Second Test Topic"));
    assertTrue(topics.get(1).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(1).getPosts().get(0).getPoster().getUserId());
    assertEquals("Third Test Topic", topics.get(2).getSubject());
    assertEquals("root", topics.get(2).getPoster().getUserId());
    assertEquals(0, topics.get(2).getReplies());
    assertEquals(0, topics.get(2).getViewCount());
    assertTrue(topics.get(2).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(2).getPosts().size());
    assertTrue(topics.get(2).getPosts().get(0).getMessage().getSubject().startsWith("Third Test Topic"));
    assertTrue(topics.get(2).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(2).getPosts().get(0).getPoster().getUserId());
    assertEquals("Fourth Test Topic", topics.get(3).getSubject());
    assertEquals("root", topics.get(3).getPoster().getUserId());
    assertEquals(0, topics.get(3).getReplies());
    assertEquals(0, topics.get(3).getViewCount());
    assertTrue(topics.get(3).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(3).getPosts().size());
    assertTrue(topics.get(3).getPosts().get(0).getMessage().getSubject().startsWith("Fourth Test Topic"));
    assertTrue(topics.get(3).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(3).getPosts().get(0).getPoster().getUserId());
    goTo(driver);
    searchForumCriteria.setCategory("Second Test Category");
    topics = searchTopic(driver, searchForumCriteria);
    assertTrue(topics == null);
    goTo(driver);
    searchForumCriteria.setCategory(null);
    searchForumCriteria.setForum("First Test Forum");
    topics = searchTopic(driver, searchForumCriteria);
    assertTrue(topics != null);
    assertEquals(2, topics.size());
    assertEquals("First Test with a large subject name triing to truncate over the 25 character Topic", topics.get(0).getSubject());
    assertEquals("root", topics.get(0).getPoster().getUserId());
    assertEquals(0, topics.get(0).getReplies());
    assertEquals(1, topics.get(0).getViewCount());
    assertTrue(topics.get(0).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(0).getPosts().size());
    assertTrue(topics.get(0).getPosts().get(0).getMessage().getSubject().startsWith("First Test with a large s..."));
    assertTrue(topics.get(0).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(0).getPosts().get(0).getPoster().getUserId());
    assertEquals("Second Test Topic", topics.get(1).getSubject());
    assertEquals("root", topics.get(1).getPoster().getUserId());
    assertEquals(0, topics.get(1).getReplies());
    assertEquals(0, topics.get(1).getViewCount());
    assertTrue(topics.get(1).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(1).getPosts().size());
    assertTrue(topics.get(1).getPosts().get(0).getMessage().getSubject().startsWith("Second Test Topic"));
    assertTrue(topics.get(1).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(1).getPosts().get(0).getPoster().getUserId());
    goTo(driver);
    searchForumCriteria.setForum("Second Test Forum");
    topics = searchTopic(driver, searchForumCriteria);
    assertEquals(2, topics.size());
    assertEquals("Third Test Topic", topics.get(0).getSubject());
    assertEquals("root", topics.get(0).getPoster().getUserId());
    assertEquals(0, topics.get(0).getReplies());
    assertEquals(0, topics.get(0).getViewCount());
    assertTrue(topics.get(0).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(0).getPosts().size());
    assertTrue(topics.get(0).getPosts().get(0).getMessage().getSubject().startsWith("Third Test Topic"));
    assertTrue(topics.get(0).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(0).getPosts().get(0).getPoster().getUserId());
    assertEquals("Fourth Test Topic", topics.get(1).getSubject());
    assertEquals("root", topics.get(1).getPoster().getUserId());
    assertEquals(0, topics.get(1).getReplies());
    assertEquals(0, topics.get(1).getViewCount());
    assertTrue(topics.get(1).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(1).getPosts().size());
    assertTrue(topics.get(1).getPosts().get(0).getMessage().getSubject().startsWith("Fourth Test Topic"));
    assertTrue(topics.get(1).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(1).getPosts().get(0).getPoster().getUserId());
    ResourceBundle bundle = getBundle("ResourceJSF");
    goTo(driver);
    searchForumCriteria.setForum(null);
    searchForumCriteria.setTimePeriod(bundle.getString("period_7_Days"));
    topics = searchTopic(driver, searchForumCriteria);
    assertTrue(topics != null);
    assertEquals(4, topics.size());
    assertEquals("First Test with a large subject name triing to truncate over the 25 character Topic", topics.get(0).getSubject());
    assertEquals("root", topics.get(0).getPoster().getUserId());
    assertEquals(0, topics.get(0).getReplies());
    assertEquals(1, topics.get(0).getViewCount());
    assertTrue(topics.get(0).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(0).getPosts().size());
    assertTrue(topics.get(0).getPosts().get(0).getMessage().getSubject().startsWith("First Test with a large s..."));
    assertTrue(topics.get(0).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(0).getPosts().get(0).getPoster().getUserId());
    assertEquals("Second Test Topic", topics.get(1).getSubject());
    assertEquals("root", topics.get(1).getPoster().getUserId());
    assertEquals(0, topics.get(1).getReplies());
    assertEquals(0, topics.get(1).getViewCount());
    assertTrue(topics.get(1).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(1).getPosts().size());
    assertTrue(topics.get(1).getPosts().get(0).getMessage().getSubject().startsWith("Second Test Topic"));
    assertTrue(topics.get(1).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(1).getPosts().get(0).getPoster().getUserId());
    assertEquals("Third Test Topic", topics.get(2).getSubject());
    assertEquals("root", topics.get(2).getPoster().getUserId());
    assertEquals(0, topics.get(2).getReplies());
    assertEquals(0, topics.get(2).getViewCount());
    assertTrue(topics.get(2).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(2).getPosts().size());
    assertTrue(topics.get(2).getPosts().get(0).getMessage().getSubject().startsWith("Third Test Topic"));
    assertTrue(topics.get(2).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(2).getPosts().get(0).getPoster().getUserId());
    assertEquals("Fourth Test Topic", topics.get(3).getSubject());
    assertEquals("root", topics.get(3).getPoster().getUserId());
    assertEquals(0, topics.get(3).getReplies());
    assertEquals(0, topics.get(3).getViewCount());
    assertTrue(topics.get(3).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(3).getPosts().size());
    assertTrue(topics.get(3).getPosts().get(0).getMessage().getSubject().startsWith("Fourth Test Topic"));
    assertTrue(topics.get(3).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(3).getPosts().get(0).getPoster().getUserId());
    goTo(driver);
    searchForumCriteria.setTimePeriod(null);
    searchForumCriteria.setSortBy(bundle.getString("Search_post_subject"));
    searchForumCriteria.setSortOrder(ASC.name());
    topics = searchTopic(driver, searchForumCriteria);
    assertTrue(topics != null);
    assertEquals(4, topics.size());
    assertEquals("First Test with a large subject name triing to truncate over the 25 character Topic", topics.get(0).getSubject());
    assertEquals("root", topics.get(0).getPoster().getUserId());
    assertEquals(0, topics.get(0).getReplies());
    assertEquals(1, topics.get(0).getViewCount());
    assertTrue(topics.get(0).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(0).getPosts().size());
    assertTrue(topics.get(0).getPosts().get(0).getMessage().getSubject().startsWith("First Test with a large s..."));
    assertTrue(topics.get(0).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(0).getPosts().get(0).getPoster().getUserId());
    assertEquals("Fourth Test Topic", topics.get(1).getSubject());
    assertEquals("root", topics.get(1).getPoster().getUserId());
    assertEquals(0, topics.get(1).getReplies());
    assertEquals(0, topics.get(1).getViewCount());
    assertTrue(topics.get(1).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(1).getPosts().size());
    assertTrue(topics.get(1).getPosts().get(0).getMessage().getSubject().startsWith("Fourth Test Topic"));
    assertTrue(topics.get(1).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(1).getPosts().get(0).getPoster().getUserId());
    assertEquals("Second Test Topic", topics.get(2).getSubject());
    assertEquals("root", topics.get(2).getPoster().getUserId());
    assertEquals(0, topics.get(2).getReplies());
    assertEquals(0, topics.get(2).getViewCount());
    assertTrue(topics.get(2).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(2).getPosts().size());
    assertTrue(topics.get(2).getPosts().get(0).getMessage().getSubject().startsWith("Second Test Topic"));
    assertTrue(topics.get(2).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(2).getPosts().get(0).getPoster().getUserId());
    assertEquals("Third Test Topic", topics.get(3).getSubject());
    assertEquals("root", topics.get(3).getPoster().getUserId());
    assertEquals(0, topics.get(3).getReplies());
    assertEquals(0, topics.get(3).getViewCount());
    assertTrue(topics.get(3).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(3).getPosts().size());
    assertTrue(topics.get(3).getPosts().get(0).getMessage().getSubject().startsWith("Third Test Topic"));
    assertTrue(topics.get(3).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(3).getPosts().get(0).getPoster().getUserId());
    goTo(driver);
    searchForumCriteria.setSortOrder(DESC.name());
    topics = searchTopic(driver, searchForumCriteria);
    assertTrue(topics != null);
    assertEquals(4, topics.size());
    assertEquals("Third Test Topic", topics.get(0).getSubject());
    assertEquals("root", topics.get(0).getPoster().getUserId());
    assertEquals(0, topics.get(0).getReplies());
    assertEquals(0, topics.get(0).getViewCount());
    assertTrue(topics.get(0).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(0).getPosts().size());
    assertTrue(topics.get(0).getPosts().get(0).getMessage().getSubject().startsWith("Third Test Topic"));
    assertTrue(topics.get(0).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(0).getPosts().get(0).getPoster().getUserId());
    assertEquals("Second Test Topic", topics.get(1).getSubject());
    assertEquals("root", topics.get(1).getPoster().getUserId());
    assertEquals(0, topics.get(1).getReplies());
    assertEquals(0, topics.get(1).getViewCount());
    assertTrue(topics.get(1).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(1).getPosts().size());
    assertTrue(topics.get(1).getPosts().get(0).getMessage().getSubject().startsWith("Second Test Topic"));
    assertTrue(topics.get(1).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(1).getPosts().get(0).getPoster().getUserId());
    assertEquals("Fourth Test Topic", topics.get(2).getSubject());
    assertEquals("root", topics.get(2).getPoster().getUserId());
    assertEquals(0, topics.get(2).getReplies());
    assertEquals(0, topics.get(2).getViewCount());
    assertTrue(topics.get(2).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(2).getPosts().size());
    assertTrue(topics.get(2).getPosts().get(0).getMessage().getSubject().startsWith("Fourth Test Topic"));
    assertTrue(topics.get(2).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(2).getPosts().get(0).getPoster().getUserId());
    assertEquals("First Test with a large subject name triing to truncate over the 25 character Topic", topics.get(3).getSubject());
    assertEquals("root", topics.get(3).getPoster().getUserId());
    assertEquals(0, topics.get(3).getReplies());
    assertEquals(1, topics.get(3).getViewCount());
    assertTrue(topics.get(3).getLastPostDate().compareTo(today) < 0);
    assertEquals(1, topics.get(3).getPosts().size());
    assertTrue(topics.get(3).getPosts().get(0).getMessage().getSubject().startsWith("First Test with a large s..."));
    assertTrue(topics.get(3).getPosts().get(0).getCreateDate().compareTo(today) < 0);
    assertEquals("root", topics.get(3).getPosts().get(0).getPoster().getUserId());
    goTo(driver);
    searchForumCriteria.setSortBy(null);
    searchForumCriteria.setSortOrder(null);
    searchForumCriteria.setSearching(MSG.name());
    topics = searchTopic(driver, searchForumCriteria);
    assertTrue(topics == null);
}
Also used : ResourceBundle(java.util.ResourceBundle) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) ViewPageTopicSearch.searchTopic(it.vige.rubia.selenium.search.action.ViewPageTopicSearch.searchTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) ViewPageTopicSearch.getTopic(it.vige.rubia.selenium.search.action.ViewPageTopicSearch.getTopic) SearchCriteria(it.vige.rubia.search.SearchCriteria) Date(java.util.Date) Test(org.junit.Test)

Example 4 with SearchCriteria

use of it.vige.rubia.search.SearchCriteria in project rubia-forums by flashboss.

the class SearchPostTest method searchPosts.

@Test
public void searchPosts() {
    goTo(driver);
    SearchCriteria searchTopicCriteria = new SearchCriteria();
    searchTopicCriteria.setAuthor("root");
    searchTopicCriteria.setCategory(null);
    searchTopicCriteria.setDisplayAs(POSTS.name());
    searchTopicCriteria.setForum(null);
    searchTopicCriteria.setKeywords("Body");
    searchTopicCriteria.setPageNumber(0);
    searchTopicCriteria.setPageSize(0);
    searchTopicCriteria.setSearching(null);
    searchTopicCriteria.setSortBy(null);
    searchTopicCriteria.setSortOrder(null);
    searchTopicCriteria.setTimePeriod(null);
    List<Post> posts = searchPost(driver, searchTopicCriteria);
    Date today = new Date();
    assertTrue(posts != null);
    assertEquals(6, posts.size());
    assertEquals("root", posts.get(0).getPoster().getUserId());
    assertEquals("First Test Topic", posts.get(0).getMessage().getSubject());
    assertEquals("First Test Body", posts.get(0).getMessage().getText());
    assertTrue(posts.get(0).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(0).getAttachments().size());
    assertEquals("root", posts.get(1).getPoster().getUserId());
    assertEquals("Second Test Topic", posts.get(1).getMessage().getSubject());
    assertEquals("Second Test Body", posts.get(1).getMessage().getText());
    assertTrue(posts.get(1).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(1).getAttachments().size());
    assertEquals("root", posts.get(2).getPoster().getUserId());
    assertEquals("Third Test Topic", posts.get(2).getMessage().getSubject());
    assertEquals("Third Test Body", posts.get(2).getMessage().getText());
    assertTrue(posts.get(2).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(2).getAttachments().size());
    assertEquals("root", posts.get(3).getPoster().getUserId());
    assertEquals("Fourth Test Topic", posts.get(3).getMessage().getSubject());
    assertEquals("Fourth Test Body", posts.get(3).getMessage().getText());
    assertTrue(posts.get(3).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(3).getAttachments().size());
    assertEquals("root", posts.get(4).getPoster().getUserId());
    assertEquals("Fifth Test with Truncation over 25 characters Topic", posts.get(4).getMessage().getSubject());
    assertEquals("Fifth Test with Truncation over 25 characters Body", posts.get(4).getMessage().getText());
    assertTrue(posts.get(4).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(4).getAttachments().size());
    assertEquals("root", posts.get(5).getPoster().getUserId());
    assertEquals("Sixth Test Topic", posts.get(5).getMessage().getSubject());
    assertEquals("Sixth Test Body", posts.get(5).getMessage().getText());
    assertTrue(posts.get(5).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(5).getAttachments().size());
    goTo(driver);
    searchTopicCriteria.setCategory("First Test Category");
    posts = searchPost(driver, searchTopicCriteria);
    assertTrue(posts != null);
    assertEquals(4, posts.size());
    assertEquals("root", posts.get(0).getPoster().getUserId());
    assertEquals("First Test Topic", posts.get(0).getMessage().getSubject());
    assertEquals("First Test Body", posts.get(0).getMessage().getText());
    assertTrue(posts.get(0).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(0).getAttachments().size());
    assertEquals("root", posts.get(1).getPoster().getUserId());
    assertEquals("Second Test Topic", posts.get(1).getMessage().getSubject());
    assertEquals("Second Test Body", posts.get(1).getMessage().getText());
    assertTrue(posts.get(1).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(1).getAttachments().size());
    assertEquals("root", posts.get(2).getPoster().getUserId());
    assertEquals("Third Test Topic", posts.get(2).getMessage().getSubject());
    assertEquals("Third Test Body", posts.get(2).getMessage().getText());
    assertTrue(posts.get(2).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(2).getAttachments().size());
    assertEquals("root", posts.get(3).getPoster().getUserId());
    assertEquals("Fourth Test Topic", posts.get(3).getMessage().getSubject());
    assertEquals("Fourth Test Body", posts.get(3).getMessage().getText());
    assertTrue(posts.get(3).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(3).getAttachments().size());
    goTo(driver);
    searchTopicCriteria.setCategory("Second Test Category");
    posts = searchPost(driver, searchTopicCriteria);
    assertTrue(posts != null);
    assertEquals(2, posts.size());
    assertEquals("root", posts.get(0).getPoster().getUserId());
    assertEquals("Fifth Test with Truncation over 25 characters Topic", posts.get(0).getMessage().getSubject());
    assertEquals("Fifth Test with Truncation over 25 characters Body", posts.get(0).getMessage().getText());
    assertTrue(posts.get(0).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(0).getAttachments().size());
    assertEquals("root", posts.get(1).getPoster().getUserId());
    assertEquals("Sixth Test Topic", posts.get(1).getMessage().getSubject());
    assertEquals("Sixth Test Body", posts.get(1).getMessage().getText());
    assertTrue(posts.get(1).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(1).getAttachments().size());
    goTo(driver);
    searchTopicCriteria.setCategory(null);
    searchTopicCriteria.setForum("First Test Forum");
    posts = searchPost(driver, searchTopicCriteria);
    assertTrue(posts != null);
    assertEquals(2, posts.size());
    assertEquals("root", posts.get(0).getPoster().getUserId());
    assertEquals("First Test Topic", posts.get(0).getMessage().getSubject());
    assertEquals("First Test Body", posts.get(0).getMessage().getText());
    assertTrue(posts.get(0).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(0).getAttachments().size());
    assertEquals("root", posts.get(1).getPoster().getUserId());
    assertEquals("Second Test Topic", posts.get(1).getMessage().getSubject());
    assertEquals("Second Test Body", posts.get(1).getMessage().getText());
    assertTrue(posts.get(1).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(1).getAttachments().size());
    goTo(driver);
    searchTopicCriteria.setForum("Second Test Forum");
    posts = searchPost(driver, searchTopicCriteria);
    assertTrue(posts != null);
    assertEquals(2, posts.size());
    assertEquals("root", posts.get(0).getPoster().getUserId());
    assertEquals("Third Test Topic", posts.get(0).getMessage().getSubject());
    assertEquals("Third Test Body", posts.get(0).getMessage().getText());
    assertTrue(posts.get(0).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(0).getAttachments().size());
    assertEquals("root", posts.get(1).getPoster().getUserId());
    assertEquals("Fourth Test Topic", posts.get(1).getMessage().getSubject());
    assertEquals("Fourth Test Body", posts.get(1).getMessage().getText());
    assertTrue(posts.get(1).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(1).getAttachments().size());
    ResourceBundle bundle = getBundle("ResourceJSF");
    goTo(driver);
    searchTopicCriteria.setForum(null);
    searchTopicCriteria.setTimePeriod(bundle.getString("period_7_Days"));
    posts = searchPost(driver, searchTopicCriteria);
    assertTrue(posts != null);
    assertEquals(6, posts.size());
    assertEquals("root", posts.get(0).getPoster().getUserId());
    assertEquals("First Test Topic", posts.get(0).getMessage().getSubject());
    assertEquals("First Test Body", posts.get(0).getMessage().getText());
    assertTrue(posts.get(0).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(0).getAttachments().size());
    assertEquals("root", posts.get(1).getPoster().getUserId());
    assertEquals("Second Test Topic", posts.get(1).getMessage().getSubject());
    assertEquals("Second Test Body", posts.get(1).getMessage().getText());
    assertTrue(posts.get(1).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(1).getAttachments().size());
    assertEquals("root", posts.get(2).getPoster().getUserId());
    assertEquals("Third Test Topic", posts.get(2).getMessage().getSubject());
    assertEquals("Third Test Body", posts.get(2).getMessage().getText());
    assertTrue(posts.get(2).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(2).getAttachments().size());
    assertEquals("root", posts.get(3).getPoster().getUserId());
    assertEquals("Fourth Test Topic", posts.get(3).getMessage().getSubject());
    assertEquals("Fourth Test Body", posts.get(3).getMessage().getText());
    assertTrue(posts.get(3).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(3).getAttachments().size());
    assertEquals("root", posts.get(4).getPoster().getUserId());
    assertEquals("Fifth Test with Truncation over 25 characters Topic", posts.get(4).getMessage().getSubject());
    assertEquals("Fifth Test with Truncation over 25 characters Body", posts.get(4).getMessage().getText());
    assertTrue(posts.get(4).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(4).getAttachments().size());
    assertEquals("root", posts.get(5).getPoster().getUserId());
    assertEquals("Sixth Test Topic", posts.get(5).getMessage().getSubject());
    assertEquals("Sixth Test Body", posts.get(5).getMessage().getText());
    assertTrue(posts.get(5).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(5).getAttachments().size());
    goTo(driver);
    searchTopicCriteria.setTimePeriod(null);
    searchTopicCriteria.setSortBy(bundle.getString("Search_post_subject"));
    searchTopicCriteria.setSortOrder(ASC.name());
    posts = searchPost(driver, searchTopicCriteria);
    assertTrue(posts != null);
    assertEquals(6, posts.size());
    assertEquals("root", posts.get(0).getPoster().getUserId());
    assertEquals("Fifth Test with Truncation over 25 characters Topic", posts.get(0).getMessage().getSubject());
    assertEquals("Fifth Test with Truncation over 25 characters Body", posts.get(0).getMessage().getText());
    assertTrue(posts.get(0).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(0).getAttachments().size());
    assertEquals("root", posts.get(1).getPoster().getUserId());
    assertEquals("First Test Topic", posts.get(1).getMessage().getSubject());
    assertEquals("First Test Body", posts.get(1).getMessage().getText());
    assertTrue(posts.get(1).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(1).getAttachments().size());
    assertEquals("root", posts.get(2).getPoster().getUserId());
    assertEquals("Fourth Test Topic", posts.get(2).getMessage().getSubject());
    assertEquals("Fourth Test Body", posts.get(2).getMessage().getText());
    assertTrue(posts.get(2).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(2).getAttachments().size());
    assertEquals("root", posts.get(3).getPoster().getUserId());
    assertEquals("Second Test Topic", posts.get(3).getMessage().getSubject());
    assertEquals("Second Test Body", posts.get(3).getMessage().getText());
    assertTrue(posts.get(3).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(3).getAttachments().size());
    assertEquals("root", posts.get(4).getPoster().getUserId());
    assertEquals("Sixth Test Topic", posts.get(4).getMessage().getSubject());
    assertEquals("Sixth Test Body", posts.get(4).getMessage().getText());
    assertTrue(posts.get(4).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(4).getAttachments().size());
    assertEquals("root", posts.get(5).getPoster().getUserId());
    assertEquals("Third Test Topic", posts.get(5).getMessage().getSubject());
    assertEquals("Third Test Body", posts.get(5).getMessage().getText());
    assertTrue(posts.get(5).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(5).getAttachments().size());
    goTo(driver);
    searchTopicCriteria.setSortOrder(DESC.name());
    posts = searchPost(driver, searchTopicCriteria);
    assertTrue(posts != null);
    assertEquals(6, posts.size());
    assertEquals("root", posts.get(0).getPoster().getUserId());
    assertEquals("Third Test Topic", posts.get(0).getMessage().getSubject());
    assertEquals("Third Test Body", posts.get(0).getMessage().getText());
    assertTrue(posts.get(2).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(0).getAttachments().size());
    assertEquals("root", posts.get(1).getPoster().getUserId());
    assertEquals("Sixth Test Topic", posts.get(1).getMessage().getSubject());
    assertEquals("Sixth Test Body", posts.get(1).getMessage().getText());
    assertTrue(posts.get(1).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(1).getAttachments().size());
    assertEquals("root", posts.get(2).getPoster().getUserId());
    assertEquals("Second Test Topic", posts.get(2).getMessage().getSubject());
    assertEquals("Second Test Body", posts.get(2).getMessage().getText());
    assertTrue(posts.get(2).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(2).getAttachments().size());
    assertEquals("root", posts.get(3).getPoster().getUserId());
    assertEquals("Fourth Test Topic", posts.get(3).getMessage().getSubject());
    assertEquals("Fourth Test Body", posts.get(3).getMessage().getText());
    assertTrue(posts.get(3).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(3).getAttachments().size());
    assertEquals("root", posts.get(4).getPoster().getUserId());
    assertEquals("First Test Topic", posts.get(4).getMessage().getSubject());
    assertEquals("First Test Body", posts.get(4).getMessage().getText());
    assertTrue(posts.get(4).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(4).getAttachments().size());
    assertEquals("root", posts.get(5).getPoster().getUserId());
    assertEquals("Fifth Test with Truncation over 25 characters Topic", posts.get(5).getMessage().getSubject());
    assertEquals("Fifth Test with Truncation over 25 characters Body", posts.get(5).getMessage().getText());
    assertTrue(posts.get(5).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(5).getAttachments().size());
    goTo(driver);
    searchTopicCriteria.setSortBy(null);
    searchTopicCriteria.setSortOrder(null);
    searchTopicCriteria.setSearching(MSG.name());
    posts = searchPost(driver, searchTopicCriteria);
    assertTrue(posts != null);
    assertEquals(6, posts.size());
    assertEquals("root", posts.get(0).getPoster().getUserId());
    assertEquals("First Test Topic", posts.get(0).getMessage().getSubject());
    assertEquals("First Test Body", posts.get(0).getMessage().getText());
    assertTrue(posts.get(0).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(0).getAttachments().size());
    assertEquals("root", posts.get(1).getPoster().getUserId());
    assertEquals("Second Test Topic", posts.get(1).getMessage().getSubject());
    assertEquals("Second Test Body", posts.get(1).getMessage().getText());
    assertTrue(posts.get(1).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(1).getAttachments().size());
    assertEquals("root", posts.get(2).getPoster().getUserId());
    assertEquals("Third Test Topic", posts.get(2).getMessage().getSubject());
    assertEquals("Third Test Body", posts.get(2).getMessage().getText());
    assertTrue(posts.get(2).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(2).getAttachments().size());
    assertEquals("root", posts.get(3).getPoster().getUserId());
    assertEquals("Fourth Test Topic", posts.get(3).getMessage().getSubject());
    assertEquals("Fourth Test Body", posts.get(3).getMessage().getText());
    assertTrue(posts.get(3).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(3).getAttachments().size());
    assertEquals("root", posts.get(4).getPoster().getUserId());
    assertEquals("Fifth Test with Truncation over 25 characters Topic", posts.get(4).getMessage().getSubject());
    assertEquals("Fifth Test with Truncation over 25 characters Body", posts.get(4).getMessage().getText());
    assertTrue(posts.get(4).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(4).getAttachments().size());
    assertEquals("root", posts.get(5).getPoster().getUserId());
    assertEquals("Sixth Test Topic", posts.get(5).getMessage().getSubject());
    assertEquals("Sixth Test Body", posts.get(5).getMessage().getText());
    assertTrue(posts.get(5).getCreateDate().compareTo(today) < 0);
    assertEquals(3, posts.get(5).getAttachments().size());
}
Also used : ViewPagePostSearch.searchPost(it.vige.rubia.selenium.search.action.ViewPagePostSearch.searchPost) Post(it.vige.rubia.model.Post) ResourceBundle(java.util.ResourceBundle) SearchCriteria(it.vige.rubia.search.SearchCriteria) Date(java.util.Date) Test(org.junit.Test)

Example 5 with SearchCriteria

use of it.vige.rubia.search.SearchCriteria in project rubia-forums by flashboss.

the class SearchPostTest method searchPostsNoResults.

@Test
public void searchPostsNoResults() {
    goTo(driver);
    SearchCriteria searchTopicCriteria = new SearchCriteria();
    searchTopicCriteria.setAuthor(null);
    searchTopicCriteria.setCategory(null);
    searchTopicCriteria.setDisplayAs(POSTS.name());
    searchTopicCriteria.setForum(null);
    searchTopicCriteria.setKeywords("Firstaaaaaa");
    searchTopicCriteria.setPageNumber(0);
    searchTopicCriteria.setPageSize(0);
    searchTopicCriteria.setSearching(null);
    searchTopicCriteria.setSortBy(null);
    searchTopicCriteria.setSortOrder(null);
    searchTopicCriteria.setTimePeriod(null);
    List<Post> posts = searchPost(driver, searchTopicCriteria);
    assertTrue(posts == null);
}
Also used : ViewPagePostSearch.searchPost(it.vige.rubia.selenium.search.action.ViewPagePostSearch.searchPost) Post(it.vige.rubia.model.Post) SearchCriteria(it.vige.rubia.search.SearchCriteria) Test(org.junit.Test)

Aggregations

SearchCriteria (it.vige.rubia.search.SearchCriteria)14 Test (org.junit.Test)13 Post (it.vige.rubia.model.Post)8 Topic (it.vige.rubia.model.Topic)8 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)7 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)7 ViewPageTopicSearch.getTopic (it.vige.rubia.selenium.search.action.ViewPageTopicSearch.getTopic)7 ViewPageTopicSearch.searchTopic (it.vige.rubia.selenium.search.action.ViewPageTopicSearch.searchTopic)7 ViewPagePostSearch.searchPost (it.vige.rubia.selenium.search.action.ViewPagePostSearch.searchPost)6 Poster (it.vige.rubia.model.Poster)4 ViewPageTopicSearch.getPoster (it.vige.rubia.selenium.search.action.ViewPageTopicSearch.getPoster)2 Date (java.util.Date)2 ResourceBundle (java.util.ResourceBundle)2 ViewPageTopicSearch.getPosterLastPost (it.vige.rubia.selenium.search.action.ViewPageTopicSearch.getPosterLastPost)1