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;
}
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);
}
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());
}
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));
}
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"));
}
Aggregations