Search in sources :

Example 31 with Topic

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

the class MyForumsTopicTest method verifyPost.

@Test
public void verifyPost() {
    Post post = new Post();
    Message message = new Message();
    message.setSubject("First Test Topic");
    post.setMessage(message);
    Topic result = ViewAllTopicsSelectPost.selectPost(driver, post);
    assertTrue(result != null);
    assertEquals(1, result.getPosts().size());
    assertEquals("root", result.getPosts().get(0).getPoster().getUserId());
    assertEquals(message.getSubject(), result.getPosts().get(0).getMessage().getSubject());
    assertEquals("First Test Body", result.getPosts().get(0).getMessage().getText());
    assertEquals(message.getSubject(), result.getSubject());
}
Also used : Message(it.vige.rubia.model.Message) ViewAllTopicsSelectPost(it.vige.rubia.selenium.myforums.action.ViewAllTopicsSelectPost) Post(it.vige.rubia.model.Post) ViewAllTopicsUpdateTopic.viewAllTopicsUpdateTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsUpdateTopic.viewAllTopicsUpdateTopic) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) ViewAllTopicsSelectTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsSelectTopic) ViewAllTopicsRemoveTopic.viewAllTopicsRemoveTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsRemoveTopic.viewAllTopicsRemoveTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) SubscriptionTopic.registerTopic(it.vige.rubia.selenium.forum.action.SubscriptionTopic.registerTopic) SubscriptionTopic.unregisterTopic(it.vige.rubia.selenium.forum.action.SubscriptionTopic.unregisterTopic) Test(org.junit.Test)

Example 32 with Topic

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

the class MyForumsTopicTest method setUp.

@BeforeClass
public static void setUp() {
    driver.get(HOME_URL);
    String message = createCategory(driver, new Category("First Test Category"));
    assertTrue(message.equals(CREATED_CATEGORY_1_MESSAGE));
    message = createCategory(driver, new Category("Second Test Category"));
    assertTrue(message.equals(CREATED_CATEGORY_2_MESSAGE));
    message = createForum(driver, new Forum("First Test Forum", "First Test Description", new Category("First Test Category")));
    assertTrue(message.equals(CREATED_FORUM_0_MESSAGE));
    message = createTopic(driver, new Topic(new Forum("First Test Forum"), "First Test Topic", asList(new Post[] { new Post("First Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), NORMAL, new Poll("First Test Question", asList(new PollOption[] { new PollOption("First Test Answer"), new PollOption("Second Test Answer") }), 4)));
    assertTrue(message.equals("First Test Topic"));
    message = registerTopic(driver, new Topic("First Test Topic"), EMAIL_LINKED_NOTIFICATION, CONFIRM);
    assertTrue(message.equals("First Test Topic"));
    message = createTopic(driver, new Topic(new Forum("First Test Forum"), "Second Test Topic", asList(new Post[] { new Post("Second Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), IMPORTANT, new Poll("Second Test Question", asList(new PollOption[] { new PollOption("Third Test Answer"), new PollOption("Fourth Test Answer") }), 8)));
    assertTrue(message.equals("Second Test Topic"));
    message = registerTopic(driver, new Topic("Second Test Topic"), EMAIL_EMBEDED_NOTIFICATION, CONFIRM);
    assertTrue(message.equals("Second Test Topic"));
    message = createForum(driver, new Forum("Second Test Forum", "Second Test Description", new Category("First Test Category")));
    assertTrue(message.equals(CREATED_FORUM_1_MESSAGE));
    message = createTopic(driver, new Topic(new Forum("Second Test Forum"), "Third Test Topic", asList(new Post[] { new Post("Third Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), ADVICE, new Poll("Third Test Question", asList(new PollOption[] { new PollOption("Fifth Test with Truncation over 25 characters Answer"), new PollOption("Sixth Test Answer") }), 9)));
    assertTrue(message.equals("Third Test Topic"));
    message = registerTopic(driver, new Topic("Third Test Topic"), EMAIL_NO_NOTIFICATION, CONFIRM);
    assertTrue(message.equals("Third Test Topic"));
    message = createTopic(driver, new Topic(new Forum("Second Test Forum"), "Fourth Test Topic", asList(new Post[] { new Post("Fourth Test Body", asList(new Attachment("fourth", "Fourth Test File"), new Attachment("fifth", "Fifth Test with Truncation over 25 characters File"), new Attachment("sixth", "Sixth Test File"))) }), IMPORTANT, new Poll("Fourth Test Question", asList(new PollOption[] { new PollOption("Seventh Test Answer"), new PollOption("Eight Test Answer") }), 0)));
    assertTrue(message.equals("Fourth Test Topic"));
    message = registerTopic(driver, new Topic("Fourth Test Topic"), EMAIL_EMBEDED_NOTIFICATION, CONFIRM);
    assertTrue(message.equals("Fourth Test Topic"));
    message = createForum(driver, new Forum("Third Test Forum", "Third Test Description", new Category("Second Test Category")));
    assertTrue(message.equals(CREATED_FORUM_2_MESSAGE));
    message = createTopic(driver, new Topic(new Forum("Third Test Forum"), "Fifth Test with Truncation over 25 characters Topic", asList(new Post[] { new Post("Fifth Test with Truncation over 25 characters Body", asList(new Attachment("seventh", "Seventh Test File"), new Attachment("eight", "Eight Test File"), new Attachment("ninth", "Ninth Test File"))) }), IMPORTANT, new Poll("Third Test Question", asList(new PollOption[] { new PollOption("Seventh Test Answer"), new PollOption("Eight Test Answer") }), 8)));
    assertTrue(message.equals("Fifth Test with Truncation over 25 characters Topic"));
    message = registerTopic(driver, new Topic("Fifth Test with Truncation over 25 characters Topic"), EMAIL_EMBEDED_NOTIFICATION, CONFIRM);
    assertTrue(message.equals("Fifth Test with Truncation over 25 characters Topic"));
    message = createTopic(driver, new Topic(new Forum("Third Test Forum"), "Sixth Test Topic", asList(new Post[] { new Post("Sixth Test Body", asList(new Attachment("ten", "Ten Test File"), new Attachment("eleven", "Eleven Test File"), new Attachment("twelve", "Twelve Test File"))) }), IMPORTANT, new Poll("Fourth Test Question", asList(new PollOption[] { new PollOption("Ninth Test Answer"), new PollOption("Ten Test Answer") }), 8)));
    assertTrue(message.equals("Sixth Test Topic"));
}
Also used : CreateCategory.createCategory(it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory) RemoveCategory.removeCategory(it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory) Category(it.vige.rubia.model.Category) ViewAllTopicsSelectPost(it.vige.rubia.selenium.myforums.action.ViewAllTopicsSelectPost) Post(it.vige.rubia.model.Post) Poll(it.vige.rubia.model.Poll) Attachment(it.vige.rubia.model.Attachment) PollOption(it.vige.rubia.model.PollOption) ViewAllTopicsUpdateTopic.viewAllTopicsUpdateTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsUpdateTopic.viewAllTopicsUpdateTopic) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) ViewAllTopicsSelectTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsSelectTopic) ViewAllTopicsRemoveTopic.viewAllTopicsRemoveTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsRemoveTopic.viewAllTopicsRemoveTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) SubscriptionTopic.registerTopic(it.vige.rubia.selenium.forum.action.SubscriptionTopic.registerTopic) SubscriptionTopic.unregisterTopic(it.vige.rubia.selenium.forum.action.SubscriptionTopic.unregisterTopic) Forum(it.vige.rubia.model.Forum) RemoveForum.removeForum(it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum) CreateForum.createForum(it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum) BeforeClass(org.junit.BeforeClass)

Example 33 with Topic

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

the class MyForumsTopicTest method verifyUpdatedTopic.

@Test
public void verifyUpdatedTopic() {
    Topic topic = new Topic();
    topic.setSubject("Third Test Topic");
    String notificationType = viewAllTopicsUpdateTopic(driver, topic, EMAIL_EMBEDED_NOTIFICATION);
    assertEquals(EMAIL_EMBEDED_NOTIFICATION.toString(), notificationType);
    notificationType = viewAllTopicsUpdateTopic(driver, topic, EMAIL_NO_NOTIFICATION);
    assertEquals(EMAIL_NO_NOTIFICATION.toString(), notificationType);
}
Also used : ViewAllTopicsUpdateTopic.viewAllTopicsUpdateTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsUpdateTopic.viewAllTopicsUpdateTopic) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) ViewAllTopicsSelectTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsSelectTopic) ViewAllTopicsRemoveTopic.viewAllTopicsRemoveTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsRemoveTopic.viewAllTopicsRemoveTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) SubscriptionTopic.registerTopic(it.vige.rubia.selenium.forum.action.SubscriptionTopic.registerTopic) SubscriptionTopic.unregisterTopic(it.vige.rubia.selenium.forum.action.SubscriptionTopic.unregisterTopic) Test(org.junit.Test)

Example 34 with Topic

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

the class MyForumsTopicTest method verifyRegisteredAuthorizedTopics.

@Test
public void verifyRegisteredAuthorizedTopics() {
    List<Topic> topics = viewAllTopics(driver);
    for (Topic topic : topics) {
        assertTrue(isRegistered(driver, topic));
        goTo(driver);
    }
    assertEquals("Fifth Test with Truncation over 25 characters Topic", topics.get(0).getSubject());
    assertEquals("Fourth Test Topic", topics.get(1).getSubject());
    assertEquals("Third Test Topic", topics.get(2).getSubject());
    assertEquals("Second Test Topic", topics.get(3).getSubject());
    assertEquals("First Test Topic", topics.get(4).getSubject());
    assertEquals(5, topics.size());
}
Also used : ViewAllTopicsUpdateTopic.viewAllTopicsUpdateTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsUpdateTopic.viewAllTopicsUpdateTopic) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) ViewAllTopicsSelectTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsSelectTopic) ViewAllTopicsRemoveTopic.viewAllTopicsRemoveTopic(it.vige.rubia.selenium.myforums.action.ViewAllTopicsRemoveTopic.viewAllTopicsRemoveTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) SubscriptionTopic.registerTopic(it.vige.rubia.selenium.forum.action.SubscriptionTopic.registerTopic) SubscriptionTopic.unregisterTopic(it.vige.rubia.selenium.forum.action.SubscriptionTopic.unregisterTopic) Test(org.junit.Test)

Example 35 with Topic

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

the class ModeratorAction method moveTopic.

/**
 * UI Action for moveing topic(s) from one forum to other.
 *
 * @return the name of the operation
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String moveTopic() {
    String forum_to_id = getParameter(p_forum_to_id);
    if (forum_to_id == null || forum_to_id.trim().length() == 0 || forum_to_id.trim().compareToIgnoreCase("-1") == 0) {
        setWarnBundleMessage("ERR_NO_DEST_FORUM");
        return "success";
    }
    Forum forumDest = null;
    try {
        forumDest = forumsModule.findForumById(new Integer(forum_to_id));
    } catch (Exception e) {
        setWarnBundleMessage("ERR_INTERNAL");
        return "success";
    }
    try {
        for (int topicId : checkboxes.keySet()) {
            boolean value = checkboxes.get(topicId);
            if (value) {
                Topic topic = null;
                try {
                    topic = forumsModule.findTopicById(topicId);
                } catch (Exception e) {
                    setWarnBundleMessage("ERR_INTERNAL");
                    return "success";
                }
                topic.setForum(forumDest);
                forumDest.setPostCount(forumDest.getPostCount() + topic.getReplies() + 1);
                forumDest.setTopicCount(forumDest.getTopicCount() + 1);
                forum.setPostCount(forum.getPostCount() - topic.getReplies() - 1);
                forum.setTopicCount(forum.getTopicCount() - 1);
                forumsModule.update(forum);
                forumsModule.update(forumDest);
                forumsModule.update(topic);
                topics.remove(topic);
            }
        }
        setInfoBundleMessage("SUCC_TOPIC_MOVED");
    } catch (Exception e) {
        handleException(e);
    }
    if (!conversation.isTransient())
        conversation.end();
    return "success";
}
Also used : ViewTopic(it.vige.rubia.ui.view.ViewTopic) Topic(it.vige.rubia.model.Topic) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Forum(it.vige.rubia.model.Forum) SecureActionForum(it.vige.rubia.auth.SecureActionForum) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

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