use of org.mamute.model.Answer in project mamute by caelum.
the class WithUserPaginatedDAOTest method should_return_only_answers_with_the_provided_user_ordered_by_vote_count.
@Test
public void should_return_only_answers_with_the_provided_user_ordered_by_vote_count() {
Question androidQuestion = androidQuestion();
Answer ehMuito = answer("Sim! É muito ruim! (tanto quanto iOS)", androidQuestion, author);
ehMuito.substitute(null, upVote);
ehMuito.substitute(null, upVote2);
Answer nemEh = answer("Não, é a melhor plataforma mobile do mundo!", androidQuestion, author);
nemEh.substitute(null, upVote3);
Answer maisOuMenos = answer("Cara, veja bem: depende do seu ponto de vista.", androidQuestion, author);
session.save(upVote);
session.save(upVote2);
session.save(upVote3);
session.save(maisOuMenos);
session.save(ehMuito);
session.save(nemEh);
List<Answer> respostasDoAuthor = answersWithUser.by(author, ByVotes, 1);
assertTrue(respostasDoAuthor.contains(maisOuMenos));
assertTrue(respostasDoAuthor.contains(ehMuito));
assertTrue(respostasDoAuthor.contains(nemEh));
assertEquals(respostasDoAuthor.get(0), ehMuito);
assertEquals(respostasDoAuthor.get(1), nemEh);
assertEquals(respostasDoAuthor.get(2), maisOuMenos);
}
use of org.mamute.model.Answer in project mamute by caelum.
the class QuestionTest method should_not_be_touched_when_marked_as_solved.
@Test
public void should_not_be_touched_when_marked_as_solved() {
Question shouldILiveForever = question.build();
User touchedBy = shouldILiveForever.getLastTouchedBy();
User leo = user("", "");
Answer yes = answer("my answer", shouldILiveForever, leo);
assertEquals(User.GHOST, shouldILiveForever.getLastTouchedBy());
shouldILiveForever.markAsSolvedBy(yes);
assertEquals(touchedBy, shouldILiveForever.getLastTouchedBy());
}
use of org.mamute.model.Answer in project mamute by caelum.
the class QuestionTest method can_not_be_marked_as_solved_by_the_an_answer_that_is_not_mine.
@Test(expected = RuntimeException.class)
public void can_not_be_marked_as_solved_by_the_an_answer_that_is_not_mine() {
Question shouldILiveForever = question.build();
Answer yes = answer("", null, null);
shouldILiveForever.markAsSolvedBy(yes);
}
use of org.mamute.model.Answer in project mamute by caelum.
the class QuestionTest method should_return_false_if_is_author_and_there_is_solution.
@Test
public void should_return_false_if_is_author_and_there_is_solution() throws Exception {
User author = user("Fernanda", "bla@bla.com", 1l);
Question question = question(author);
Answer answer = answer("", question, author);
question.markAsSolvedBy(answer);
assertFalse(question.canMarkAsSolution(author));
}
use of org.mamute.model.Answer in project mamute by caelum.
the class FlaggableDAOTest method should_get_count_of_answers_with_two_flags.
@Test
public void should_get_count_of_answers_with_two_flags() throws Exception {
Answer flagged = answer("answer answer answer answer answer", question, author);
Answer other = answer("answer answer answer answer answer", question, author);
addFlags(flagged, 10, author);
addFlags(other, 1, author);
session.save(java);
session.save(question);
session.save(other);
session.save(flagged);
int count = flaggables.flaggedButVisibleCount(Answer.class);
assertEquals(1, count);
}
Aggregations