Search in sources :

Example 71 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class SearchTopicTest method searchTopicsNoFields.

@Test
public void searchTopicsNoFields() {
    goTo(driver);
    SearchCriteria searchForumCriteria = new SearchCriteria();
    List<Topic> topics = searchTopic(driver, searchForumCriteria);
    assertTrue(topics == null);
}
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 72 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class ForumsModuleImpl method createTopic.

@Override
public Topic createTopic(Forum forum, String userId, String subject, TopicType type) throws ModuleException {
    try {
        Poster poster = findPosterByUserId(userId);
        if (poster == null) {
            poster = createPoster(userId);
        }
        em.persist(poster);
        Topic topic = new Topic();
        topic.setSubject(subject);
        topic.setForum(forum);
        topic.setPoster(poster);
        topic.setType(type);
        topic.setPoll(null);
        em.persist(topic);
        em.flush();
        return topic;
    } catch (Exception e) {
        String errorMessage = "Cannot create topic";
        throw new ModuleException(errorMessage, e);
    }
}
Also used : Poster(it.vige.rubia.model.Poster) Topic(it.vige.rubia.model.Topic) NoResultException(javax.persistence.NoResultException) NonUniqueResultException(javax.persistence.NonUniqueResultException)

Example 73 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class VerifyAttachment method addParents.

private static void addParents(WebDriver driver, Attachment attachment) {
    Post post = new Post();
    Message message = new Message();
    message.setSubject(driver.findElement(POST_TEMPLATE_LINK.getValue()).getText());
    post.setMessage(message);
    Topic topic = new Topic();
    topic.setSubject(driver.findElement(TOPIC_TEMPLATE_LINK.getValue()).getText());
    post.setTopic(topic);
    Forum forum = new Forum();
    forum.setName(driver.findElement(FORUM_TEMPLATE_LINK.getValue()).getText());
    topic.setForum(forum);
    Category category = new Category();
    category.setTitle(driver.findElement(CATEGORY_TEMPLATE_LINK.getValue()).getText());
    forum.setCategory(category);
    attachment.setPost(post);
}
Also used : Category(it.vige.rubia.model.Category) Message(it.vige.rubia.model.Message) Post(it.vige.rubia.model.Post) Topic(it.vige.rubia.model.Topic) Forum(it.vige.rubia.model.Forum)

Example 74 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class VerifyPost method addParents.

private static void addParents(WebDriver driver, Post post) {
    Topic topic = new Topic();
    topic.setSubject(driver.findElement(TOPIC_TEMPLATE_LINK.getValue()).getText());
    post.setTopic(topic);
    Forum forum = new Forum();
    forum.setName(driver.findElement(FORUM_TEMPLATE_LINK.getValue()).getText());
    topic.setForum(forum);
    Category category = new Category();
    category.setTitle(driver.findElement(CATEGORY_TEMPLATE_LINK.getValue()).getText());
    forum.setCategory(category);
}
Also used : Category(it.vige.rubia.model.Category) Topic(it.vige.rubia.model.Topic) Forum(it.vige.rubia.model.Forum)

Example 75 with Topic

use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.

the class VerifyPost method getPostsOfCurrentTopic.

public static List<Post> getPostsOfCurrentTopic(WebDriver driver) {
    List<WebElement> postComponents = driver.findElements(className(BODY_OUTPUT_TEXT));
    int postComponentsSize = postComponents.size();
    List<Post> posts = new ArrayList<Post>();
    for (int i = 0; i < postComponentsSize; i++) {
        Post post = new Post();
        WebElement postComponent = driver.findElements(className(BODY_OUTPUT_TEXT)).get(i);
        String body = postComponent.findElement(xpath("p")).getText();
        String post_subject = postComponent.findElement(xpath(POST_SUBJECT_OUTPUT_TEXT)).getText().split(POST_SUBJECT_TEXT)[1];
        String createDateStr = postComponent.findElement(xpath(CREATE_DATE_OUTPUT_TEXT)).getText().split(CREATE_DATE_TEXT)[1];
        Date createDate = null;
        try {
            createDate = dateFormat.parse(createDateStr);
        } catch (ParseException e) {
            log.error(e);
        }
        Message message = new Message();
        message.setSubject(post_subject);
        message.setText(body);
        post.setMessage(message);
        post.setCreateDate(createDate);
        WebElement topicEl = driver.findElement(TOPIC_TEMPLATE_LINK.getValue());
        Topic topic = new Topic(topicEl.getText());
        post.setTopic(topic);
        WebElement forumEl = driver.findElement(FORUM_TEMPLATE_LINK.getValue());
        topic.setForum(new Forum(forumEl.getText()));
        post.setAttachments(getAttachmentsOfCurrentPostInPage(driver, post));
        addParents(driver, post);
        Poster poster = new Poster();
        postComponent = driver.findElements(className(BODY_OUTPUT_TEXT)).get(i);
        poster.setUserId(postComponent.findElement(xpath(USER_LINK)).getText());
        post.setPoster(poster);
        posts.add(post);
    }
    return posts;
}
Also used : Message(it.vige.rubia.model.Message) Post(it.vige.rubia.model.Post) ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement) Date(java.util.Date) Forum(it.vige.rubia.model.Forum) Poster(it.vige.rubia.model.Poster) ParseException(java.text.ParseException) Topic(it.vige.rubia.model.Topic)

Aggregations

Topic (it.vige.rubia.model.Topic)112 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)64 Forum (it.vige.rubia.model.Forum)63 Post (it.vige.rubia.model.Post)62 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)49 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)48 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)39 Category (it.vige.rubia.model.Category)36 Test (org.junit.Test)36 CreateCategory.createCategory (it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory)30 RemoveCategory.removeCategory (it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory)30 Poll (it.vige.rubia.model.Poll)25 PollOption (it.vige.rubia.model.PollOption)24 Attachment (it.vige.rubia.model.Attachment)23 Poster (it.vige.rubia.model.Poster)17 CreatePost.createPost (it.vige.rubia.selenium.forum.action.CreatePost.createPost)16 WebElement (org.openqa.selenium.WebElement)16 SecureActionForum (it.vige.rubia.auth.SecureActionForum)14 Date (java.util.Date)14 Interceptors (javax.interceptor.Interceptors)13