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