Search in sources :

Example 6 with Answer

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);
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 7 with Answer

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());
}
Also used : Answer(org.mamute.model.Answer) User(org.mamute.model.User) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 8 with Answer

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);
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 9 with Answer

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));
}
Also used : Answer(org.mamute.model.Answer) User(org.mamute.model.User) Question(org.mamute.model.Question) Test(org.junit.Test)

Example 10 with Answer

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);
}
Also used : Answer(org.mamute.model.Answer) Test(org.junit.Test)

Aggregations

Answer (org.mamute.model.Answer)31 Test (org.junit.Test)27 Question (org.mamute.model.Question)24 User (org.mamute.model.User)9 ArrayList (java.util.ArrayList)6 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)5 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)5 LoggedUser (org.mamute.model.LoggedUser)5 AnswerAndVotes (org.mamute.model.AnswerAndVotes)4 AnswerInformation (org.mamute.model.AnswerInformation)4 Comment (org.mamute.model.Comment)3 Tag (org.mamute.model.Tag)3 SuspectMassiveVote (org.mamute.dto.SuspectMassiveVote)2 Information (org.mamute.model.Information)2 Vote (org.mamute.model.Vote)2 CustomBrutauthRules (br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules)1 Get (br.com.caelum.vraptor.Get)1 Nullable (javax.annotation.Nullable)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1 DateTime (org.joda.time.DateTime)1