use of it.vige.rubia.model.PollOption in project rubia-forums by flashboss.
the class ModerateTopicTest method moveSelectedDown.
@Test
public void moveSelectedDown() {
Topic topic = new Topic(new Forum("Third Test Forum"), "Sixth Test Topic");
goToSplitPanel(driver, topic);
String message = moveTopicSelectedDown(driver, topic, null);
assertEquals(ERR_NO_POST_SELECTED, message);
topic.setPosts(asList(new Post[] { new Post("Fifty Test Body"), new Post("Fiftytwo Test Body"), new Post("Fiftythree Test Body"), new Post("Fiftyfour Test Body") }));
message = moveTopicSelectedDown(driver, topic, null);
assertEquals(ERR_DEST_FORUM, message);
Forum forum = new Forum("First Test Forum");
message = moveTopicSelectedDown(driver, null, forum);
assertEquals(ERR_NO_SUBJECT_GIVEN, message);
forum.setTopics(asList(new Topic[] { new Topic("New Test Topic") }));
message = moveTopicSelectedDown(driver, null, forum);
assertEquals(SUCC_TOPIC_SPLITTED, message);
forum.setName("Third Test Forum");
forum.setTopics(asList(new Topic[] { new Topic("Sixth Test Topic") }));
topic.setForum(new Forum("First Test Forum"));
topic.setSubject("New Test Topic");
goToSplitPanel(driver, topic);
message = moveTopicSelectedDown(driver, topic, forum);
assertEquals(ERR_SPLIT_ALL, message);
message = removeTopic(driver, CONFIRM, topic);
assertTrue(message.equals(SUCC_TOPIC_REMOVED));
topic.setSubject("Sixth Test Topic");
topic.setForum(new Forum("Third Test Forum"));
message = removeTopic(driver, CONFIRM, topic);
assertTrue(message.equals(SUCC_TOPIC_REMOVED));
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"))), new Post("Fourtynine Test Body"), new Post("Fifty Test Body"), new Post("Fiftyone Test Body"), new Post("Fiftytwo Test Body"), new Post("Fiftythree Test Body"), new Post("Fiftyfour Test Body") }), 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"));
}
use of it.vige.rubia.model.PollOption in project rubia-forums by flashboss.
the class ModerateTopicTest method moveFromSelectedUp.
@Test
public void moveFromSelectedUp() {
Topic topic = new Topic(new Forum("Third Test Forum"), "Fifth Test with Truncation over 25 characters Topic");
goToSplitPanel(driver, topic);
String message = moveTopicFromSelectedUp(driver, topic, null);
assertEquals(ERR_NO_POST_SELECTED, message);
topic.setPosts(asList(new Post[] { new Post("Fourtyfive Test Body"), new Post("Fourtysix Test Body") }));
message = moveTopicSelectedDown(driver, topic, null);
assertEquals(ERR_DEST_FORUM, message);
Forum forum = new Forum("First Test Forum");
message = moveTopicSelectedDown(driver, null, forum);
assertEquals(ERR_NO_SUBJECT_GIVEN, message);
forum.setTopics(asList(new Topic[] { new Topic("New Test Topic") }));
message = moveTopicSelectedDown(driver, null, forum);
assertEquals(SUCC_TOPIC_SPLITTED, message);
forum.setName("Third Test Forum");
forum.setTopics(asList(new Topic[] { new Topic("Fifth Test with Truncation over 25 characters Topic") }));
topic.setForum(new Forum("First Test Forum"));
topic.setSubject("New Test Topic");
goToSplitPanel(driver, topic);
message = moveTopicSelectedDown(driver, topic, forum);
assertEquals(ERR_SPLIT_ALL, message);
message = removeTopic(driver, CONFIRM, topic);
assertTrue(message.equals(SUCC_TOPIC_REMOVED));
topic.setForum(new Forum("Third Test Forum"));
topic.setSubject("Fifth Test with Truncation over 25 characters Topic");
message = removeTopic(driver, CONFIRM, topic);
assertTrue(message.equals(SUCC_TOPIC_REMOVED));
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"))), new Post("Fourtythree Test Body"), new Post("Fourtyfour Test Body"), new Post("Fourtyfive Test Body"), new Post("Fourtysix Test Body"), new Post("Fourtyseven Test Body"), new Post("Fourtyeight Test Body") }), 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"));
}
use of it.vige.rubia.model.PollOption in project rubia-forums by flashboss.
the class ModerateTopicTest method moveSelectedUp.
@Test
public void moveSelectedUp() {
Topic topic = new Topic(new Forum("Second Test Forum"), "Fourth Test Topic");
goToSplitPanel(driver, topic);
String message = moveTopicSelectedUp(driver, topic, null);
assertEquals(ERR_NO_POST_SELECTED, message);
topic.setPosts(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"))), new Post("Thirtyeight Test Body"), new Post("Fourtyone Test Body") }));
message = moveTopicSelectedDown(driver, topic, null);
assertEquals(ERR_DEST_FORUM, message);
Forum forum = new Forum("First Test Forum");
message = moveTopicSelectedDown(driver, null, forum);
assertEquals(ERR_NO_SUBJECT_GIVEN, message);
forum.setTopics(asList(new Topic[] { new Topic("New Test Topic") }));
message = moveTopicSelectedDown(driver, null, forum);
assertEquals(SUCC_TOPIC_SPLITTED, message);
forum.setName("Second Test Forum");
forum.setTopics(asList(new Topic[] { new Topic("Fourth Test Topic") }));
topic.setForum(new Forum("First Test Forum"));
topic.setSubject("New Test Topic");
goToSplitPanel(driver, topic);
message = moveTopicSelectedDown(driver, topic, forum);
assertEquals(ERR_SPLIT_ALL, message);
message = removeTopic(driver, CONFIRM, topic);
assertTrue(message.equals(SUCC_TOPIC_REMOVED));
topic.setForum(new Forum("Second Test Forum"));
topic.setSubject("Fourth Test Topic");
message = removeTopic(driver, CONFIRM, topic);
assertTrue(message.equals(SUCC_TOPIC_REMOVED));
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"))), new Post("Thirtyseven Test Body"), new Post("Thirtyeight Test Body"), new Post("Thirtynine Test Body"), new Post("Fourty Test Body"), new Post("Fourtyone Test Body"), new Post("Fourtytwo Test Body") }), 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"));
}
use of it.vige.rubia.model.PollOption 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"));
}
use of it.vige.rubia.model.PollOption in project rubia-forums by flashboss.
the class PollController method vote.
/**
* accepts a vote and processes it
*
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String vote() {
String navState = null;
try {
String t = getParameter(p_topicId);
String vote = getParameter(p_vote);
if (t != null && t.trim().length() > 0) {
// setup the data needed for this process
int topicId, voteIndex;
try {
topicId = parseInt(t);
voteIndex = parseInt(vote);
} catch (NumberFormatException e) {
// dont process a vote
return null;
}
Topic topic = forumsModule.findTopicById(topicId);
Poll poll = topic.getPoll();
PollOption selectedOption = poll.getOptions().get(voteIndex);
Poster poster = getPoster(userModule, forumsModule);
// perform the voting on the selected option
if (poster != null) {
poll.getVoted().add(poster.getUserId());
}
selectedOption.incVotes();
forumsModule.update(selectedOption);
}
} catch (Exception e) {
handleException(e);
}
return navState;
}
Aggregations