use of it.vige.rubia.model.Post 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);
}
use of it.vige.rubia.model.Post 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.Post in project rubia-forums by flashboss.
the class VerifyPost method getPostsOfTopics.
public static List<Post> getPostsOfTopics(WebDriver driver, Topic... topics) {
List<Post> posts = new ArrayList<Post>();
WebElement home = driver.findElement(linkText(HOME_LINK));
home.click();
WebElement tableComponent = driver.findElement(className(FORUM_TABLE));
List<WebElement> forumSubjectComponents = tableComponent.findElements(xpath(FORUM_SUBJECT));
int forumComponentSize = forumSubjectComponents.size();
for (int j = 0; j < forumComponentSize; j++) {
home = driver.findElement(linkText(HOME_LINK));
home.click();
tableComponent = driver.findElement(className(FORUM_TABLE));
forumSubjectComponents = tableComponent.findElements(xpath(FORUM_SUBJECT));
WebElement forumEl = forumSubjectComponents.get(j);
forumEl.click();
List<WebElement> subjectComponents = driver.findElements(xpath(SUBJECT_LINK));
int subjectComponentsSize = subjectComponents.size();
for (int i = 0; i < subjectComponentsSize; i++) {
subjectComponents = driver.findElements(xpath(SUBJECT_LINK));
List<String> topicNames = findTopicNames(topics);
if (topicNames.contains(subjectComponents.get(i).getText())) {
subjectComponents = driver.findElements(xpath(SUBJECT_LINK));
WebElement subjectComponent = subjectComponents.get(i);
subjectComponent.click();
posts.addAll(getPostsOfCurrentTopic(driver));
String forumLinkText = driver.findElement(id(FORUM_LINK)).getText();
driver.findElement(linkText(forumLinkText)).click();
}
}
}
return posts;
}
use of it.vige.rubia.model.Post in project rubia-forums by flashboss.
the class VerifyPost method getLastPostOfCurrentForum.
public static Post getLastPostOfCurrentForum(WebDriver driver, Topic topic) {
WebElement postComponent = driver.findElements(className(PROFILE_LINK)).get(0).findElement(xpath("../tr/td/a[contains(text(),'" + topic.getSubject() + "')]")).findElement(xpath("../a"));
postComponent.click();
List<Post> posts = getPostsOfCurrentTopic(driver);
return posts.get(posts.size() - 1);
}
use of it.vige.rubia.model.Post 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));
}
Aggregations