use of org.mamute.model.Question in project mamute by caelum.
the class InformationDAOTest method should_get_pending_history.
@Test
public void should_get_pending_history() {
newQuestion(author);
Question question2 = newQuestion(author);
newChangesWithStatus(question2, 2, PENDING);
Question question3 = newQuestion(author);
newChangesWithStatus(question3, 3, PENDING);
ModeratableAndPendingHistory pending = informations.pendingByUpdatables(Question.class);
List<Moderatable> questions = pending.moderatables();
assertEquals(2, questions.size());
assertEquals(question2.getId(), questions.get(0).getId());
List<Information> pendingQuestion2 = pending.pendingInfoFor(questions.get(0));
assertEquals(2, pendingQuestion2.size());
List<Information> pendingQuestion3 = pending.pendingInfoFor(questions.get(1));
assertEquals(3, pendingQuestion3.size());
}
use of org.mamute.model.Question in project mamute by caelum.
the class ReputationEventDAOTest method should_return_tag_answerer_summary.
@Test
public void should_return_tag_answerer_summary() {
User solutionAuthor = user("solutionAuthor", "solution@x.com");
User otherAnswerAuthor = user("answerAuthor", "other@x.com");
Tag tag = tag("teste");
Question question1 = question(author, tag);
Answer answer1 = answer("BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA", question1, solutionAuthor);
Answer answer2 = answer("BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA", question1, otherAnswerAuthor);
Question question2 = question(author, tag);
Answer answer3 = answer("BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA", question2, solutionAuthor);
ReputationEvent answer3Upvote = new ReputationEvent(EventType.ANSWER_UPVOTE, question2, solutionAuthor);
for (int i = 0; i < 30; i++) {
ReputationEvent questionUpvote = new ReputationEvent(EventType.QUESTION_UPVOTE, question1, author);
session.save(questionUpvote);
}
ReputationEvent answerIsSolution = new ReputationEvent(EventType.SOLVED_QUESTION, question1, solutionAuthor);
ReputationEvent solutionUpvote = new ReputationEvent(EventType.ANSWER_UPVOTE, question1, solutionAuthor);
long karmaRewardForSolution = SOLVED_QUESTION.reward().longValue() + ANSWER_UPVOTE.reward().longValue() * 2;
ReputationEvent answer2Upvote = new ReputationEvent(EventType.ANSWER_UPVOTE, question1, otherAnswerAuthor);
ReputationEvent answer2Upvote2 = new ReputationEvent(EventType.ANSWER_UPVOTE, question1, otherAnswerAuthor);
long karmaRewardForOtherAnswer = ANSWER_UPVOTE.reward().longValue() * 2;
session.save(tag);
session.save(question1);
session.save(question2);
session.save(otherAnswerAuthor);
session.save(solutionAuthor);
session.save(answer1);
session.save(answer2);
session.save(answer3);
session.save(answerIsSolution);
session.save(solutionUpvote);
session.save(answer2Upvote);
session.save(answer2Upvote2);
session.save(answer3Upvote);
List<UserSummaryForTag> summaryForTag = reputationEvents.getTopAnswerersSummaryAllTime(tag);
assertEquals(2, summaryForTag.size());
assertEquals(karmaRewardForSolution, summaryForTag.get(0).getKarmaReward().longValue());
assertEquals(solutionAuthor, summaryForTag.get(0).getUser());
assertEquals(2l, summaryForTag.get(0).getCount().longValue());
assertEquals(karmaRewardForOtherAnswer, summaryForTag.get(1).getKarmaReward().longValue());
assertEquals(otherAnswerAuthor, summaryForTag.get(1).getUser());
assertEquals(1l, summaryForTag.get(1).getCount().longValue());
}
use of org.mamute.model.Question in project mamute by caelum.
the class ReputationEventDAOTest method should_return_tag_asker_summary.
@Test
public void should_return_tag_asker_summary() {
User question1Author = user("solutionAuthor", "solution@x.com");
User question3Author = user("answerAuthor", "other@x.com");
session.save(question3Author);
session.save(question1Author);
Tag tag = tag("teste");
session.save(tag);
Question question1 = question(question1Author, tag);
Question question2 = question(question1Author, tag);
Question question3 = question(question3Author, tag);
session.save(question1);
session.save(question2);
session.save(question3);
for (int i = 0; i < 30; i++) {
session.save(new ReputationEvent(EventType.QUESTION_UPVOTE, question1, question1Author));
}
session.save(new ReputationEvent(EventType.QUESTION_UPVOTE, question2, question1Author));
long karmaRewardForQuestion1 = EventType.QUESTION_UPVOTE.reward().longValue() * 31;
for (int i = 0; i < 10; i++) {
session.save(new ReputationEvent(EventType.QUESTION_UPVOTE, question3, question3Author));
}
long karmaRewardForQuestion2 = EventType.QUESTION_UPVOTE.reward().longValue() * 10;
List<UserSummaryForTag> summaryForTag = reputationEvents.getTopAskersSummaryAllTime(tag);
assertEquals(2, summaryForTag.size());
assertEquals(karmaRewardForQuestion1, summaryForTag.get(0).getKarmaReward().longValue());
assertEquals(question1Author, summaryForTag.get(0).getUser());
assertEquals(2l, summaryForTag.get(0).getCount().longValue());
assertEquals(karmaRewardForQuestion2, summaryForTag.get(1).getKarmaReward().longValue());
assertEquals(question3Author, summaryForTag.get(1).getUser());
assertEquals(1l, summaryForTag.get(1).getCount().longValue());
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionDAOTest method javaQuestion.
private Question javaQuestion() {
Question q = question.withTitle("Some question about java SE and other stuff").withDescription(notMarked("Please help solving my question about java! Thanks, guys!")).withAuthor(author).withTag(java).build();
session.save(q);
return q;
}
use of org.mamute.model.Question in project mamute by caelum.
the class QuestionDAOTest method should_find_questions_visible_and_order_by_creation_date.
@Test
public void should_find_questions_visible_and_order_by_creation_date() throws Exception {
Question question1 = question(author, java);
Question question2 = question(author, java);
question2.remove();
session.save(question1);
session.save(question2);
List<RssContent> questions = questionsForAnyone.orderedByCreationDate(5);
assertEquals(1, questions.size());
}
Aggregations