Search in sources :

Example 66 with Forum

use of it.vige.rubia.model.Forum 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)

Example 67 with Forum

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

the class OperationPollTest method verifyVote.

@Test
public void verifyVote() {
    Topic topic = new Topic(new Forum("Second Test Forum"), "Fourth Test Topic");
    goTo(driver, topic);
    Poll pollToUpdate = getPollOfCurrentTopic(driver);
    Poll updatedPoll = vote(driver, pollToUpdate, 0);
    assertEquals("Fourth Test Question", updatedPoll.getTitle());
    assertEquals(100, updatedPoll.getVotesSum());
    List<PollOption> options = updatedPoll.getOptions();
    assertEquals("Seventh Test Answer", options.get(0).getQuestion());
    assertEquals("Eight Test Answer", options.get(1).getQuestion());
    assertEquals(100, options.get(0).getVotes());
    assertEquals(0, options.get(1).getVotes());
    assertEquals(2, options.size());
    updatedPoll = vote(driver, pollToUpdate, 1);
    assertEquals("Fourth Test Question", updatedPoll.getTitle());
    assertEquals(100, updatedPoll.getVotesSum());
    options = updatedPoll.getOptions();
    assertEquals("Seventh Test Answer", options.get(0).getQuestion());
    assertEquals("Eight Test Answer", options.get(1).getQuestion());
    assertEquals(50, options.get(0).getVotes());
    assertEquals(50, options.get(1).getVotes());
    assertEquals(2, options.size());
    topic.setPoll(updatedPoll);
    String message = removePoll(driver, topic);
    assertTrue(message.equals(OK));
    String[] createdOptions = addPoll(driver, updatedPoll);
    assertEquals(2, createdOptions.length);
}
Also used : UpdatePoll.updatePoll(it.vige.rubia.selenium.forum.action.UpdatePoll.updatePoll) Poll(it.vige.rubia.model.Poll) RemovePoll.removePoll(it.vige.rubia.selenium.forum.action.RemovePoll.removePoll) CreatePoll.addPoll(it.vige.rubia.selenium.forum.action.CreatePoll.addPoll) PollOption(it.vige.rubia.model.PollOption) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) VerifyPoll.getPollOfCurrentTopic(it.vige.rubia.selenium.forum.action.VerifyPoll.getPollOfCurrentTopic) 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) Test(org.junit.Test)

Example 68 with Forum

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

the class OperationPollTest method verifyAddDeleteOptions.

@Test
public void verifyAddDeleteOptions() {
    Topic topic = new Topic(new Forum("Second Test Forum"), "Fourth Test Topic");
    goTo(driver, topic);
    Poll pollToUpdate = getPollOfCurrentTopic(driver);
    pollToUpdate.getOptions().clear();
    pollToUpdate.getOptions().add(new PollOption("Third Test Answer"));
    pollToUpdate.getOptions().add(new PollOption("Fifth Test with Truncation over 25 characters Answer"));
    Poll updatedPoll = addOptions(driver, pollToUpdate);
    assertEquals("Fourth Test Question", updatedPoll.getTitle());
    assertEquals(0, updatedPoll.getVotesSum());
    List<PollOption> options = updatedPoll.getOptions();
    assertEquals("Seventh Test Answer", options.get(0).getQuestion());
    assertEquals("Eight Test Answer", options.get(1).getQuestion());
    assertEquals("Third Test Answer", options.get(2).getQuestion());
    assertEquals("Fifth Test with Truncation over 25 characters Answer", options.get(3).getQuestion());
    assertEquals(0, options.get(0).getVotes());
    assertEquals(0, options.get(1).getVotes());
    assertEquals(0, options.get(2).getVotes());
    assertEquals(0, options.get(3).getVotes());
    assertEquals(4, options.size());
    pollToUpdate.getOptions().clear();
    pollToUpdate.getOptions().add(new PollOption("Third Test Answer"));
    pollToUpdate.getOptions().add(new PollOption("Fifth Test with Truncation over 25 characters Answer"));
    updatedPoll = deleteOptions(driver, pollToUpdate);
    assertEquals("Fourth Test Question", updatedPoll.getTitle());
    assertEquals(0, updatedPoll.getVotesSum());
    options = updatedPoll.getOptions();
    assertEquals("Seventh Test Answer", options.get(0).getQuestion());
    assertEquals("Eight Test Answer", options.get(1).getQuestion());
    assertEquals(0, options.get(0).getVotes());
    assertEquals(0, options.get(1).getVotes());
    assertEquals(2, options.size());
}
Also used : UpdatePoll.updatePoll(it.vige.rubia.selenium.forum.action.UpdatePoll.updatePoll) Poll(it.vige.rubia.model.Poll) RemovePoll.removePoll(it.vige.rubia.selenium.forum.action.RemovePoll.removePoll) CreatePoll.addPoll(it.vige.rubia.selenium.forum.action.CreatePoll.addPoll) PollOption(it.vige.rubia.model.PollOption) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) VerifyPoll.getPollOfCurrentTopic(it.vige.rubia.selenium.forum.action.VerifyPoll.getPollOfCurrentTopic) 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) Test(org.junit.Test)

Example 69 with Forum

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

the class OperationPollTest method stop.

@AfterClass
public static void stop() {
    Topic topic = 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));
    String message = removePoll(driver, topic);
    assertTrue(message.equals(OK));
    message = removeTopic(driver, topic);
    assertTrue(message.equals(OK));
    topic = 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));
    message = removePoll(driver, topic);
    assertTrue(message.equals(OK));
    message = removeTopic(driver, topic);
    assertTrue(message.equals(OK));
    topic = 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));
    message = removePoll(driver, topic);
    assertTrue(message.equals(OK));
    message = removeTopic(driver, topic);
    assertTrue(message.equals(OK));
    topic = 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));
    message = removePoll(driver, topic);
    assertTrue(message.equals(OK));
    message = removeTopic(driver, topic);
    assertTrue(message.equals(OK));
    message = removeForum(driver, new Forum("First Test Forum"), "Second Test Forum");
    assertTrue(message.equals(REMOVED_FORUM_0_MESSAGE));
    message = removeForum(driver, new Forum("Second Test Forum"), SELECT_FORUM_TYPE);
    assertTrue(message.equals(REMOVED_FORUM_1_MESSAGE));
    message = removeCategory(driver, new Category("First Test Category"), SELECT_CATEGORY_TYPE);
    assertTrue(message.equals(REMOVED_CATEGORY_0_MESSAGE));
    message = removeCategory(driver, new Category("Second Test Category"), SELECT_CATEGORY_TYPE);
    assertTrue(message.equals(REMOVED_CATEGORY_1_MESSAGE));
}
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) Post(it.vige.rubia.model.Post) UpdatePoll.updatePoll(it.vige.rubia.selenium.forum.action.UpdatePoll.updatePoll) Poll(it.vige.rubia.model.Poll) RemovePoll.removePoll(it.vige.rubia.selenium.forum.action.RemovePoll.removePoll) CreatePoll.addPoll(it.vige.rubia.selenium.forum.action.CreatePoll.addPoll) Attachment(it.vige.rubia.model.Attachment) PollOption(it.vige.rubia.model.PollOption) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) VerifyPoll.getPollOfCurrentTopic(it.vige.rubia.selenium.forum.action.VerifyPoll.getPollOfCurrentTopic) 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) AfterClass(org.junit.AfterClass)

Example 70 with Forum

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

the class OperationPollTest 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 = 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 = 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 = 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"));
}
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) Post(it.vige.rubia.model.Post) UpdatePoll.updatePoll(it.vige.rubia.selenium.forum.action.UpdatePoll.updatePoll) Poll(it.vige.rubia.model.Poll) RemovePoll.removePoll(it.vige.rubia.selenium.forum.action.RemovePoll.removePoll) CreatePoll.addPoll(it.vige.rubia.selenium.forum.action.CreatePoll.addPoll) Attachment(it.vige.rubia.model.Attachment) PollOption(it.vige.rubia.model.PollOption) RemoveTopic.removeTopic(it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic) CreateTopic.createTopic(it.vige.rubia.selenium.forum.action.CreateTopic.createTopic) Topic(it.vige.rubia.model.Topic) VerifyPoll.getPollOfCurrentTopic(it.vige.rubia.selenium.forum.action.VerifyPoll.getPollOfCurrentTopic) 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)

Aggregations

Forum (it.vige.rubia.model.Forum)100 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)65 Topic (it.vige.rubia.model.Topic)63 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)55 Post (it.vige.rubia.model.Post)52 Category (it.vige.rubia.model.Category)50 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)49 CreateCategory.createCategory (it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory)40 RemoveCategory.removeCategory (it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory)40 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)34 Test (org.junit.Test)33 Poll (it.vige.rubia.model.Poll)23 Attachment (it.vige.rubia.model.Attachment)21 PollOption (it.vige.rubia.model.PollOption)21 SecureActionForum (it.vige.rubia.auth.SecureActionForum)16 CreatePost.createPost (it.vige.rubia.selenium.forum.action.CreatePost.createPost)15 Poster (it.vige.rubia.model.Poster)14 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)14 BeforeClass (org.junit.BeforeClass)14 AfterClass (org.junit.AfterClass)13