Search in sources :

Example 11 with Answer

use of org.mamute.model.Answer in project mamute by caelum.

the class InformationDAOTest method should_get_pending_count.

@Test
public void should_get_pending_count() {
    Answer answer = answer("info1 info1 info1 info1 info1 info1 info1 ", question, author);
    session.save(answer);
    newPendingChangesAnswer(answer, 2);
    newChangesWithStatus(question, 3, PENDING);
    Long count = informations.pendingCount();
    assertEquals(5l, count.longValue());
}
Also used : Answer(org.mamute.model.Answer) Test(org.junit.Test)

Example 12 with Answer

use of org.mamute.model.Answer in project mamute by caelum.

the class RetrieveKarmaTest method should_not_handle_answer_without_moderator.

@Test
public void should_not_handle_answer_without_moderator() {
    Answer answer = answer(null, question, null);
    assertFalse(retrieveKarmaWithoutModerator.shouldHandle(answer));
}
Also used : Answer(org.mamute.model.Answer) Test(org.junit.Test)

Example 13 with Answer

use of org.mamute.model.Answer in project mamute by caelum.

the class AnswerAndVotesTest method should_fill_value_with_null_only_answers_that_has_no_currentUserVote.

@Test
public void should_fill_value_with_null_only_answers_that_has_no_currentUserVote() {
    Question q = question.build();
    Object[] first = new Object[] { answerFor(q, 1), mock(Vote.class) };
    Object[] second = new Object[] { answerFor(q, 2), mock(Vote.class) };
    Answer third = answerFor(q, 3);
    List<Object[]> voteList = new ArrayList<>();
    voteList.add(first);
    voteList.add(second);
    List<Answer> answers = new ArrayList<>();
    answers.add((Answer) first[0]);
    answers.add((Answer) second[0]);
    answers.add(third);
    AnswerAndVotes votes = new AnswerAndVotes(q, answers, voteList);
    Map<Answer, Vote> map = votes.getVotes();
    assertEquals(first[1], map.get(first[0]));
    assertEquals(second[1], map.get(second[0]));
    assertEquals(null, map.get(third));
    assertTrue(map.containsKey(third));
}
Also used : Answer(org.mamute.model.Answer) Vote(org.mamute.model.Vote) ArrayList(java.util.ArrayList) Question(org.mamute.model.Question) AnswerAndVotes(org.mamute.model.AnswerAndVotes) Test(org.junit.Test)

Example 14 with Answer

use of org.mamute.model.Answer in project mamute by caelum.

the class AnswerTest method should_approve_answer_info.

@Test
public void should_approve_answer_info() throws Exception {
    Question myQuestion = question.withTitle("question title").withDescription("description").withAuthor(author).build();
    Answer answer = answer("blablablab", myQuestion, author);
    Information approved = new AnswerInformation(notMarked("blablabalblab"), new LoggedUser(editUser, null), answer, "");
    answer.approve(approved);
    assertEquals(approved, answer.getInformation());
    assertEquals(editUser, answer.getLastTouchedBy());
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) LoggedUser(org.mamute.model.LoggedUser) AnswerInformation(org.mamute.model.AnswerInformation) Information(org.mamute.model.Information) AnswerInformation(org.mamute.model.AnswerInformation) Test(org.junit.Test)

Example 15 with Answer

use of org.mamute.model.Answer in project mamute by caelum.

the class AnswerTest method should_mark_question_as_solved.

@Test
public void should_mark_question_as_solved() {
    Question canILiveForever = question.build();
    Answer yes = answer("Yes", canILiveForever, null);
    assertEquals(null, canILiveForever.getSolution());
    yes.markAsSolution();
    assertEquals(yes, canILiveForever.getSolution());
}
Also used : Answer(org.mamute.model.Answer) Question(org.mamute.model.Question) 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