use of org.mamute.model.Question 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.Question 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.Question in project mamute by caelum.
the class WithUserPaginatedDAOTest method should_return_only_questions_with_the_provided_user_ordered_by_vote_count.
@Test
public void should_return_only_questions_with_the_provided_user_ordered_by_vote_count() {
Question javaEEQuestion = javaEEQuestion();
javaEEQuestion.substitute(null, upVote);
javaEEQuestion.substitute(null, upVote2);
Question androidQuestion = androidQuestion();
androidQuestion.substitute(null, upVote3);
Question javaQuestion = javaQuestion();
List<Question> perguntasDoAuthor = questionsWithUser.by(author, ByVotes, 1);
assertTrue(perguntasDoAuthor.contains(javaQuestion));
assertTrue(perguntasDoAuthor.contains(javaEEQuestion));
assertTrue(perguntasDoAuthor.contains(androidQuestion));
assertEquals(perguntasDoAuthor.get(0), javaEEQuestion);
assertEquals(perguntasDoAuthor.get(1), androidQuestion);
assertEquals(perguntasDoAuthor.get(2), javaQuestion);
}
use of org.mamute.model.Question in project mamute by caelum.
the class WithUserPaginatedDAOTest method javaQuestion.
private Question javaQuestion() {
Question q = question.withTitle("Some question about java SE and other stuff").withDescription("Please help solving my question about java! Thanks, guys!").withAuthor(author).withTag(defaultTag).build();
session.save(q);
return q;
}
use of org.mamute.model.Question in project mamute by caelum.
the class WithUserPaginatedDAOTest method javaEEQuestion.
private Question javaEEQuestion() {
Question q = question.withTitle("Some question about java ee and other stuff?").withDescription("Please help solving my question about java ee! Thanks, guys!").withAuthor(author).withTag(defaultTag).build();
session.save(q);
return q;
}
Aggregations